Skip to content

Commit

Permalink
Allow leading whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebarron committed Oct 7, 2024
1 parent 33c060f commit bcd1250
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/infer_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,20 @@ pub fn infer_type(input: &str) -> Result<(GeometryType, Option<Dimension>), Stri
return Err("Invalid WKT; no '(' character and not EMPTY".to_string());
}

if input.starts_with(POINT) {
// We use contains instead of starts_with to allow leading whitespace
if input.contains(POINT) {
Ok((GeometryType::Point, None))
} else if input.starts_with(LINESTRING) {
} else if input.contains(LINESTRING) {
Ok((GeometryType::LineString, None))
} else if input.starts_with(POLYGON) {
} else if input.contains(POLYGON) {
Ok((GeometryType::Polygon, None))
} else if input.starts_with(MULTIPOINT) {
} else if input.contains(MULTIPOINT) {
Ok((GeometryType::MultiPoint, None))
} else if input.starts_with(MULTILINESTRING) {
} else if input.contains(MULTILINESTRING) {
Ok((GeometryType::MultiLineString, None))
} else if input.starts_with(MULTIPOLYGON) {
} else if input.contains(MULTIPOLYGON) {
Ok((GeometryType::MultiPolygon, None))
} else if input.starts_with(GEOMETRYCOLLECTION) {
} else if input.contains(GEOMETRYCOLLECTION) {
Ok((GeometryType::GeometryCollection, None))
} else {
return Err(format!("Unsupported WKT prefix {}", input));
Expand Down

0 comments on commit bcd1250

Please sign in to comment.