/** * Returns the Well-known Text representation of this <code>Geometry</code>. * For a definition of the Well-known Text format, see the OpenGIS Simple * Features Specification. * *@return the Well-known Text representation of this <code>Geometry</code> */ public String toText() { WKTWriter writer = new WKTWriter(); return writer.write(this); }
/** * Test method for * {@link com.impetus.kundera.property.accessor.PointAccessor#toString(java.lang.Object)} * . */ @Test public void testToStringObject() { Point point = new Point(4.5, 6.3); String pointStr = pa.toString(point); WKTWriter writer = new WKTWriter(); String wktStr = writer.write(point); Assert.assertEquals(wktStr, pointStr); }
/** * Test method for * {@link com.impetus.kundera.property.accessor.PointAccessor#fromString(java.lang.Class, java.lang.String)} * . */ @Test public void testFromString() { Point point = new Point(4.5, 6.3); WKTWriter writer = new WKTWriter(); String wktStr = writer.write(point); Point point2 = pa.fromString(com.vividsolutions.jts.geom.Point.class, wktStr); Assert.assertNotNull(point2); Assert.assertEquals(point.getX(), point2.getX()); Assert.assertEquals(point.getY(), point2.getY()); }
public VocabWriterGeosparql() { this.wktWriter = new WKTWriter(); this.property = GEOSPARQL.asWKT;//.getURI(); this.datatype = GEOSPARQL.Geometry;//.getURI(); }
@Override public void encodeGeometryValue(Geometry value, int srid, StringBuffer sql) throws IOException { sql.append("GeomFromText('") .append( new WKTWriter().write( value ) ).append( "',") .append(srid).append(")"); }
/** * * @param geom JTS geometry representation * * @return The WKT representation of the geometry * * @throws ParseException error while creating the WKT */ public static String toWKT(Geometry geom) throws ParseException { WKTWriter wktWriter = new WKTWriter(); //TODO: consider use of GeometryFactory return wktWriter.write(geom); }
@Override public String format(Object value) { Point2D point = (Point2D) value; return new WKTWriter().write(geometryFactory.createPoint(new Coordinate(point.getX(), point.getY()))); } }
@Override public String toString() { String ret = new WKTWriter().write(value); if (ret.endsWith(" EMPTY")) { // for DBs that do not support any other empty WKT ret = "GEOMETRYCOLLECTION EMPTY"; } return ret; }
@Override public String toString() { String ret = new WKTWriter().write(value); if (ret.endsWith(" EMPTY")) { // for DBs that do not support any other empty WKT ret = "GEOMETRYCOLLECTION EMPTY"; } return ret; }
/** * Returns the Well-known Text representation of this <code>Geometry</code>. * For a definition of the Well-known Text format, see the OpenGIS Simple * Features Specification. * *@return the Well-known Text representation of this <code>Geometry</code> */ public String toText() { WKTWriter writer = new WKTWriter(); return writer.write(this); }
@Override public String format(Geometry value) { if (value == null) { return ""; } return new WKTWriter().write(value); }
@Override public String format(Object value) { Point2D point = (Point2D) value; return new WKTWriter().write(geometryFactory.createPoint(new Coordinate(point.getX(), point.getY()))); } }
/** * Convert a Geometry value into a Well Known Text value. * @param geometry Geometry instance * @return The String representation */ public static String asWKT(Geometry geometry) { if(geometry==null) { return null; } WKTWriter wktWriter = new WKTWriter(); return wktWriter.write(geometry); } }
@Override public InputStream generateStream(IData data, String mimeType, String schema) throws IOException { if(data instanceof JTSGeometryBinding){ Geometry g = ((JTSGeometryBinding)data).getPayload(); String wktString = new WKTWriter().write(g); InputStream is = new ByteArrayInputStream(wktString.getBytes()); return is; } return null; }
/** * Get the value in Well-Known-Text format. * * @return the well-known-text */ public String getWKT() { return new WKTWriter(3).write(getGeometryNoCopy()); }
@Override public Item item(final QueryContext qc, final InputInfo ii) throws QueryException { return Str.get(new WKTWriter().write(checkGeo(0, qc))); } }
@Override public String convert(final Polygon polygon) { final Geometry geometry = new JtsPolygonConverter().convert(polygon); return new WKTWriter().write(geometry); } }
@Override public String convert(final Location location) { final Geometry geometry = new JtsPointConverter().convert(location); final String wkt = new WKTWriter().write(geometry); return wkt; } }
@Override public String convert(final MultiPolyLine multiPolyLine) { final MultiLineString geometry = new JtsMultiPolyLineConverter().convert(multiPolyLine); return new WKTWriter().write(geometry); } }
private void testParsing(Geometry expectedGeometry) throws ConversionException { final WKTWriter wktWriter = new WKTWriter(); final String geometryWkt = wktWriter.write(expectedGeometry); final Geometry geometry = converter.parse(geometryWkt); assertTrue(expectedGeometry.equalsExact(geometry)); assertEquals(null, converter.parse("")); } }