Skip to content

Commit

Permalink
Attempt to fix invalid way geometries
Browse files Browse the repository at this point in the history
  • Loading branch information
mojodna committed Jul 3, 2019
1 parent e5d7934 commit 2bb7c82
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Adds `riverbank`, `stream_end`, `dam`, `weir`, `waterfall`, and `pressurised`
to the list of waterway features
- Populates `nds` and `members` for deleted elements from the previous version
- Attempt to fix invalid way geometries by buffering them (this will result in
more way geometries for certain datasets)

### Fixed

Expand Down
10 changes: 10 additions & 0 deletions src/main/scala/vectorpipe/internal/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,16 @@ package object internal {
}
val geometry = geom match {
case Some(g) if g.isValid => g
case Some(g) if !g.isEmpty =>
val buffered = g.buffer(0)

if (buffered.isValid) {
logWarning(s"Invalid way geometry, fixed by buffering: $id@$version ($updated): $g)")
buffered
} else {
logWarning(s"Invalid way geometry: $id@$version ($updated): $g)")
null
}
case _ => null
}
new GenericRowWithSchema(Array(changeset, id, version, updated, geometry), BareElementSchema): Row
Expand Down

0 comments on commit 2bb7c82

Please sign in to comment.