Skip to content

Commit

Permalink
try to use lwgeom to make valid; #88 (comment)
Browse files Browse the repository at this point in the history
  • Loading branch information
timelyportfolio committed Jan 20, 2019
1 parent 3fa7191 commit d0fa02e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ Imports:
sf (>= 0.5-2),
shiny
Suggests:
crayon
crayon,
lwgeom
Enhances:
geojsonio
Encoding: UTF-8
Expand Down
15 changes: 15 additions & 0 deletions R/edit.R
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,21 @@ editFeatures.sf = function(

merged <- dplyr::select_(merged, "-edit_id")

# check to see if the result is valid with lwgeom if available and make valid
# if error then return the invalid merged with a warning
if(requireNamespace("lwgeom")) {
tryCatch(
{
merged <- st_make_valid(merged)
},
error = function(e) {
warn("unable to make valid with lwgeom; please inspect closely", call. = FALSE)
}
)
} else {
message("lwgeom package not available so could not test validity")
}

# return merged features
if(record==TRUE) {
attr(merged, "recorder") <- attr(crud, "recorder", exact=TRUE)
Expand Down

0 comments on commit d0fa02e

Please sign in to comment.