Skip to content

Commit 0f6a470

Browse files
authored
Merge pull request #19 from pjleonard37/pjl/playground-buffer-fix
Limits geometry buffering to Points so previews show appropriate zoom
2 parents 3acdf05 + 060c257 commit 0f6a470

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Playgrounds/GEOSwiftMapKit.playground/Contents.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ try! Point(wkt: "POINT(10 45)")
4141
// Create a POINT from its WKT representation.
4242
let point = try! Point(wkt: "POINT(10 45)")
4343

44+
// Create a POLYGON from its WKT representation. Here: the Notre Dame cathedral building footprint
45+
let polygon = try! Polygon(wkt: "POLYGON ((2.349252343714653 48.85347829980472, 2.3489192520770246 48.853050271993254, 2.35034958675422 48.852599033892346, 2.350565116637 48.852593876862244, 2.3507845652447372 48.852712488426135, 2.3508237524963533 48.852874934242834, 2.350682678390797 48.85304253651725, 2.349252343714653 48.85347829980472))")
46+
4447
// If the expected type is unknown, you can use Geometry(wkt:) and the
4548
// returned value will be one of the Geometry enum cases
4649
let geometry1 = try! Geometry(wkt: "POLYGON((35 10, 45 45.5, 15 40, 10 20, 35 10),(20 30, 35 35, 30 20, 20 30))")

Sources/GEOSwiftMapKit/GEOSwift+MapKitQuickLook.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ protocol GEOSwiftQuickLook: CustomPlaygroundDisplayConvertible, GeometryConverti
1111
extension GEOSwiftQuickLook {
1212
public var playgroundDescription: Any {
1313
let defaultReturnValue: Any = (try? geometry.wkt()) ?? self
14-
guard let buffered = try? geometry.buffer(by: 0.1)?.intersection(with: Polygon.world),
14+
var bufferValue: Double = 0
15+
if case .point = geometry {
16+
bufferValue = 0.1
17+
}
18+
guard let buffered = try? geometry.buffer(by: bufferValue)?.intersection(with: Polygon.world),
1519
let region = try? MKCoordinateRegion(containing: buffered) else {
1620
return defaultReturnValue
1721
}

0 commit comments

Comments
 (0)