geometry-api-java
geometry-api-java copied to clipboard
esrijson to geojson Exception
I have an esrijson and when converting it to geojson, I found that the geometry returned by createGeometryByGeoJson is empty. Is there any other way to convert it to geojson? I can successfully convert using https://github.com/Esri/arcgis-to-geojson-utils arcgisToGeoJSON method.
The code example is as follows:
public String EsriJsonToGeoJson(String esri_json){
Geometry geometry = createGeometryByJson(esri_json);
return getGeoJson(geometry);
}
private Geometry createGeometryByGeoJson(String geojson) {
return GeometryEngine.geoJsonToGeometry(geojson, WktExportFlags.wktExportDefaults, Geometry.Type.Unknown).getGeometry();
}
private String getGeoJson(Geometry geometry) {
return GeometryEngine.geometryToGeoJson(geometry);
}
The data example is as follows: GeoJson.json
GeometryEngine accepts JSON strings that only have the geometry (with an optional spatial reference), not the other properties. Your JSON string should start with {"rings": and end with the closing brace }