Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Collection of geometry utilities to work with data in different projections, multiple polygons and polygon overlays

License

Notifications You must be signed in to change notification settings

visualNACert/GeometryUtilities

Open more actions menu

Repository files navigation

Build Status codecov documentation pod platforms pod version pod license

Geometry Utilities

This is a small collection of geometry utilities to work with data in different projections, multiple polygons and polygon overlays:

  • Parse WKT and extract multiple polygons (implemented in Objective-C for performance's sake).
  • Convert multiple polygons into single CGPathRef to be drawable with MapKit as a single polygon.
  • Convert from Mercator projection and WGS84 coordinate system.

API

// Extract polygons from a WKT string
let wkt = "MULTIPOLYGON(((0.0 0.0, 0.0 1.0, 1.0 1.0, 1.0 0.0)))"
let polygons = WKT.polygons(in: wkt)
let polygon = polygons.first
polygon?.coordinates() // (0, 0), (0, 1), (1, 1), (1, 0), (0, 0)

// Serialize polygons into a WKT string
let polygon = MKPolygon(
    coordinates: [
        CLLocationCoordinate2D(
            latitude: 0,
            longitude: 0
        ),
        CLLocationCoordinate2D(
            latitude: 1,
            longitude: 0
        ),
        CLLocationCoordinate2D(
            latitude: 1,
            longitude: 1
        ),
        CLLocationCoordinate2D(
            latitude: 0,
            longitude: 1
        )
    ]
)
polygon.wktString() // MULTIPOLYGON(((0.0 0.0, 0.0 1.0, 1.0 1.0, 1.0 0.0)))

About

Collection of geometry utilities to work with data in different projections, multiple polygons and polygon overlays

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published
Morty Proxy This is a proxified and sanitized view of the page, visit original site.