if (CGAlgorithms.signedArea(ring.getCoordinateSequence()) > 0.0) holes.add(ring); else
if (CGAlgorithms.signedArea(ring.getCoordinateSequence()) > 0.0) holes.add(ring); else
/** * Returns the area of this <code>Polygon</code> * *@return the area of the polygon */ public double getArea() { double area = 0.0; area += Math.abs(CGAlgorithms.signedArea(shell.getCoordinateSequence())); for (int i = 0; i < holes.length; i++) { area -= Math.abs(CGAlgorithms.signedArea(holes[i].getCoordinateSequence())); } return area; }
private void validateConstruction() { if (!isEmpty() && ! super.isClosed()) { throw new IllegalArgumentException("Points of LinearRing do not form a closed linestring"); } if (getCoordinateSequence().size() >= 1 && getCoordinateSequence().size() < MINIMUM_VALID_SIZE) { throw new IllegalArgumentException("Invalid number of points in LinearRing (found " + getCoordinateSequence().size() + " - must be 0 or >= 4)"); } }
public void filter(Geometry geom) { if (isForcedToLineString && geom instanceof LinearRing) { LineString line = geom.getFactory().createLineString( ((LinearRing) geom).getCoordinateSequence()); lines.add(line); return; } // if not being forced, and this is a linear component if (geom instanceof LineString) lines.add(geom); // else this is not a linear component, so skip it }
/** * Transforms a LinearRing. * The transformation of a LinearRing may result in a coordinate sequence * which does not form a structurally valid ring (i.e. a degnerate ring of 3 or fewer points). * In this case a LineString is returned. * Subclasses may wish to override this method and check for this situation * (e.g. a subclass may choose to eliminate degenerate linear rings) * * @param geom the ring to simplify * @param parent the parent geometry * @return a LinearRing if the transformation resulted in a structurally valid ring * @return a LineString if the transformation caused the LinearRing to collapse to 3 or fewer points */ protected Geometry transformLinearRing(LinearRing geom, Geometry parent) { CoordinateSequence seq = transformCoordinates(geom.getCoordinateSequence(), geom); int seqSize = seq.size(); // ensure a valid LinearRing if (seqSize > 0 && seqSize < 4 && ! preserveType) return factory.createLineString(seq); return factory.createLinearRing(seq); }
public final Geometry edit(Geometry geometry, GeometryFactory factory) { if (geometry instanceof LinearRing) { return factory.createLinearRing(edit( ((LinearRing)geometry).getCoordinateSequence(), geometry)); } if (geometry instanceof LineString) { return factory.createLineString(edit( ((LineString)geometry).getCoordinateSequence(), geometry)); } if (geometry instanceof Point) { return factory.createPoint(edit( ((Point)geometry).getCoordinateSequence(), geometry)); } return geometry; }
/** * Computes the boundary of this geometry * * @return a lineal geometry (which may be empty) * @see Geometry#getBoundary */ public Geometry getBoundary() { if (isEmpty()) { return getFactory().createMultiLineString(null); } LinearRing[] rings = new LinearRing[holes.length + 1]; rings[0] = shell; for (int i = 0; i < holes.length; i++) { rings[i + 1] = holes[i]; } // create LineString or MultiLineString as appropriate if (rings.length <= 1) return getFactory().createLinearRing(rings[0].getCoordinateSequence()); return getFactory().createMultiLineString(rings); }
public Object getProperty(Object object, QName name) throws Exception { LinearRing linearRing = (LinearRing) object; if (GML.coordinates.equals(name)) { return linearRing.getCoordinateSequence(); } return null; } }
public Object getProperty(Object object, QName name) throws Exception { if ( KML.coordinates.getLocalPart().equals( name.getLocalPart() ) ) { LinearRing l = (LinearRing) object; return l.getCoordinateSequence(); } return null; } }
private double getDistanceFromFrontier(final double _xref, final double _yref) { tmp_.x = _xref; tmp_.y = _yref; return GISLib.getDistanceFromFrontier(extern_.getCoordinateSequence(), tmp_, tmpX1_, tmpX2_); }
public boolean visitPolygone(final LinearRing _p) { res_ = TYPE_REGION + " 1\n" + exportCoords(_p.getCoordinateSequence(), true); return true; }
if (shell.getNumPoints() != 5) return false; CoordinateSequence seq = shell.getCoordinateSequence();
public void filter(Geometry geom) { if (isForcedToLineString && geom instanceof LinearRing) { LineString line = geom.getFactory().createLineString( ((LinearRing) geom).getCoordinateSequence()); lines.add(line); return; } // if not being forced, and this is a linear component if (geom instanceof LineString) lines.add(geom); // else this is not a linear component, so skip it }
private void validateConstruction() { if (!isEmpty() && ! super.isClosed()) { throw new IllegalArgumentException("Points of LinearRing do not form a closed linestring"); } if (getCoordinateSequence().size() >= 1 && getCoordinateSequence().size() < MINIMUM_VALID_SIZE) { throw new IllegalArgumentException("Invalid number of points in LinearRing (found " + getCoordinateSequence().size() + " - must be 0 or >= 4)"); } }
private static final Geometry cloneGeometryLCS(LinearRing geom) { return geomFac.createLinearRing(new LiteCoordinateSequence((LiteCoordinateSequence) geom .getCoordinateSequence())); }
@Override protected void visitLiteralGeometry(Literal expression) throws IOException { Geometry g = (Geometry) evaluateLiteral(expression, Geometry.class); if (g instanceof LinearRing) { //WKT does not support linear rings g = g.getFactory().createLineString(((LinearRing) g).getCoordinateSequence()); } out.write( "geometry::STGeomFromText('"+g.toText()+"', "+currentSRID+")"); }
@Override protected void visitLiteralGeometry(Literal expression) throws IOException { Geometry g = (Geometry) evaluateLiteral(expression, Geometry.class); if (g instanceof LinearRing) { //WKT does not support linear rings g = g.getFactory().createLineString(((LinearRing) g).getCoordinateSequence()); } out.write( "GeomFromText('"+g.toText()+"', "+currentSRID+")"); }
@Override protected void visitLiteralGeometry(Literal expression) throws IOException { Geometry g = (Geometry) evaluateLiteral(expression, Geometry.class); if (g instanceof LinearRing) { //WKT does not support linear rings g = g.getFactory().createLineString(((LinearRing) g).getCoordinateSequence()); } out.write( "ST_GeomFromText('"+g.toText()+"', "+currentSRID+")"); }
public static boolean isSelectedEnv(final Coordinate _pt, final LinearRing _r, final Envelope _env, final PointInRing _tester, final double _prec) { if (_env == null) { return isSelected(_pt, _r, _tester, _prec); } return _env.contains(_pt) && _tester.isInside(_pt) || getDistanceFromFrontier(_r.getCoordinateSequence(), _pt) < _prec; }