public ST_AsGeoJSON() { addProperty(PROP_REMARKS, "Return the geometry as a Geometry Javascript Object Notation (GeoJSON 1.0) element.\n" + "2D and 3D Geometries are both supported.\n" + "GeoJSON only supports SFS 1.1 geometry types (POINT, LINESTRING, POLYGON and COLLECTION)."); }
/** * Convert a jts array of coordinates to a GeoJSON coordinates * representation. * * Syntax: * * [[X1,Y1],[X2,Y2]] * * @param coords * @param sb */ public static void toGeojsonCoordinates(Coordinate[] coords, StringBuilder sb) { sb.append("["); for (int i = 0; i < coords.length; i++) { toGeojsonCoordinate(coords[i], sb); if (i < coords.length - 1) { sb.append(","); } } sb.append("]"); }
/** * Coordinates of a MultiPoint are an array of positions. * * Syntax: * * { "type": "MultiPoint", "coordinates": [ [100.0, 0.0], [101.0, 1.0] ] } * * @param multiPoint * @param sb */ public static void toGeojsonMultiPoint(MultiPoint multiPoint, StringBuilder sb) { sb.append("{\"type\":\"MultiPoint\",\"coordinates\":"); toGeojsonCoordinates(multiPoint.getCoordinates(), sb); sb.append("}"); }
/** * Transform a JTS geometry to a GeoJSON representation. * * @param geom * @param sb */ public static void toGeojsonGeometry(Geometry geom, StringBuilder sb) { if (geom instanceof Point) { toGeojsonPoint((Point) geom, sb); } else if (geom instanceof LineString) { toGeojsonLineString((LineString) geom, sb); } else if (geom instanceof Polygon) { toGeojsonPolygon((Polygon) geom, sb); } else if (geom instanceof MultiPoint) { toGeojsonMultiPoint((MultiPoint) geom, sb); } else if (geom instanceof MultiLineString) { toGeojsonMultiLineString((MultiLineString) geom, sb); } else if (geom instanceof MultiPolygon) { toGeojsonMultiPolygon((MultiPolygon) geom, sb); } else { toGeojsonGeometryCollection((GeometryCollection) geom, sb); } }
Geometry geom = geometryCollection.getGeometryN(i); if (geom instanceof Point) { toGeojsonPoint((Point) geom, sb); } else if (geom instanceof LineString) { toGeojsonLineString((LineString) geom, sb); } else if (geom instanceof Polygon) { toGeojsonPolygon((Polygon) geom, sb);
/** * Convert the geometry to a GeoJSON representation. * * @param geom * @return */ public static String toGeojson(Geometry geom) { StringBuilder sb = new StringBuilder(); toGeojsonGeometry(geom, sb); return sb.toString(); }
new ST_AddPoint(), new ST_AddZ(), new ST_AsGeoJSON(), new ST_AsKml(), new ST_BoundingCircle(),
/** * Transform a JTS geometry to a GeoJSON representation. * * @param geom * @param sb */ public static void toGeojsonGeometry(Geometry geom, StringBuilder sb) { if (geom instanceof Point) { toGeojsonPoint((Point) geom, sb); } else if (geom instanceof LineString) { toGeojsonLineString((LineString) geom, sb); } else if (geom instanceof Polygon) { toGeojsonPolygon((Polygon) geom, sb); } else if (geom instanceof MultiPoint) { toGeojsonMultiPoint((MultiPoint) geom, sb); } else if (geom instanceof MultiLineString) { toGeojsonMultiLineString((MultiLineString) geom, sb); } else if (geom instanceof MultiPolygon) { toGeojsonMultiPolygon((MultiPolygon) geom, sb); } else { toGeojsonGeometryCollection((GeometryCollection) geom, sb); } }
Geometry geom = geometryCollection.getGeometryN(i); if (geom instanceof Point) { toGeojsonPoint((Point) geom, sb); } else if (geom instanceof LineString) { toGeojsonLineString((LineString) geom, sb); } else if (geom instanceof Polygon) { toGeojsonPolygon((Polygon) geom, sb);
/** * Convert the geometry to a GeoJSON representation. * * @param geom * @return */ public static String toGeojson(Geometry geom) { StringBuilder sb = new StringBuilder(); toGeojsonGeometry(geom, sb); return sb.toString(); }
new ST_AddPoint(), new ST_AddZ(), new ST_AsGeoJSON(), new ST_AsKml(), new ST_BoundingCircle(),
/** * Transform a JTS geometry to a GeoJSON representation. * * @param geom * @param sb */ public static void toGeojsonGeometry(Geometry geom, StringBuilder sb) { if (geom instanceof Point) { toGeojsonPoint((Point) geom, sb); } else if (geom instanceof LineString) { toGeojsonLineString((LineString) geom, sb); } else if (geom instanceof Polygon) { toGeojsonPolygon((Polygon) geom, sb); } else if (geom instanceof MultiPoint) { toGeojsonMultiPoint((MultiPoint) geom, sb); } else if (geom instanceof MultiLineString) { toGeojsonMultiLineString((MultiLineString) geom, sb); } else if (geom instanceof MultiPolygon) { toGeojsonMultiPolygon((MultiPolygon) geom, sb); } else { toGeojsonGeometryCollection((GeometryCollection) geom, sb); } }
Geometry geom = geometryCollection.getGeometryN(i); if (geom instanceof Point) { toGeojsonPoint((Point) geom, sb); } else if (geom instanceof LineString) { toGeojsonLineString((LineString) geom, sb); } else if (geom instanceof Polygon) { toGeojsonPolygon((Polygon) geom, sb);
/** * Coordinates of LineString are an array of positions. * * Syntax: * * { "type": "LineString", "coordinates": [ [100.0, 0.0], [101.0, 1.0] ] } * * @param lineString * @param sb */ public static void toGeojsonLineString(LineString lineString, StringBuilder sb) { sb.append("{\"type\":\"LineString\",\"coordinates\":"); toGeojsonCoordinates(lineString.getCoordinates(), sb); sb.append("}"); }
public ST_AsGeoJSON() { addProperty(PROP_REMARKS, "Return the geometry as a Geometry Javascript Object Notation (GeoJSON 1.0) element.\n" + "2D and 3D Geometries are both supported.\n" + "GeoJSON only supports SFS 1.1 geometry types (POINT, LINESTRING, POLYGON and COLLECTION)."); }
/** * Convert the geometry to a GeoJSON representation. * * @param geom * @return */ public static String toGeojson(Geometry geom) { StringBuilder sb = new StringBuilder(); toGeojsonGeometry(geom, sb); return sb.toString(); }
/** * Convert a jts array of coordinates to a GeoJSON coordinates * representation. * * Syntax: * * [[X1,Y1],[X2,Y2]] * * @param coords * @param sb */ public static void toGeojsonCoordinates(Coordinate[] coords, StringBuilder sb) { sb.append("["); for (int i = 0; i < coords.length; i++) { toGeojsonCoordinate(coords[i], sb); if (i < coords.length - 1) { sb.append(","); } } sb.append("]"); }
new ST_AddPoint(), new ST_AddZ(), new ST_AsGeoJSON(), new ST_AsKml(), new ST_BoundingCircle(),
/** * Coordinates of a MultiPoint are an array of positions. * * Syntax: * * { "type": "MultiPoint", "coordinates": [ [100.0, 0.0], [101.0, 1.0] ] } * * @param multiPoint * @param sb */ public static void toGeojsonMultiPoint(MultiPoint multiPoint, StringBuilder sb) { sb.append("{\"type\":\"MultiPoint\",\"coordinates\":"); toGeojsonCoordinates(multiPoint.getCoordinates(), sb); sb.append("}"); }
public ST_AsGeoJSON() { addProperty(PROP_REMARKS, "Return the geometry as a Geometry Javascript Object Notation (GeoJSON 1.0) element.\n" + "2D and 3D Geometries are both supported.\n" + "GeoJSON only supports SFS 1.1 geometry types (POINT, LINESTRING, POLYGON and COLLECTION)."); }