1

I'm trying to convert com.vividsolutions.jts.geom.Geometry to geography, using the GeoTools package - org.geotools.geometry.jts.JTS. This is my code:

public Geometry getGeography() {
    Geometry geo = null;
    try {
        JTS.toGeographic(this.geo, CRS.decode("EPSG:" + Integer.toString(this.geo.getSRID()), true));
    } catch (TransformException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (NoSuchAuthorityCodeException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (FactoryException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return geo;
}

I'm getting:

org.opengis.referencing.NoSuchAuthorityCodeException: No code "EPSG:0" from authority "EPSG" found for object of type "EngineeringCRS".

Can anybody assist on why the this.geo.getSRID() return 0?

0

1 Answer 1

1

JTS geometries in GeoTools don't make use of the SRID value, so it will always be 0 unless you make a special effort to set it to something.

You should query your FeatureType to find out the SRS for the layer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.