https://github.com/3sidedcube/cubegeojson
A GeoJSON library for iOS and OSX written in swift
https://github.com/3sidedcube/cubegeojson
Last synced: 11 months ago
JSON representation
A GeoJSON library for iOS and OSX written in swift
- Host: GitHub
- URL: https://github.com/3sidedcube/cubegeojson
- Owner: 3sidedcube
- License: apache-2.0
- Created: 2016-05-03T09:17:06.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2024-11-27T12:11:09.000Z (over 1 year ago)
- Last Synced: 2024-11-27T13:20:00.890Z (over 1 year ago)
- Language: Swift
- Size: 95.7 KB
- Stars: 9
- Watchers: 10
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CubeGeoJSON
[](https://github.com/Carthage/Carthage) [](https://swift.org/blog/swift-5-5-released/)
A GeoJSON library for iOS, macOS, and watchOS written in Swift.
Features:
- Parse all kinds of [Geometry](http://geojson.org/geojson-spec.html#geometry-objects) objects
- Auto-Creates MKShape subclasses to represent your GeoJSON structure
- Allows serialising back to swift dictionary objects
- Adds useful helper methods for doing calculations with and editing GeoJSON structures
## Installation
### Carthage
[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
You can install Carthage with [Homebrew](http://brew.sh/) using the following command:
```bash
$ brew update
$ brew install carthage
```
To integrate CubeGeoJSON into your Xcode project using Carthage, specify it in your `Cartfile`:
```
github "3sidedcube/CubeGeoJSON" ~> 2.0.0
```
Then run
```bash
carthage update --use-xcframeworks
```
to build the framework and drag the built `GeoJSON.xcframework` into your Xcode project.
### Manually
- Add CubeGeoJSON as a git [submodule](http://git-scm.com/docs/git-submodule) by running the following command:
```bash
$ git submodule add https://github.com/3sidedcube/CubeGeoJSON.git
```
- Open the new `CubeGeoJSON` folder, and drag the `GeoJSON.xcodeproj` into the Project Navigator of your application's Xcode project.
> It should appear nested underneath your application's blue project icon. Whether it is above or below all the other Xcode groups does not matter.
- Make sure the `GeoJSON.xcodeproj` is set up with the same deployment target as your root project.
- Add `GeoJSON.framework` as a target dependency to your project.
## Usage
Initialise a new Geometry object using the default `init(dictionary: [String:AnyObject)` method
```swift
import GeoJSON
let geoJSON = [
"type": "MultiPoint",
"coordinates": [
[
-105.01621,
39.57422
],
[
-80.6665134,
35.0539943
]
]
]
let geometry = Geometry(dictionary: geoJSON)
if let annotations : [MKPointAnnotation]? = geometry.shapes?.flatMap({ $0 as? MKPointAnnotation }) {
mapView.addAnnotations(annotations)
}
```
## Contributing
1. Fork it!
2. Create your feature branch: `git checkout -b my-new-feature`
3. Commit your changes: `git commit -am 'Add some feature'`
4. Push to the branch: `git push origin my-new-feature`
5. Submit a pull request :D