/** * Writes a LineString. * * @param geometry * @param writer * @throws IOException */ public void writeLineString( LineString geometry, Writer writer ) throws IOException { writer.append( "LINESTRING " ); if ( flags.contains( WKTFlag.USE_DKT ) ) { appendObjectProps( writer, geometry ); } writer.append( '(' ); writeLineStringWithoutPrefix( geometry, writer ); writer.append( ')' ); }
/** * Writes the multiLineString. * * @param geometry * @param writer * @throws IOException */ public void writeMultiLineString( MultiLineString geometry, Writer writer ) throws IOException { writer.append( "MULTILINESTRING " ); if ( flags.contains( WKTFlag.USE_DKT ) ) { appendObjectProps( writer, geometry ); } writer.append( '(' ); for ( int i = 0; i < geometry.size(); i++ ) { writer.append( '(' ); writeLineStringWithoutPrefix( geometry.get( i ), writer ); if ( i < geometry.size() - 1 ) { writer.append( ',' ); } writer.append( ')' ); } writer.append( ')' ); }
/** * Writes the CURVE without the 'CURVE()'-specific envelope. <br/> * It writes just the CURVE-coordinates. * * @param geometry * @param writer * @throws IOException */ private void writeCurveGeometryWithoutPrefix( Curve geometry, Writer writer ) throws IOException { if ( flags.contains( WKTFlag.USE_SQL_MM ) ) { throw new UnsupportedOperationException( "Handling curves within 'SQL-MM Part 3' is not implemented yet." ); } CurveLinearizer cl = new CurveLinearizer( new GeometryFactory() ); LinearizationCriterion crit = new NumPointsCriterion( linearizedControlPoints ); Curve c = cl.linearize( geometry, crit ); LineString ls = new DefaultLineString( c.getId(), c.getCoordinateSystem(), c.getPrecision(), c.getControlPoints() ); writer.append( '(' ); writeLineStringWithoutPrefix( ls, writer ); writer.append( ')' ); }
/** * Writes a linearRing. * * @param geometry * @param writer * @throws IOException */ public void writeLinearRing( LinearRing geometry, Writer writer ) throws IOException { if ( flags.contains( WKTFlag.USE_DKT ) ) { writer.append( "LINEARRING " ); appendObjectProps( writer, geometry ); LineString ls = new DefaultLineString( geometry.getId(), geometry.getCoordinateSystem(), geometry.getPrecision(), geometry.getControlPoints() ); writer.append( '(' ); writeLineStringWithoutPrefix( ls, writer ); writer.append( ')' ); } else if ( flags.contains( WKTFlag.USE_LINEARRING ) ) { writer.append( "LINEARRING " ); LineString ls = new DefaultLineString( geometry.getId(), geometry.getCoordinateSystem(), geometry.getPrecision(), geometry.getControlPoints() ); writer.append( '(' ); writeLineStringWithoutPrefix( ls, writer ); writer.append( ')' ); } else { LineString ls = new DefaultLineString( geometry.getId(), geometry.getCoordinateSystem(), geometry.getPrecision(), geometry.getControlPoints() ); writeLineString( ls, writer ); } }