Requires Xcode 10.2.
Drop in the GeoJsonUtils folder to your Xcode project (make sure to enable "Copy items if needed" and "Create groups").
Reading functions have been refactored to use closures to avoid clogging the main thread on large datasets.
GeoJsonUtils.readGJFeatureCollectionFromFileInBundle(file: "nyc_neighborhoods",
withExtension: "geojson") { [unowned self] (result) in
switch result {
case .failure(let error):
print(error.localizedDescription)
case .success(let featureCollection):
self.mapView.loadGJFeatureCollection(featureCollection)
}
}
guard let path = URL(...).path else { return }
GeoJsonUtils.readGJFeatureCollectionFromFileAt(path: path) { [unowned self] (result) in
switch result {
case .failure(let error):
print(error.localizedDescription)
case .success(let featureCollection):
self.mapView.loadGJFeatureCollection(featureCollection)
}
}
let data = Data() {...}
GeoJsonUtils.readGJFeatureCollectionFrom(data) { [unowned self] (result) in
switch result {
case .failure(let error):
print(error.localizedDescription)
case .success(let featureCollection):
self.mapView.loadGJFeatureCollection(featureCollection)
}
}
- At ChangeLog wiki page
GeoJsonUtils is released under the MIT license. See LICENSE for details.