GeometryJSON geometryJSON = new GeometryJSON();
public FeatureJSON() { this(new GeometryJSON()); }
public FeatureJSON() { this(new GeometryJSON()); }
@Override public Object decode(String input) throws Exception { return new GeometryJSON().read(input); } }
@Override public void encode(Object value, OutputStream os) throws IOException { GeometryJSON json = new GeometryJSON(); json.write((Geometry) value, os); }
@Override public Object decode(InputStream input) throws Exception { return new GeometryJSON().read(input); }
/** * Get GeometryJSON point. * * @param longitude the longitude. * @param latitude the latitude. * @return the GeoJSON representation of the given point. */ public static Point getGeoJsonPoint( double longitude, double latitude ) throws IOException { Point point = null; GeometryJSON gtjson = new GeometryJSON(); point = gtjson.readPoint( new StringReader( "{\"type\":\"Point\", \"coordinates\":[" + longitude + "," + latitude + "]}" ) ); return point; }
GeometryJSON geometryJSON = new GeometryJSON(); String json = geometryJSON.toString(geometry)
/** * Given a JTS Geometry in fixed-point latitude and longitude, log it as floating-point GeoJSON. */ public static void logFixedPointGeometry (String label, Geometry fixedPointGeometry) { if (fixedPointGeometry == null){ LOG.info("{} is null.", label); } else if (fixedPointGeometry.isEmpty()) { LOG.info("{} is empty.", label); } else { String geoJson = new GeometryJSON().toString(fixedDegreeGeometryToFloating(fixedPointGeometry)); if (geoJson == null) { LOG.info("Could not convert non-null geometry to GeoJSON"); } else { LOG.info("{} {}", label, geoJson); } } }
private String getGeoJSONGeometryForSubject(Subject subject) { // For millimeter (mm) precision represent lat/lon with 8 decimal places in decimal degrees format. return (new GeometryJSON(8)).toString(subject.getShape()); } }
/** * Given a JTS Geometry in fixed-point latitude and longitude, log it as floating-point GeoJSON. */ public static void logFixedPointGeometry (String label, Geometry fixedPointGeometry) { if (fixedPointGeometry == null){ LOG.info("{} is null.", label); } else if (fixedPointGeometry.isEmpty()) { LOG.info("{} is empty.", label); } else { String geoJson = new GeometryJSON().toString(fixedDegreeGeometryToFloating(fixedPointGeometry)); if (geoJson == null) { LOG.info("Could not convert non-null geometry to GeoJSON"); } else { LOG.info("{} {}", label, geoJson); } } }
new GeometryJSON().write(g, tempFile);
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) ); }
GeometryCollection g = new GeometryJSON().readGeometryCollection(geojsonstring); Geometry g = new GeometryJSON().read(geojsonstring);
protected void visitLiteralGeometry(Literal expression) throws IOException { // evaluate the literal and store it for later currentGeometry = (Geometry) evaluateLiteral(expression, Geometry.class); if ( currentGeometry instanceof LinearRing ) { // convert LinearRing to LineString final GeometryFactory factory = currentGeometry.getFactory(); final LinearRing linearRing = (LinearRing) currentGeometry; final CoordinateSequence coordinates; coordinates = linearRing.getCoordinateSequence(); currentGeometry = factory.createLineString(coordinates); } final String geoJson = new GeometryJSON().toString(currentGeometry); currentShapeBuilder = mapReader.readValue(geoJson); }
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); } } }
GeometryJSON gtjson = new GeometryJSON();
Geometry geometry = new GeometryJSON().read(jsonObject.get("geometry").toString()); geometry.setSRID(4326); feature.setDefaultGeometry(geometry);