@Override public Points getControlPoints() { List<Points> pointsList = new ArrayList<Points>( memberCurves.size() ); for ( Curve curve : memberCurves ) { pointsList.add( curve.getControlPoints() ); } return new PointsPoints( pointsList ); } }
@Override public List<CurveSegment> getCurveSegments() { return baseCurve.getCurveSegments(); }
/** * Simplifies the given {@link Curve}. * * @param geometry * the geometry to be simplified, must not be <code>null</code> * @return the simplified geometry */ public LineString simplify( Curve geometry ) { LineString simplified = null; switch ( geometry.getCurveType() ) { case LineString: { simplified = (LineString) geometry; break; } case CompositeCurve: case Curve: case OrientableCurve: case Ring: { Curve linearized = linearizer.linearize( geometry, crit ); simplified = linearized.getAsLineString(); break; } } return simplified; }
void render( PointStyling styling, Curve curve ) { if ( curve.getCurveSegments().size() != 1 || !( curve.getCurveSegments().get( 0 ) instanceof LineStringSegment ) ) { // TODO handle non-linear and multiple curve segments throw new IllegalArgumentException(); } LineStringSegment segment = ( (LineStringSegment) curve.getCurveSegments().get( 0 ) ); // coordinate representation is still subject to change... for ( Point point : segment.getControlPoints() ) { point.setCoordinateSystem( curve.getCoordinateSystem() ); renderer.render( styling, point ); } }
public static Curve invertOrientation( Curve curve ) { Curve fixedCurve = null; switch ( curve.getCurveType() ) { case CompositeCurve: { CompositeCurve compositeCurve = (CompositeCurve) curve; fixedCurve = new DefaultCompositeCurve( curve.getId(), curve.getCoordinateSystem(), curve.getPrecision(), fixedMemberCurves ); break; List<CurveSegment> fixedSegments = new ArrayList<CurveSegment>( curve.getCurveSegments().size() ); for ( CurveSegment segment : curve.getCurveSegments() ) { fixedSegments.add( invertOrientation( segment ) ); fixedCurve = new DefaultCurve( curve.getId(), curve.getCoordinateSystem(), curve.getPrecision(), fixedSegments ); break; fixedCurve = new DefaultLineString( curve.getId(), curve.getCoordinateSystem(), curve.getPrecision(), invertOrientation( lineString.getControlPoints() ) ); break; fixedCurve = new DefaultOrientableCurve( curve.getId(), curve.getCoordinateSystem(), invertOrientation( orientableCurve.getBaseCurve() ), orientableCurve.isReversed() ); fixedCurve.setProperties( curve.getProperties() ); return fixedCurve;
CurveType type = curve.getCurveType(); Curve result = null; switch ( type ) { case OrientableCurve: case Curve: { CurveSegment[] curveSegments = new CurveSegment[curve.getCurveSegments().size()]; int i = 0; for ( CurveSegment segment : curve.getCurveSegments() ) { curveSegments[i++] = transform( segment, trans ); result = geomFactory.createCurve( curve.getId(), getTargetCRS(), curveSegments ); if ( type == CurveType.OrientableCurve ) { result = geomFactory.createOrientableCurve( curve.getId(), result.getCoordinateSystem(), result, ( (OrientableCurve) curve ).isReversed() );
/** * 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( ')' ); }
throws XMLStreamException, UnknownCRSException, TransformationException { switch ( curve.getCurveType() ) { case CompositeCurve: exportCompositeCurve( (CompositeCurve) curve ); for ( CurveSegment curveSeg : curve.getCurveSegments() ) { exportCurveSegment( curveSeg ); if ( baseCurve.getId() != null && referenceExportStrategy.isObjectExported( baseCurve.getId() ) ) { writer.writeEmptyElement( gmlNs, "baseCurve" ); writer.writeAttribute( XLNNS, "href", "#" + baseCurve.getId() ); writer.writeEndElement(); } else {
Double fromCurve( Curve curve, boolean close ) { Double line = new Double(); // TODO use error criterion ICRS crs = curve.getCoordinateSystem(); curve = linearizer.linearize( curve, new NumPointsCriterion( 100 ) ); curve.setCoordinateSystem( crs ); Points points = curve.getControlPoints(); Iterator<Point> iter = points.iterator(); Point p = iter.next(); double x = p.get0(), y = p.get1(); line.moveTo( x, y ); while ( iter.hasNext() ) { p = iter.next(); if ( iter.hasNext() ) { line.lineTo( p.get0(), p.get1() ); } else { if ( close && isZero( x - p.get0() ) && isZero( y - p.get1() ) ) { line.closePath(); } else { line.lineTo( p.get0(), p.get1() ); } } } line.transform( worldToScreen ); return line; }
LOG.debug( "Curve geometry. Testing for duplication of successive control points." ); int segmentIdx = 0; for ( CurveSegment segment : curve.getCurveSegments() ) { if ( segment.getSegmentType() == CurveSegmentType.LINE_STRING_SEGMENT ) { LineStringSegment lineStringSegment = (LineStringSegment) segment; Point lastSegmentEndPoint = null; segmentIdx = 0; for ( CurveSegment segment : curve.getCurveSegments() ) { Point startPoint = segment.getStartPoint(); if ( lastSegmentEndPoint != null ) { if ( selfIntersection ) { LOG.debug( "Detected self-intersection." ); Point location = getPoint( isSimpleOp.getNonSimpleLocation(), curve.getCoordinateSystem() ); if ( !fireEvent( new CurveSelfIntersection( curve, location, affectedGeometryParticles2 ) ) ) { isValid = false; if ( !curve.isClosed() ) { LOG.debug( "Not closed." ); if ( !fireEvent( new RingNotClosed( (Ring) curve, affectedGeometryParticles2 ) ) ) {
private void traverseCurve( Curve c ) { CurveType ct = c.getCurveType(); switch ( ct ) { case CompositeCurve: for ( Curve member : ( (CompositeCurve) c ) ) { traverse( member ); } break; case Curve: case Ring: for ( CurveSegment segment : c.getCurveSegments() ) { traverseSegment( segment ); } break; case LineString: traversePoints( ( (LineString) c ).getControlPoints() ); break; case OrientableCurve: traverse( ( (OrientableCurve) c ).getBaseCurve() ); break; } }
Curve c = (Curve) geom; LinkedList<Point> ps = new LinkedList<Point>(); for ( Point p : c.getAsLineString().getControlPoints() ) { ps.add( (Point) move( p, offx, offy ) ); return fac.createLineString( geom.getId(), c.getCoordinateSystem(), new PointsList( ps ) );
@Override public LineString getAsLineString() { return baseCurve.getAsLineString(); }
@Override public Measure getLength( Unit requestedUnit ) { return baseCurve.getLength( requestedUnit ); }
@Override public CurveType getCurveType() { return getReferencedObject().getCurveType(); }
/** * @param multiCurve * @throws XMLStreamException * @throws UnknownCRSException * @throws TransformationException */ public void exportMultiLineString( MultiCurve<Curve> multiCurve ) throws XMLStreamException, TransformationException, UnknownCRSException { startGeometry( "MultiLineString", multiCurve ); for ( Curve curve : multiCurve ) { if ( referenceExportStrategy.isObjectExported( curve.getId() ) ) { writer.writeEmptyElement( "gml", "lineStringMember", GML21NS ); writer.writeAttribute( "xlink", XLNNS, "href", "#" + curve.getId() ); } else { writer.writeStartElement( "gml", "lineStringMember", GML21NS ); exportLineString( curve ); writer.writeEndElement(); } } writer.writeEndElement(); // </gml:MultiLineString> }
void render( LineStyling styling, Surface surface ) { for ( SurfacePatch patch : surface.getPatches() ) { if ( patch instanceof PolygonPatch ) { PolygonPatch polygonPatch = (PolygonPatch) patch; for ( Curve curve : polygonPatch.getBoundaryRings() ) { if ( curve.getCoordinateSystem() == null ) { curve.setCoordinateSystem( surface.getCoordinateSystem() ); } renderer.render( styling, curve ); } } else { throw new IllegalArgumentException( "Cannot render non-planar surfaces." ); } } }
curve.setType( type ); curve.setProperties( props );
@Override public boolean contains( Geometry geometry ) { return baseCurve.contains( geometry ); }
private static Curve fixCurve( Curve curve, Point lastPoint ) { Curve fixedCurve = null; switch ( curve.getCurveType() ) { case Curve: { List<CurveSegment> fixedSegments = new ArrayList<CurveSegment>( curve.getCurveSegments() ); CurveSegment lastSegment = fixedSegments.get( fixedSegments.size() - 1 ); if ( lastSegment.getSegmentType() == CurveSegmentType.LINE_STRING_SEGMENT ) { fixedCurve = new DefaultCurve( curve.getId(), curve.getCoordinateSystem(), curve.getPrecision(), fixedSegments ); break; LineString lineString = (LineString) curve; Points fixedPoints = getFixedPoints( lineString.getControlPoints(), lastPoint ); fixedCurve = new DefaultLineString( curve.getId(), curve.getCoordinateSystem(), curve.getPrecision(), fixedPoints ); break; fixedMemberCurves.set( fixedMemberCurves.size() - 1, fixCurve( fixedMemberCurves.get( fixedMemberCurves.size() - 1 ), lastPoint ) ); fixedCurve = new DefaultCompositeCurve( curve.getId(), curve.getCoordinateSystem(), curve.getPrecision(), fixedMemberCurves ); break; OrientableCurve orientableCurve = (OrientableCurve) curve; Curve fixedBaseCurve = fixCurve( orientableCurve.getBaseCurve(), lastPoint ); fixedCurve = new DefaultOrientableCurve( curve.getId(), curve.getCoordinateSystem(), fixedBaseCurve, orientableCurve.isReversed() ); break;