bjornharrtell / jts2geojson

JTS from/to GeoJSON converter for Java
MIT License
138 stars 56 forks source link

Reading/writing 3D coordinates #15

Closed treinar closed 7 years ago

treinar commented 7 years ago

The current versions of GeoJSONReader and GEOJSONWriter don't handle 3D coordinates. I propose the following changes:

GeoJSONWriter:

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

GeoJSONReader:

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

Thanks for a useful library, btw!

bjornharrtell commented 7 years ago

Thanks, seems like a good idea. Can you make it a pull request?

bjornharrtell commented 7 years ago

Fixed by #16.