Closed Ironholds closed 7 years ago
Sounds good. 👍
Would it be useful to also provide a column of examples? so you get:
wicket:::validate_wkt("POINT (12,14)")
is_valid comments example
1 FALSE Expected ')' at ',' in 'point (12,14)' POINT(12 14)
Yeah, sounds good
okay, validate_wkt
is ready to test (I was slowed down by building GeometryCollection support in which is..non-trivial, as a parsing problem)
cool, all seems good to me.
validate_wkt(c(
"polygon ((30 10, 40 40, 20 40, 10 20, 30 10))",
"POLYGON ((30 10, 40 40, 20 40, 10 20))",
"POINT(-71.064544 42.28787)",
"POINT(-71.064544, 42.28787)",
"POINT(-71.064544 42.28787))",
"FOO(-71.064544 42.28787))"
))
#> is_valid comments
#> 1 TRUE <NA>
#> 2 TRUE <NA>
#> 3 TRUE <NA>
#> 4 FALSE Expected ')' at ',' in 'point(-71.064544, 42.28787)'
#> 5 FALSE Too much tokens at ')' in 'point(-71.064544 42.28787))'
#> 6 FALSE Object could not be recognised as a supported WKT type
There should be a function,
lint_wkt
, that:is_valid
, of TRUE/FALSE values identifying if the string is valid, andcomments
, a character vector containing either an empty string or (in the case of invalid strings) a pointer to what's wrong with them.