Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabling reading/writing of 3D coordinates #16

Merged
merged 1 commit into from
Oct 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/main/java/org/wololo/jts2geojson/GeoJSONReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@ Geometry convert(GeometryCollection gc) {
}

Coordinate convert(double[] c) {
return new Coordinate(c[0], c[1]);
if(c.length == 2){
return new Coordinate(c[0], c[1]);
}
else{
return new Coordinate(c[0], c[1], c[2]);
}
}

Coordinate[] convert(double[][] ca) {
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/org/wololo/jts2geojson/GeoJSONWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,12 @@ org.wololo.geojson.GeometryCollection convert(GeometryCollection gc) {
}

double[] convert(Coordinate coordinate) {
return new double[] { coordinate.x, coordinate.y };
if(Double.isNaN( coordinate.z )) {
return new double[] { coordinate.x, coordinate.y };
}
else {
return new double[] { coordinate.x, coordinate.y, coordinate.z };
}
}

double[][] convert(Coordinate[] coordinates) {
Expand Down