欢迎加入QQ讨论群258996829

Swift 地理引擎 GEOSwift

发布时间:2016-07-13 22:11  回复:0  查看:5896  感兴趣:15  赞:0   最后回复:2016-07-13 22:11  

Swift 地理引擎 GEOSwift

GEOSwift 是 Swift 写的地理引擎,可以轻松处理地理对象模型(点,线串,多边形等)和相关的地形操作(交集,重叠等)。

示例代码

// 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
}

相关开源代码

您还未登录,请先登录

热门帖子

最新帖子