Swiftpack.co - Package - MonsantoCo/GeospatialSwift

GeospatialSwift

Carthage Compatible Swift 5.1 Platforms

What is GeospatialSwift?

GeospatialSwift is an interface to translate a GeoJson document / dictionary into a swift object which fully conforms to the more recent GeoJson specification - August 2016.

A GeoJsonObject can be transformed to a bounding box.

Features

  • Unit tested with high coverage
  • Ongoing development

Installation

Carthage

github "MonsantoCo/GeospatialSwift" ~> 1.0.0

Package Manager

.package(url: "git@github.com:MonsantoCo/GeospatialSwift.git", from: "1.0.0")

Geospatial

Geospatial

  • The main interface consisting of 4 sub interface

GeoJson

Geospatial.geoJson

  • Full GeoJson specification support to create a GeoJsonObject
  • A GeoJsonObject is the base object of GeospatialSwift functionality
  • Bounding Box generated from any GeoJsonObject
  • GeoJson generated from any GeoJsonObject

GeoJsonObjects

  • Minimum distance to a given point (Optional error distance)

  • Contains a given point (Optional error distance)

  • Bounding box for any shape

  • GeoJson returned as a Dictionary

  • Coordinates array for the associated geometry

  • Line segments with midpoint and bearing functions

  • Point

    • Normalize
  • MultiPoint

  • LineString

    • Length
  • MultiLineString

    • Length
  • Polygon

    • Centroid
    • Area
  • MultiPolygon

    • Area
  • GeometryCollection

  • Feature

  • FeatureCollection

Geohash

Geospatial.geohash

  • Create a geohash from a coordinate or bounding box
  • Get geohash neighbors (8)
  • Create a bounding box for a geohash

WKT - Not Fully Supported

Geospatial.parse(wkt: String) -> GeoJsonObject

  • Minimal WKT parsing support which transforms to a GeoJsonObject.
  • POINT, LINESTRING, MULTILINESTRING, POLYGON, MULTPOLYGON.
  • This is currently only intended to parse a very simple WKT string

Running GeospatialSwift in XCode

  • Bootstrap Example: rm -rf *.xcodeproj || rm -rf .build || swift package resolve && swift package generate-xcodeproj && open *.xcodeproj
  • In the Target GeospatialSwift, select the tab Signing & Capabilities and check the box Automatically manage signing
  • In the scheme menu, select Edit Scheme..., select the Test item on the left, select the tab Options, and check the box Gather coverage for "all targets"
  • In the target GeospatialSwiftTests select the tab Build Phases and add a Run Script Phase with the body $PROJECT_DIR/Scripts/parrot.sh and move the item to the top of the Buld Phases just below Dependencies.
  • In the target GeospatialSwift select the tab Build Phases and add a Run Script Phase with the body $PROJECT_DIR/Scripts/swiftlint.sh.

Extending GeospatialSwift in XCode

Option 1: Run with the current XCode project as is

Option 2: Rebuild it using generate-xcodeproj

  • Setup: Package Manager Example: rm -rf *.xcodeproj || rm -rf .build || swift package resolve && swift package generate-xcodeproj && open *.xcodeproj
  • Building: In the Target GeospatialSwift, select the tab Signing & Capabilities and check the box Automatically manage signing
  • Code Coverage: In the scheme menu, select Edit Scheme..., select the Test item on the left, select the tab Options, and check the box Gather coverage for "all targets"
  • Mocking: In the target GeospatialSwiftTests select the tab Build Phases and add a Run Script Phase with the body $PROJECT_DIR/Scripts/parrot.sh and move the item to the top of the Buld Phases just below Dependencies.
  • Linting: In the target GeospatialSwift select the tab Build Phases and add a Run Script Phase with the body $PROJECT_DIR/Scripts/swiftlint.sh.

Github

link
Stars: 3

Dependencies

Used By

Total: 0

Releases

Performance Enhancements - 2020-01-28 21:54:59

  • Rebuilt the XCode project as a Package
  • Removed most protocols in favor of public struct objects
  • Increased performance all around
  • Added an option to pass in pre-validated GeoJson which is parsed without validation. This will have a a significant performance boost with the side effect of the application crashing if the GeoJson was not validated. The older parse methods still validate but should only need to be run once when pulling in new data and thereafter can be considered validated.
  • Large performance boost for Geohash coding and neighbors
  • Significant API changes
  • TimberSwift is no longer a dependency in favor of now passing back invalid geo json errors.

Swift 5 - 2019-04-22 18:03:32

General Enhancements - 2018-10-30 21:21:14

Added Timber Swift - 2018-06-19 12:54:21

  • Delegates logging to using application
  • Clean up

Initial Release - 2018-05-08 21:04:19