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
23 changes: 0 additions & 23 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ let package = Package(
.library(
name: "GISTools",
targets: ["GISTools"]),
.library(
name: "GISToolsGeoPackage",
targets: ["GISToolsGeoPackage"]),
],
traits: [
.trait(
Expand All @@ -25,34 +22,14 @@ let package = Package(
.trait(
name: "EnableMeasurementConversionExtensions",
description: "Adds conversion properties that return Measurement<UnitLength> values for unit-aware arithmetic."),
.trait(
name: "EnableShapefileSupport",
description: "Adds Shapefile (.shp/.dbf/.shx/.prj) read and write support."),
],
dependencies: [],
targets: [
.target(
name: "GISTools"),
.systemLibrary(
name: "CSQLite",
pkgConfig: "sqlite3",
providers: [
.apt(["libsqlite3-dev"]),
.brew(["sqlite3"]),
]),
.target(
name: "GISToolsGeoPackage",
dependencies: [
"GISTools",
"CSQLite",
]),
.testTarget(
name: "GISToolsTests",
dependencies: ["GISTools"],
exclude: ["TestData"]),
.testTarget(
name: "GISToolsGeoPackageTests",
dependencies: ["GISToolsGeoPackage"],
exclude: ["TestData"]),
]
)
57 changes: 10 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ GIS tools for Swift, including a [GeoJSON][3] implementation and many algorithms
- Supports EPSG:3857 (web mercator) and EPSG:4326 (geodetic) conversions
- Experimental support for EPSG:4978 (ECEF geocentric) coordinate conversion and spatial operations
- Supports WKT/WKB/TWKB, also with different projections
- Reads and writes ESRI Shapefiles (.shp/.dbf/.shx/.prj)
- Reads and writes OGC GeoPackage (.gpkg) files
- [**gis-tools-shapefile**](https://github.com/Outdooractive/gis-tools-shapefile) — reads and writes ESRI Shapefiles (.shp/.dbf/.shx/.prj)
- [**gis-tools-geopackage**](https://github.com/Outdooractive/gis-tools-geopackage) — reads and writes OGC GeoPackage (.gpkg) files
- 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 Expand Up @@ -75,9 +75,6 @@ let distance: Double = 1000.0.meters // raw meters
let total = distance + 500.0.feet // Double arithmetic (both in meters)
```

**Storage format traits**:
- `EnableShapefileSupport` — adds Shapefile (.shp/.dbf/.shx/.prj) read/write support via `ShapefileCoder` and convenience extensions on `FeatureCollection`.

## Usage

Please see also the [API documentation][8] (via Swift Package Index).
Expand Down Expand Up @@ -891,58 +888,24 @@ let coordinates = polyline.decodePolyline()

# GeoPackage (.gpkg)

Provides read/write support for the OGC GeoPackage format via the `GISToolsGeoPackage` target.

`FeatureCollection` has convenience methods:
GeoPackage support has been extracted into its own package: [**gis-tools-geopackage**](https://github.com/Outdooractive/gis-tools-geopackage).

```swift
// Read from a GeoPackage file:
let fc = try FeatureCollection(geopackage: url, table: "features")

// Write to a GeoPackage file:
try fc.writeGeopackage(to: url, table: "features")
dependencies: [
.package(url: "https://github.com/Outdooractive/gis-tools-geopackage", from: "1.0.0"),
]
```

Properties are mapped per the GeoPackage spec:
- `INTEGER` → `Int`, `REAL` → `Double`, `TEXT` → `String`, `BLOB` → `String` (Base64)
- `BOOLEAN` → `Bool`, `DATE`/`DATETIME` → `String` (ISO 8601)

Mixed geometry types are rejected with an error.

# Shapefile (.shp / .dbf / .shx / .prj)

Provides read/write support for the ESRI Shapefile format. `FeatureCollection` has convenience methods to read and write Shapefiles.

The Shapefile reader handles Point, PolyLine, Polygon, MultiPoint, and MultiPatch geometry types, including Z (altitude) and M (measure) variants. Attributes are mapped to and from `Feature.properties` via the companion `.dbf` file. The `.prj` file is read to determine the source projection. The `.shx` index file is written for compatibility with tools that require it.

## Reading
Shapefile support has been extracted into its own package: [**gis-tools-shapefile**](https://github.com/Outdooractive/gis-tools-shapefile).

```swift
// Read from a base URL (looks for .shp, .dbf, .prj):
let fc = try ShapefileCoder.read(from: url)

// Or via the convenience initializer:
let fc = FeatureCollection(shapefile: url)
```

The source projection is determined from the `.prj` file. If no `.prj` file is present, EPSG:4326 is assumed.

## Writing

```swift
// Write to a base URL (creates .shp, .dbf, .shx, .prj):
try ShapefileCoder.write(fc, to: url)

// Or via the convenience method:
try fc.writeShapefile(to: url)
dependencies: [
.package(url: "https://github.com/Outdooractive/gis-tools-shapefile", from: "1.0.0"),
]
```

The output projection is taken from the `FeatureCollection`'s `projection` property.

## MultiPatch support

MultiPatch (type 31) geometries are decomposed into individual `Polygon` parts and wrapped in a `GeometryCollection`. Triangle strips and triangle fans are converted to triangle polygons.

# Algorithms
Hint: Most algorithms are optimized for EPSG:4326. Using other projections will have a performance penalty due to added projections.<br>
The union algorithm works in EPSG:3857 (Web Mercator) for uniform Cartesian tolerances. This limits its usable latitude range to approximately ±85°.
Expand Down
5 changes: 0 additions & 5 deletions Sources/CSQLite/module.modulemap

This file was deleted.

1 change: 0 additions & 1 deletion Sources/CSQLite/shim.h

This file was deleted.

Loading
Loading