BoundingBox bbox = feature.getBounds(); string("bbox", sb).append(":"); sb.append(gjson.toString(bbox)).append(","); string("geometry", sb) .append(":") .append(gjson.toString((Geometry) feature.getDefaultGeometry())); sb.append(","); array(ad.getLocalName(), gjson.toString((Envelope) value), sb); } else if (value instanceof BoundingBox) { array(ad.getLocalName(), gjson.toString((BoundingBox) value), sb); } else if (value instanceof Geometry) { string(ad.getLocalName(), sb) .append(":") .append(gjson.toString((Geometry) value)); } else { entry(ad.getLocalName(), value, sb);
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); } } }
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); }
BoundingBox bbox = feature.getBounds(); string("bbox", sb).append(":"); sb.append(gjson.toString(bbox)).append(","); .append(gjson.toString((Geometry) feature.getDefaultGeometry())); sb.append(","); array(ad.getLocalName(), gjson.toString((Envelope)value), sb); } else if (value instanceof BoundingBox) { array(ad.getLocalName(), gjson.toString((BoundingBox)value), sb); } else if (value instanceof Geometry) { string(ad.getLocalName(), sb).append(":") .append(gjson.toString((Geometry) value)); } else { entry(ad.getLocalName(), value, sb);