歡迎加入QQ討論群258996829

Swift 地理引擎 GEOSwift

發(fā)布時(shí)間:2016-07-13 22:11  回復(fù):0  查看:5834  感興趣:15  贊:0   最后回復(fù):2016-07-13 22:11  

Swift 地理引擎 GEOSwift

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
}

相關(guān)開源代碼

您還未登錄,請(qǐng)先登錄

熱門帖子

最新帖子

?