/** * Returns a list of the rings which define the surface: First element is * the exterior ring (island), the following elements, if exist, define the * interior rings (holes) * * @return List of Ring: First element is the exterior ring (island), * the following elements, if exist, define the interior rings * (holes) */ public List<Ring> getBoundaryRings() { List<Ring> rList = new ArrayList(); rList.add(this.boundary.getExterior()); Iterator tInteriorRings = this.boundary.getInteriors().iterator(); while (tInteriorRings.hasNext()) { rList.add((Ring) tInteriorRings.next()); } return rList; }
public PolygonType(final JTSPolygon poly) { if (poly != null && poly.getBoundary() != null) { this.coordinateReferenceSystem = poly.getBoundary().getCoordinateReferenceSystem(); this.exterior = poly.getBoundary().getExterior(); this.interior = poly.getBoundary().getInteriors(); } }
public SurfaceImpl clone() throws CloneNotSupportedException { // Test OK // Clone SurfaceBoundary and use it to create new Surface SurfaceBoundary newBoundary = (SurfaceBoundary) this.boundary.clone(); return new SurfaceImpl(newBoundary); }
/** * Constructor The second version, which is guaranteed to work always in 2D * coordinate spaces, constructs a Surface by indicating its boundary as a * collection of Curves organized into a SurfaceBoundary. In 3D coordinate * spaces, this second version of the constructor shall require all of the * defining boundary Curve instances to be coplanar (lie in a single plane) * which will define the surface interior. * * Surface::Surface(bdy : SurfaceBoundary) : Surface * @param boundary * The SurfaceBoundary which defines the Surface */ public SurfaceImpl(SurfaceBoundary boundary) { super(boundary.getCoordinateReferenceSystem(), null, null, null); // Set Boundary this.boundary = boundary; // Set Envelope this.envelope = boundary.getEnvelope(); // TODO Is it really necessary to create the surface patches? // Create Surface Patch on basis of the Boundary ArrayList<SurfacePatch> newPatchList = new ArrayList<SurfacePatch>(); newPatchList.add(new PolygonImpl((SurfaceBoundaryImpl)boundary, (SurfaceImpl)this)); this.patch = newPatchList; }
public static DirectPosition[] getExteriorDirectPositions(final Polygon polygon) { final SurfaceBoundary surfaceBoundary = polygon.getBoundary(); final Ring exteriorRing = surfaceBoundary.getExterior(); return GeometryUtils.getDirectPositions(exteriorRing); }
public static DirectPosition[][] getInteriorDirectPositions(final Polygon polygon) { final SurfaceBoundary surfaceBoundary = polygon.getBoundary(); final List interiorRings = surfaceBoundary.getInteriors(); final DirectPosition[][] returnable = new DirectPosition[interiorRings.size()][]; for (int i = 0; i < interiorRings.size(); i++) { returnable[i] = getDirectPositions((Ring)interiorRings.get(i)); } return returnable; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; final SurfaceImpl other = (SurfaceImpl) obj; if (boundary == null) { if (other.boundary != null) return false; } else if (!boundary.equals(other.boundary)) return false; /* Envelope.class doesn't have equals implemented if (envelope == null) { if (other.envelope != null) return false; } else if (!envelope.equals(other.envelope)) return false; */ return true; }
public static DirectPosition[] getExteriorDirectPositions(final Polygon polygon) { final SurfaceBoundary surfaceBoundary = polygon.getBoundary(); final Ring exteriorRing = surfaceBoundary.getExterior(); return GeometryUtils.getDirectPositions(exteriorRing); }
public static DirectPosition[][] getInteriorDirectPositions(final Polygon polygon) { final SurfaceBoundary surfaceBoundary = polygon.getBoundary(); final List interiorRings = surfaceBoundary.getInteriors(); final DirectPosition[][] returnable = new DirectPosition[interiorRings.size()][]; for (int i = 0; i < interiorRings.size(); i++) { returnable[i] = getDirectPositions((Ring)interiorRings.get(i)); } return returnable; }
private String surfaceBoundaryCoordToString(SurfaceBoundary sb) { String rString = "("; rString += ringCoordToString((Ring) sb.getExterior()); rString += ")"; List<Ring> interior = sb.getInteriors(); if (interior.size() > 0) { for (int i = 0; i < interior.size(); i++) { rString += ", ("; rString += ringCoordToString((Ring) interior.get(i)); rString += ")"; } } return rString; }
assertEquals(expPoly.getPatches().get(0).getBoundary().getExterior(), resPoly.getPatches().get(0).getBoundary().getExterior()); assertEquals(expPoly.getPatches().get(0).getBoundary().getInteriors(), resPoly.getPatches().get(0).getBoundary().getInteriors()); assertEquals(expPoly.getPatches().get(0).getBoundary(), resPoly.getPatches().get(0).getBoundary()); assertEquals(expPoly.getPatches().get(0).getInterpolation(), resPoly.getPatches().get(0).getInterpolation()); JTSPolygon resPolygon = (JTSPolygon) result.getElements().iterator().next(); assertEquals(expPolygon.getCoordinateReferenceSystem(), resPolygon.getCoordinateReferenceSystem()); assertEquals(expPolygon.getBoundary().getCoordinateReferenceSystem(), resPolygon.getBoundary().getCoordinateReferenceSystem()); JTSCurve expCurve = (JTSCurve) expPolygon.getBoundary().getExterior().getElements().iterator().next(); JTSCurve resCurve = (JTSCurve) resPolygon.getBoundary().getExterior().getElements().iterator().next(); JTSLineString expLine = (JTSLineString) expCurve.getSegments().get(0); JTSLineString resLine = (JTSLineString) resCurve.getSegments().get(0); assertEquals(expCurve.getSegments(), resCurve.getSegments()); assertEquals(expCurve, resCurve); assertEquals(expPolygon.getBoundary().getExterior(), resPolygon.getBoundary().getExterior()); assertEquals(expPolygon.getBoundary().getInteriors(), resPolygon.getBoundary().getInteriors()); assertEquals(expPolygon.getBoundary(), resPolygon.getBoundary()); assertEquals(expPolygon, resPolygon);
public static DirectPosition[] getExteriorDirectPositions(final Polygon polygon) { final SurfaceBoundary surfaceBoundary = polygon.getBoundary(); final Ring exteriorRing = surfaceBoundary.getExterior(); return GeometryUtils.getDirectPositions(exteriorRing); }
public static DirectPosition[][] getInteriorDirectPositions(final Polygon polygon) { final SurfaceBoundary surfaceBoundary = polygon.getBoundary(); final List interiorRings = surfaceBoundary.getInteriors(); final DirectPosition[][] returnable = new DirectPosition[interiorRings.size()][]; for (int i = 0; i < interiorRings.size(); i++) { returnable[i] = getDirectPositions((Ring)interiorRings.get(i)); } return returnable; }
/** * @return * @see com.polexis.lite.spatialschema.geometry.primitive.SurfacePatchImpl#calculateJTSPeer() */ public com.vividsolutions.jts.geom.Geometry calculateJTSPeer() { SurfaceBoundary boundary = getBoundary(); Ring exterior = boundary.getExterior(); List interiors = boundary.getInteriors(); com.vividsolutions.jts.geom.Geometry g = ((JTSGeometry) exterior).getJTSGeometry(); int numHoles = (interiors != null) ? interiors.size() : 0; com.vividsolutions.jts.geom.LinearRing jtsExterior = JTSUtils.GEOMETRY_FACTORY.createLinearRing(g.getCoordinates()); com.vividsolutions.jts.geom.LinearRing [] jtsInterior = new com.vividsolutions.jts.geom.LinearRing[numHoles]; for (int i=0; i<numHoles; i++) { com.vividsolutions.jts.geom.Geometry g2 = ((JTSGeometry) interiors.get(i)).getJTSGeometry(); jtsInterior[i] = JTSUtils.GEOMETRY_FACTORY.createLinearRing(g2.getCoordinates()); } com.vividsolutions.jts.geom.Polygon result = JTSUtils.GEOMETRY_FACTORY.createPolygon(jtsExterior, jtsInterior); return result; }
/** * @return * @see com.polexis.lite.spatialschema.geometry.primitive.SurfacePatchImpl#calculateJTSPeer() */ public com.vividsolutions.jts.geom.Geometry calculateJTSPeer() { SurfaceBoundary boundary = getBoundary(); Ring exterior = boundary.getExterior(); List interiors = boundary.getInteriors(); com.vividsolutions.jts.geom.Geometry g = ((JTSGeometry) exterior).getJTSGeometry(); int numHoles = (interiors != null) ? interiors.size() : 0; com.vividsolutions.jts.geom.LinearRing jtsExterior = JTSUtils.GEOMETRY_FACTORY.createLinearRing(g.getCoordinates()); com.vividsolutions.jts.geom.LinearRing [] jtsInterior = new com.vividsolutions.jts.geom.LinearRing[numHoles]; for (int i=0; i<numHoles; i++) { com.vividsolutions.jts.geom.Geometry g2 = ((JTSGeometry) interiors.get(i)).getJTSGeometry(); jtsInterior[i] = JTSUtils.GEOMETRY_FACTORY.createLinearRing(g2.getCoordinates()); } com.vividsolutions.jts.geom.Polygon result = JTSUtils.GEOMETRY_FACTORY.createPolygon(jtsExterior, jtsInterior); return result; }
/** * {@inheritDoc } */ @Override public org.locationtech.jts.geom.Geometry computeJTSPeer() { final SurfaceBoundary boundary = getBoundary(); final Ring exterior = boundary.getExterior(); final List interiors = boundary.getInteriors(); if (exterior != null) { final org.locationtech.jts.geom.Geometry g = ((JTSGeometry) exterior).getJTSGeometry(); final int numHoles = (interiors != null) ? interiors.size() : 0; final org.locationtech.jts.geom.LinearRing jtsExterior = JTSUtils.GEOMETRY_FACTORY.createLinearRing(g.getCoordinates()); final org.locationtech.jts.geom.LinearRing [] jtsInterior = new org.locationtech.jts.geom.LinearRing[numHoles]; for (int i=0; i<numHoles; i++) { final org.locationtech.jts.geom.Geometry g2 = ((JTSGeometry) interiors.get(i)).getJTSGeometry(); jtsInterior[i] = JTSUtils.GEOMETRY_FACTORY.createLinearRing(g2.getCoordinates()); } final org.locationtech.jts.geom.Polygon result = JTSUtils.GEOMETRY_FACTORY.createPolygon(jtsExterior, jtsInterior); final CoordinateReferenceSystem crs = getCoordinateReferenceSystem(); if (crs != null) { final int srid = SRIDGenerator.toSRID(crs, Version.V1); result.setSRID(srid); } return result; } return null; }
public void applyCRSOnchild() { JTSRing exterior = (JTSRing) polygon.getBoundary().getExterior(); exterior.setCoordinateReferenceSystem(getCoordinateReferenceSystem()); if (polygon.getBoundary().getInteriors() != null) { for (Ring ring : polygon.getBoundary().getInteriors()) { ((JTSRing) ring).setCoordinateReferenceSystem(getCoordinateReferenceSystem()); for (Primitive p : ring.getElements()) {