Comments (2)
All of the main geometry types have a method for this:
A few lines after that, thereโs a variant that has some parameters that enable customizing the behavior. Hope it helps!
from geoswift.
Thanks, Andrew.
Some code, in case it is useful for anyone reading this ..
func getWKtAndType(geom: Geometry) -> (wkt: String, type: String) {
var wkt = ""
var geomType = ""
do {
if case let .point(point) = geom {
wkt = try point.wkt(trim: false, roundingPrecision: 6)
geomType = "POINT"
} else if case let .multiPoint(multiPoint) = geom {
wkt = try multiPoint.wkt(trim: false, roundingPrecision: 6)
geomType = "MULTIPOINT"
} else if case let .lineString(line) = geom {
wkt = try line.wkt(trim: false, roundingPrecision: 6)
geomType = "LINESTRING"
} else if case let .multiLineString(multiLine) = geom {
wkt = try multiLine.wkt(trim: false, roundingPrecision: 6)
geomType = "MULTILINESTRING"
} else if case let .polygon(polygon) = geom {
wkt = try polygon.wkt(trim: false, roundingPrecision: 6)
geomType = "POLYGON"
} else if case let .multiPolygon(multiPolygon) = geom {
wkt = try multiPolygon.wkt(trim: false, roundingPrecision: 6)
geomType = "MULTIPOLYGON"
}
return (wkt, geomType)
} catch let error as NSError {
let str = "\(error.debugDescription)"
MyUtils.Log(TAG, str)
return ("", "")
}
}
from geoswift.
Related Issues (20)
- [SPM] dyld[10829]: Library not loaded: @rpath/geos.framework/geos HOT 1
- Xcode Cloud: Unable to verify project that links GEOSwift using SPM HOT 2
- Inaccurate heatmap output. Maybe My Code is Wrong? HOT 3
- Question: Storing large GeoJSON Files for usage with GEOSwift HOT 2
- Update for Swift Concurrency
- Confused about `distance(to:)` usage or units HOT 2
- No access to LineStringSnapper HOT 6
- Expose Hausdorff Distance functions
- Support Z coordinates HOT 1
- CI is broken HOT 1
- Request: concave hull support HOT 12
- Support for fixing invalid geometries with GeometryFixer/GEOSMakeValidWithParams HOT 3
- Getting at coordinates after a Polygon is buffered HOT 3
- Searching for point within a large geoJSON file HOT 6
- Get struct out of GEOSwift.JSON HOT 4
- PreparedGeometry branch Library Not Loaded HOT 9
- Prepared Geometry Codable or Public Base Access
- Compiling with Xcode 15.0 beta 5 for "My Mac (Mac Catalyst)" fails with "ld: Undefined symbols:..." HOT 3
- Split MultiPoint into multiple Points ? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from geoswift.