Skip to content

Commit

Permalink
Merge pull request #100 from ibi-group/nan-altitude
Browse files Browse the repository at this point in the history
Use NaN instead of 0 for unknown point altitude
  • Loading branch information
hannesj committed Mar 15, 2022
2 parents 6c24407 + c5618f7 commit 1f4a393
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,11 @@ public static Geometry convertGeoJsonToJtsGeometry(GeoJsonObject geoJsonGeom)
throws UnsupportedGeometryException {
if (geoJsonGeom instanceof org.geojson.Point) {
org.geojson.Point geoJsonPoint = (org.geojson.Point) geoJsonGeom;
return gf.createPoint(new Coordinate(geoJsonPoint.getCoordinates().getLongitude(), geoJsonPoint
.getCoordinates().getLatitude()));
return gf.createPoint(new Coordinate(
geoJsonPoint.getCoordinates().getLongitude(),
geoJsonPoint.getCoordinates().getLatitude(),
geoJsonPoint.getCoordinates().getAltitude()
));

} else if (geoJsonGeom instanceof org.geojson.Polygon) {
org.geojson.Polygon geoJsonPolygon = (org.geojson.Polygon) geoJsonGeom;
Expand Down Expand Up @@ -226,7 +229,12 @@ private static Coordinate[] convertPath(List<LngLatAlt> path) {
Coordinate[] coords = new Coordinate[path.size()];
int i = 0;
for (LngLatAlt p : path) {
coords[i++] = new Coordinate(p.getLongitude(), p.getLatitude());
// the serialization library does serialize a 0 but not a NaN
coords[i++] = new Coordinate(
p.getLongitude(),
p.getLatitude(),
p.getAltitude()
);
}
return coords;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ public Double(int size, int dimension) {
public Coordinate getCoordinateInternal(int i) {
double x = coords[i * dimension];
double y = coords[i * dimension + 1];
double z = dimension == 2 ? 0.0 : coords[i * dimension + 2];
double z = dimension == 2 ? java.lang.Double.NaN : coords[i * dimension + 2];
return new Coordinate(x, y, z);
}

Expand Down

0 comments on commit 1f4a393

Please sign in to comment.