Skip to content

Commit

Permalink
Nml parser should parse float coordinates of nodes (#4045)
Browse files Browse the repository at this point in the history
* round float values for node positions

* pr feedback changelog entry #4045
  • Loading branch information
youri-k authored May 2, 2019
1 parent 8e5d14b commit 0b0e27e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.md).
-

### Changed
-
- The NML parser now rounds floating point values in node coordinates. [#4045](https://github.com/scalableminds/webknossos/pull/4045)

### Fixed
-
Expand Down
12 changes: 8 additions & 4 deletions app/models/annotation/nml/NmlParser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,16 @@ object NmlParser extends LazyLogging with ProtoGeometryImplicits {
}
}

private def parsePoint3D(node: XMLNode) =
private def parsePoint3D(node: XMLNode) = {
val xText = (node \ "@x").text
val yText = (node \ "@y").text
val zText = (node \ "@x").text
for {
x <- (node \ "@x").text.toIntOpt
y <- (node \ "@y").text.toIntOpt
z <- (node \ "@z").text.toIntOpt
x <- xText.toIntOpt.orElse(xText.toFloatOpt.map(math.round))
y <- yText.toIntOpt.orElse(yText.toFloatOpt.map(math.round))
z <- zText.toIntOpt.orElse(zText.toFloatOpt.map(math.round))
} yield Point3D(x, y, z)
}

private def parseRotationForParams(node: XMLNode) =
for {
Expand Down

0 comments on commit 0b0e27e

Please sign in to comment.