/** * Reads a Geometry instance from GeoJSON. * * <p>This method calls through to {@link #read(Object)} * * @param input The input stream. * @return The geometry instance. */ public Geometry read(InputStream input) throws IOException { return read((Object) input); }
Geometry g = new GeometryJSON().read(geojsonstring);
/** * Reads a Geometry instance from GeoJSON. * <p> * This method calls through to {@link #read(Object)} * </p> * @param input The input stream. * * @return The geometry instance. */ public Geometry read(InputStream input) throws IOException { return read((Object)input); }
@Override public Object decode(String input) throws Exception { return new GeometryJSON().read(input); } }
@Override public Object decode(InputStream input) throws Exception { return new GeometryJSON().read(input); }
public static Geometry getGeometryFromCoordinatesAndType( FeatureType featureType, String coordinates ) throws IOException { GeometryJSON geometryJSON = new GeometryJSON(); if ( featureType.equals( FeatureType.NONE ) || featureType.equals( FeatureType.SYMBOL ) ) { throw new IllegalArgumentException( "Invalid featureType '" + featureType.value() + "'" ); } return geometryJSON.read( String.format( "{\"type\": \"%s\", \"coordinates\": %s}", featureType.value(), coordinates) ); }
private Filter buildGeometryFilter(SimpleFeatureType schema, Form form) { String geometry = form.getFirstValue("geometry"); if (geometry == null) { return Filter.INCLUDE; } else { try { Geometry geom = new GeometryJSON().read(geometry); final double tolerance = getTolerance(form); return geometryFilter(schema, geom, tolerance); } catch (IOException e) { throw new RestletException("Could not parse the geometry geojson: " + e.getMessage(), Status.CLIENT_ERROR_BAD_REQUEST); } } }
Geometry geometry = new GeometryJSON().read(jsonObject.get("geometry").toString()); geometry.setSRID(4326); feature.setDefaultGeometry(geometry);