Skip to content

0.1.0

Latest

Choose a tag to compare

@csanfilippo csanfilippo released this 04 Oct 16:01
· 5 commits to main since this release

The first release of sfera: RFC 7946 GeoJSON for Swift, valid by construction.

Highlights

  • Every GeoJSON object type. Position, all seven geometries (Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, GeometryCollection), Feature, FeatureCollection, and GeoJSON for decoding input of unknown kind.
  • Invalid values cannot exist. Coordinates are validated when a Position is created, with a typed PositionError. A line string needs two positions and a ring three vertices, both checked at compile time.
  • Rings close themselves, and polygons follow the right-hand rule. Rings given in the wrong direction are reversed, both when building a Polygon and when decoding one.
  • Exact numbers. Whole numbers in properties and identifiers are stored as Int64, so 64-bit identifiers survive a round trip exactly, also on 32-bit platforms.
  • Decoding enforces the same rules as the initializers, so a decoded value is always valid. Rejections are DecodingErrors with the coding path of the offending value.
  • Codable, Sendable and Hashable throughout, with no third-party dependencies.

Platforms

Swift 6.4, on iOS, macOS, watchOS and tvOS 26, Linux, and WebAssembly (WASI). All are tested in CI. Embedded Swift is not supported.

Installation

.package(url: "https://github.com/csanfilippo/sfera.git", from: "0.1.0"),

Known limitations

  • bbox and foreign members are not modelled: decoding ignores them, so they are lost in a round trip.
  • Encoding a .number holding NaN or infinity throws, because JSON cannot represent them.

The API may still change before 1.0. Breaking changes will bump the minor version.