diff --git a/CHANGELOG.md b/CHANGELOG.md index 500e866669..33e8adab4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 - diff --git a/app/models/annotation/nml/NmlParser.scala b/app/models/annotation/nml/NmlParser.scala index 7961277699..6c9326dcaa 100755 --- a/app/models/annotation/nml/NmlParser.scala +++ b/app/models/annotation/nml/NmlParser.scala @@ -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 {