Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ algorithms.
- [**gis-tools-geopackage**](https://github.com/Outdooractive/gis-tools-geopackage) — reads and writes OGC GeoPackage (.gpkg) files
- [**gis-tools-gpx**](https://github.com/Outdooractive/gis-tools-gpx) — reads and writes GPX 1.1 files (.gpx)
- [**gis-tools-fit**](https://github.com/Outdooractive/gis-tools-fit) — reads and writes FIT activity files (.fit)
- [**mvt-tools**](https://github.com/Outdooractive/mvt-tools) — reads and writes Mapbox Vector Tiles (MVT) and MapLibre Tiles (MLT); despite its name, its `mvt` command-line tool converts between all supported formats (MVT, MLT, GeoJSON, GPX, FIT, CSV, Shapefile and GeoPackage), and is available via `brew install Outdooractive/homebrew-tap/mvt-tools`
- Spatial search with a R-tree
- Includes many spatial algorithms (ported from turf.js), and more to come
- Many algorithms accept a `gridSize` parameter to snap coordinates to a uniform grid before computation, reducing noise from floating-point precision
Expand Down
2 changes: 1 addition & 1 deletion Sources/GISTools/GISTools.docc/CSV.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,4 @@ by first appearance across all features.

## Related packages

<doc:FIT>, <doc:GeoPackage>, <doc:GPX>, <doc:Shapefile>
<doc:FIT>, <doc:GeoPackage>, <doc:GPX>, <doc:Shapefile>, <doc:MVTTools>
2 changes: 1 addition & 1 deletion Sources/GISTools/GISTools.docc/FIT.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,4 @@ timestamps.

## Related packages

<doc:CSV>, <doc:GeoPackage>, <doc:GPX>, <doc:Shapefile>
<doc:CSV>, <doc:GeoPackage>, <doc:GPX>, <doc:Shapefile>, <doc:MVTTools>
4 changes: 3 additions & 1 deletion Sources/GISTools/GISTools.docc/GISTools.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ The package covers:
- Opt-in graph construction, routing and network analysis

Companion packages add CSV, FIT, GeoPackage, GPX and Shapefile support:
<doc:CSV>, <doc:FIT>, <doc:GeoPackage>, <doc:GPX> and <doc:Shapefile>.
<doc:CSV>, <doc:FIT>, <doc:GeoPackage>, <doc:GPX> and <doc:Shapefile>. Tiled
vector formats (MVT and MLT) and the `mvt` CLI live in <doc:MVTTools>.

> Important: GISTools 3.0 contains source-breaking changes to containment,
> validity, projected coordinates, unlocated features, bounding boxes and the
Expand Down Expand Up @@ -63,6 +64,7 @@ let decoded = Feature(jsonString: json)
- <doc:GeoPackage>
- <doc:GPX>
- <doc:Shapefile>
- <doc:MVTTools>

### Performance

Expand Down
2 changes: 1 addition & 1 deletion Sources/GISTools/GISTools.docc/GPX.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,4 @@ namespaces are preserved. GPX 1.0 input is read-only; writing always emits GPX

## Related packages

<doc:CSV>, <doc:FIT>, <doc:GeoPackage>, <doc:Shapefile>
<doc:CSV>, <doc:FIT>, <doc:GeoPackage>, <doc:Shapefile>, <doc:MVTTools>
2 changes: 1 addition & 1 deletion Sources/GISTools/GISTools.docc/GeoPackage.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,4 @@ Attribute columns other than `fid`, `id` and geometry are mapped as:

## Related packages

<doc:CSV>, <doc:FIT>, <doc:GPX>, <doc:Shapefile>
<doc:CSV>, <doc:FIT>, <doc:GPX>, <doc:Shapefile>, <doc:MVTTools>
99 changes: 99 additions & 0 deletions Sources/GISTools/GISTools.docc/MVTTools.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# mvt-tools

[`mvt-tools`](https://github.com/Outdooractive/mvt-tools) reads and writes
[Mapbox Vector Tiles (MVT)](https://github.com/mapbox/vector-tile-spec) and
[MapLibre Tiles (MLT)](https://maplibre.org/maplibre-tile-spec/), and ships the
`mvt` command-line tool. Despite its name, `mvt` is not limited to vector tiles:
it inspects, queries and converts every supported format, including GeoJSON,
GPX, FIT, CSV, Shapefile and GeoPackage.

- Repository: [mvt-tools](https://github.com/Outdooractive/mvt-tools)
- Product: `MVTTools`
- Formats: MVT 2.1 (including version-1 layers) and MLT (`0x01`), with gzip
input detection
- CLI: `mvt` with `dump`, `info`, `query`, `merge`, `import`, `export`, `load`,
`rezoom` and `reproject`; it converts between all supported formats, not just
vector tiles

MVT and MLT are tiled, layered formats, so `mvt-tools` does not wrap
``FeatureCollection`` like the `gis-tools-*` packages. It provides a
`VectorTile` model instead: layers of features, a tile coordinate, a
projection and tile-space buffers, with optional R-tree indexing.

## Installation

```swift
dependencies: [
.package(
url: "https://github.com/Outdooractive/gis-tools",
from: "3.0.0"),
.package(
url: "https://github.com/Outdooractive/mvt-tools",
from: "3.0.0",
traits: ["EnableMVT", "EnableMLT"]),
],
targets: [
.target(
name: "MyTarget",
dependencies: [
.product(name: "GISTools", package: "gis-tools"),
.product(name: "MVTTools", package: "mvt-tools"),
]),
]
```

MVT and MLT are opt-in package traits, so enable `EnableMVT` and/or
`EnableMLT` explicitly. The optional `EnableMLTCXX` trait selects the
deprecated C++ MLT backend instead of the pure Swift implementation.

## Reading

```swift
import MVTTools

let data = try Data(contentsOf: mvtURL)
let tile = try VectorTile(mvtData: data, x: 8716, y: 8015, z: 14)

print(tile.layerNames)
print(tile.features(for: "water").count)
```

MLT uses the same initializer shape:

```swift
let tile = try VectorTile(mltData: data, x: 8716, y: 8015, z: 14)
```

## Writing

```swift
var options = VectorTile.ExportOptions(compression: .default)
options.mlt.useVertexDictionaries = true

let mvtData = tile.mvtData(options: options)
try tile.writeMLT(to: mltURL, options: options)
```

## Command line tool

The `mvt` CLI is not limited to vector tiles. Every command accepts any
supported format, and `merge`, `import` and `export` convert between MVT, MLT,
GeoJSON, GPX, FIT, CSV, Shapefile and GeoPackage.

It is available via Homebrew:

```bash
brew install Outdooractive/homebrew-tap/mvt-tools
```

To build it from source with every format coder:

```bash
swift build --enable-all-traits --product mvt
mvt info tile.mvt -x 8716 -y 8015 -z 14
mvt export tile.mvt --output tile.geojson
```

## Related packages

<doc:CSV>, <doc:FIT>, <doc:GeoPackage>, <doc:GPX>, <doc:Shapefile>
2 changes: 1 addition & 1 deletion Sources/GISTools/GISTools.docc/Shapefile.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,4 @@ choice; see <doc:GeoPackage>.

## Related packages

<doc:CSV>, <doc:FIT>, <doc:GeoPackage>, <doc:GPX>
<doc:CSV>, <doc:FIT>, <doc:GeoPackage>, <doc:GPX>, <doc:MVTTools>
Loading