/** * Returns a linearized version (i.e. a {@link PolygonPatch} that only uses {@link LinearRing}s as boundaries) of * the given {@link PolygonPatch}. * * @param patch * @param crit * determines the interpolation quality / number of interpolation points * @return {@link PolygonPatch} that only uses {@link LinearRing}s as boundaries */ public PolygonPatch linearize( PolygonPatch patch, LinearizationCriterion crit ) { Ring exteriorRing = patch.getExteriorRing(); Ring linearizedExteriorRing = null; if ( exteriorRing != null ) { linearizedExteriorRing = (Ring) curveLinearizer.linearize( exteriorRing, crit ); } List<Ring> interiorRings = patch.getInteriorRings(); List<Ring> linearizedInteriorRings = new ArrayList<Ring>( interiorRings.size() ); for ( Ring interiorRing : interiorRings ) { linearizedInteriorRings.add( (Ring) curveLinearizer.linearize( interiorRing, crit ) ); } return geomFac.createPolygonPatch( linearizedExteriorRing, linearizedInteriorRings ); } }
private void writePolygonPatch( String id, ICRS crs, PrecisionModel pm, PolygonPatch polyPatch, Writer writer ) throws IOException { PolygonPatchType type = polyPatch.getPolygonPatchType(); Polygon poly = null; switch ( type ) { case POLYGON_PATCH: case RECTANGLE: case TRIANGLE: poly = new DefaultPolygon( id, crs, pm, polyPatch.getExteriorRing(), polyPatch.getInteriorRings() ); break; } writePolygonWithoutPrefix( poly, writer ); }
void render( TextStyling styling, Font font, String text, Surface surface ) { for ( SurfacePatch patch : surface.getPatches() ) { if ( patch instanceof PolygonPatch ) { PolygonPatch polygonPatch = (PolygonPatch) patch; for ( Curve curve : polygonPatch.getBoundaryRings() ) { render( styling, font, text, curve ); } } else { throw new IllegalArgumentException( "Cannot render non-planar surfaces." ); } } }
@Override public Points getExteriorRingCoordinates() { if ( patches.size() == 1 ) { if ( patches.get( 0 ) instanceof PolygonPatch ) { PolygonPatch patch = (PolygonPatch) patches.get( 0 ); return patch.getExteriorRing().getControlPoints(); } throw new IllegalArgumentException( Messages.getMessage( "SURFACE_IS_NON_PLANAR" ) ); } throw new IllegalArgumentException( Messages.getMessage( "SURFACE_MORE_THAN_ONE_PATCH" ) ); }
@Override public List<Points> getInteriorRingsCoordinates() { List<Points> controlPoints = new ArrayList<Points>(); if ( patches.size() == 1 ) { if ( patches.get( 0 ) instanceof PolygonPatch ) { PolygonPatch patch = (PolygonPatch) patches.get( 0 ); List<Ring> interiorRings = patch.getInteriorRings(); for ( Ring ring : interiorRings ) { controlPoints.add( ring.getControlPoints() ); } } else { throw new IllegalArgumentException( Messages.getMessage( "SURFACE_IS_NON_PLANAR" ) ); } } else { throw new IllegalArgumentException( Messages.getMessage( "SURFACE_MORE_THAN_ONE_PATCH" ) ); } return controlPoints; }
@Override public int getCoordinateDimension() { return patches.get( 0 ).getCoordinateDimension(); }
Ring exterior = patch.getExteriorRing(); float[] extC = extractGeometries( exterior, min, max ); if ( extC == null ) { LOG.warn( "The exterior ring of a polygon patch did not contain any coordinates, discarding this patch." ); } else { List<Ring> interior = patch.getInteriorRings(); List<float[]> interiors = new ArrayList<float[]>( interior.size() ); int size = extC.length;
private void exportPolygonPatch( PolygonPatch polygonPatch ) throws XMLStreamException, UnknownCRSException, TransformationException { switch ( polygonPatch.getPolygonPatchType() ) { case POLYGON_PATCH: writer.writeStartElement( gmlNs, "PolygonPatch" ); writer.writeStartElement( gmlNs, "exterior" ); exportRing( polygonPatch.getExteriorRing() ); writer.writeEndElement(); for ( Ring ring : polygonPatch.getInteriorRings() ) { writer.writeStartElement( gmlNs, "interior" ); exportRing( ring ); writer.writeEndElement(); } writer.writeEndElement(); break; case TRIANGLE: exportTriangle( (Triangle) polygonPatch ); break; case RECTANGLE: exportRectangle( (Rectangle) polygonPatch ); break; } }
void render( PointStyling styling, Surface surface ) { for ( SurfacePatch patch : surface.getPatches() ) { if ( patch instanceof PolygonPatch ) { PolygonPatch polygonPatch = (PolygonPatch) patch; for ( Curve curve : polygonPatch.getBoundaryRings() ) { curve.setCoordinateSystem( surface.getCoordinateSystem() ); renderer.render( styling, curve ); } } else { throw new IllegalArgumentException( "Cannot render non-planar surfaces." ); } } }
@Override protected com.vividsolutions.jts.geom.Geometry buildJTSGeometry() { if ( patches.size() < 1 || !( patches.get( 0 ) instanceof PolygonPatch ) ) { throw new IllegalArgumentException( Messages.getMessage( "SURFACE_NOT_EQUIVALENT_TO_POLYGON" ) ); } // TODO handle the other patches as well PolygonPatch patch = (PolygonPatch) patches.get( 0 ); Ring exteriorRing = patch.getExteriorRing(); List<Ring> interiorRings = patch.getInteriorRings(); LinearRing shell = (LinearRing) getAsDefaultGeometry( exteriorRing ).getJTSGeometry(); LinearRing[] holes = null; if ( interiorRings != null ) { holes = new LinearRing[interiorRings.size()]; int i = 0; for ( Ring ring : interiorRings ) { holes[i++] = (LinearRing) getAsDefaultGeometry( ring ).getJTSGeometry(); } } return jtsFactory.createPolygon( shell, holes ); } }
private PolygonPatch transform( PolygonPatch patch, Transformation trans ) throws TransformationException { Ring exterior = patch.getExteriorRing(); LinearRing transformedExteriorRing = transform( exterior, trans ); PolygonPatch result = null; PolygonPatchType type = patch.getPolygonPatchType(); switch ( type ) { case POLYGON_PATCH: List<Ring> interiorRings = ( patch ).getInteriorRings(); List<Ring> transformedInteriorRings = new ArrayList<Ring>( interiorRings == null ? 0 : interiorRings.size() ); if ( interiorRings != null && !interiorRings.isEmpty() ) { for ( Ring interior : interiorRings ) { if ( interior != null ) { LinearRing lr = transform( interior, trans ); transformedInteriorRings.add( lr ); } } } result = geomFactory.createPolygonPatch( transformedExteriorRing, transformedInteriorRings ); break; case RECTANGLE: result = geomFactory.createRectangle( transformedExteriorRing ); break; case TRIANGLE: result = geomFactory.createTriangle( transformedExteriorRing ); break; } return result; }
void render( PolygonStyling styling, Surface surface ) { for ( SurfacePatch patch : surface.getPatches() ) { if ( patch instanceof PolygonPatch ) { LinkedList<Double> lines = new LinkedList<Double>(); PolygonPatch polygonPatch = (PolygonPatch) patch; // just appending the holes appears to work, the Java2D rendering mechanism can determine that they lie // inside and thus no substraction etc. is needed. This speeds up things SIGNIFICANTLY GeneralPath polygon = new GeneralPath( WIND_EVEN_ODD ); for ( Curve curve : polygonPatch.getBoundaryRings() ) { Double d = geomHelper.fromCurve( curve, true ); lines.add( d ); polygon.append( d, false ); } fillRenderer.applyFill( styling.fill, styling.uom ); graphics.fill( polygon ); for ( Double d : lines ) { strokeRenderer.applyStroke( styling.stroke, styling.uom, d, styling.perpendicularOffset, styling.perpendicularOffsetType ); } } else { throw new IllegalArgumentException( "Cannot render non-planar surfaces." ); } } }
Ring exteriorRing = patch.getExteriorRing(); List<Ring> interiorRings = patch.getInteriorRings(); simplified = geomFac.createPolygon( geometry.getId(), geometry.getCoordinateSystem(), exteriorRing, interiorRings ); Ring exteriorRing = ( (PolygonPatch) patch ).getExteriorRing(); List<Ring> interiorRings = ( (PolygonPatch) patch ).getInteriorRings(); members.add( geomFac.createPolygon( null, geometry.getCoordinateSystem(), exteriorRing, interiorRings ) );
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." ); } } }
Ring exteriorRing = patch.getExteriorRing(); if ( !validateCurve( exteriorRing, affectedGeometryParticles2 ) ) { isValid = false; List<Ring> interiorRings = patch.getInteriorRings(); List<LinearRing> interiorJTSRings = new ArrayList<LinearRing>( interiorRings.size() ); List<Polygon> interiorJTSRingsAsPolygons = new ArrayList<Polygon>( interiorRings.size() );
for ( SurfacePatch patch : s.getPatches() ) { if ( patch instanceof PolygonPatch ) { Ring exterior = ( (PolygonPatch) patch ).getExteriorRing(); LinearRing movedExteriorRing = null; if ( exterior != null ) { offx, offy ) ); List<Ring> interiorRings = ( (PolygonPatch) patch ).getInteriorRings(); List<Ring> movedInteriorRings = new ArrayList<Ring>( interiorRings.size() ); for ( Ring interior : interiorRings ) {