ropensci-archive / wicket

:no_entry: ARCHIVED :no_entry: Utilities to Handle WKT Spatial Data
Other
9 stars 1 forks source link

invalid WKT in example, rendered valid by wicket. #13

Closed edzer closed 7 years ago

edzer commented 7 years ago

?wkt_centroid gives POLYGON((2 1.3,2.4 1.7)) as an example, and

> validate_wkt("POLYGON((2 1.3,2.4 1.7))")
  is_valid comments
1     TRUE     <NA>

I don't believe that this is a valid polygon, though. WKT polygons need to be closed, and span an area.

With sf:

> st_is_valid(st_as_sfc("POLYGON((2 1.3,2.4 1.7))"))
Error in CPL_geos_is_valid(st_geometry(x)) : 
  IllegalArgumentException: Points of LinearRing do not form a closed linestring
Ironholds commented 7 years ago

I'll raise it with the boost::geometry folks, although validation is mostly to check that the contents can be parsed out.

edzer commented 7 years ago

Then maybe you should call it is_parseable rather than is_valid - valid has a different meaning in the context of the simple feature standard.

Ironholds commented 7 years ago

Hence why I've opened an upstream ticket to see why this is parsing as an acceptable polygon.

Ironholds commented 7 years ago

Still waiting on a response; will bump it.

Ironholds commented 7 years ago

Okay, after some back and forth with the geometry devs we have a solution, and even one that produces a nice output message!

validate_wkt("POLYGON((2 1.3,2.4 1.7))") is_valid comments 1 FALSE The WKT object has too few points for its type validate_wkt("POLYGON((2 1.3,2.4 1.7, 3 4.4, 1 2.2))") is_valid comments 1 FALSE The WKT object is closed but does not have matching start/end points

`