GEOSwift 是 Swift 寫的地理引擎,可以輕松處理地理對(duì)象模型(點(diǎn),線串,多邊形等)和相關(guān)的地形操作(交集,重疊等)。
示例代碼
// 1. From Well Known Text (WKT) representation let point = Waypoint(WKT: "POINT(10 45)") let polygon = Geometry.create("POLYGON((35 10, 45 45.5, 15 40, 10 20, 35 10),(20 30, 35 35, 30 20, 20 30))") // 2. From a Well Known Binary (WKB) let WKB: NSData = geometryWKB() let geometry2 = Geometry.create(WKB.bytes, size: WKB.length) // 3. From a GeoJSON file: if let geoJSONURL = NSBundle.mainBundle().URLForResource("italy", withExtension: "geojson"), let geometries = Geometry.fromGeoJSON(geoJSONURL), let italy = geometries[0] as? MultiPolygon { italy }