Closed sckott closed 7 years ago
perhaps one of http://www.boost.org/doc/libs/1_63_0/libs/geometry/doc/html/geometry/reference/algorithms/correct.html or http://www.boost.org/doc/libs/1_47_0/libs/geometry/doc/html/geometry/reference/algorithms/reverse.html can be implemented here? (assuming the error in question here has to do with order of points in a geometry object)
Yeah, that's what it means! Correct seems the right approach.
So would you like a distinct wkt_correct function, or a parameter, or..?
Probably a separate fxn then e.g., if (!wkt_validate(foobar)) wkt_correct(foobar)
That works!*
*assuming an absence of vectorised usage
Give the github version a spin? And if it works - any more things to ask for soon? If not I'll throw in a new CRAN release.
Will test now ... 🕐
finding some problems, just a sec
wkt <- 'POLYGON((30 20, 10 40, 45 40, 30 20), (15 5, 5 10, 10 20, 40 10, 15 5))'
wicket::validate_wkt(wkt)
#> is_valid comments
#> 1 FALSE The WKT object has a different orientation from the default
i didn't know what to do with this error at first
wicket::validate_wkt(wicket::wkt_correct(wkt))
#> is_valid comments
#> 1 FALSE The WKT object has interior rings sitting outside its exterior ring
but i guess it makes sense that you can't have multiple polygons' in a POLYGON
object unless one is inside the other, - so in this case need to make it a MULTIPOLYGON
wkt <- "MULTIPOLYGON(((15 5,40 10,10 20,5 10,15 5)), ((30 20,10 40,45 40,30 20)))"
validate_wkt(wicket::wkt_correct(wkt))
#> is_valid comments
#> 1 TRUE <NA>
can give further informative warning/message about this when it happens
Are those problems with this ticket or unrelated problems? I mean, the 'orientation default' one could be clarified to point to wkt_correct, absolutely, but the rings?
Sort of related, just sort of thinking out loud.
if a "orientation default" error happens, i'm catching that and then pointing the user to wkt_correct fxn - but you could include in this pkg if you think it makes sense
Have tweaked the error message now! I'm not sure how I'd turn the exterior/interior rings thing into a multipolygon specific error message because of course it can happen when the intent is in fact to have just a straight up polygon.
great, thanks
do you know what "The WKT object has a different orientation from the default" errors in
wicket::validate_wkt
refer to? that is, what needs to be fixed in the WKT for it to pass validation? googled it, but still not clear what this error really means - i have a feeling its related to order of points in a polygon, but not suree.g.,