Skip to content

Commit

Permalink
Check for invalid geometries in the WKT decoder
Browse files Browse the repository at this point in the history
  • Loading branch information
trasch committed Jun 28, 2023
1 parent e31f169 commit c20d7a9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Sources/GISTools/GeoJson/WKTCoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,10 @@ extension WKTCoder {
throw WKTCoderError.dataCorrupted
}

guard x.isFinite, y.isFinite else {
throw WKTCoderError.invalidGeometry
}

var z: Double?
var m: Double?

Expand All @@ -502,6 +506,9 @@ extension WKTCoder {
m = vector.get(at: 2)
}

if z?.isFinite == false { z = nil }
if m?.isFinite == false { m = nil }

switch projection {
case .epsg4326:
coordinates.append(Coordinate3D(latitude: y, longitude: x, altitude: z, m: m))
Expand Down

0 comments on commit c20d7a9

Please sign in to comment.