private boolean testVerticesEquality(Geometry geom1, Geometry geom2) { if ( geom1.getNumPoints() != geom2.getNumPoints() ) { return false; } for ( int i = 0; i < geom1.getNumPoints(); i++ ) { Coordinate cn1 = geom1.getCoordinates()[i]; Coordinate cn2 = geom2.getCoordinates()[i]; if ( !cn1.equals2D( cn2 ) ) { return false; } } return true; } }
private boolean testVerticesEquality(Geometry geom1, Geometry geom2) { if ( geom1.getNumPoints() != geom2.getNumPoints() ) { return false; } for ( int i = 0; i < geom1.getNumPoints(); i++ ) { Coordinate cn1 = geom1.getCoordinates()[i]; Coordinate cn2 = geom2.getCoordinates()[i]; if ( !cn1.equals2D( cn2 ) ) { return false; } } return true; } }
private static void writePolyline(Geometry geometry, SliceOutput output, boolean multitype) { int numParts; int numPoints = geometry.getNumPoints(); if (multitype) { numParts = geometry.getNumGeometries(); output.writeByte(GeometrySerializationType.MULTI_LINE_STRING.code()); } else { numParts = numPoints > 0 ? 1 : 0; output.writeByte(GeometrySerializationType.LINE_STRING.code()); } output.writeInt(EsriShapeType.POLYLINE.code); writeEnvelope(geometry, output); output.writeInt(numParts); output.writeInt(numPoints); int partIndex = 0; for (int i = 0; i < numParts; i++) { output.writeInt(partIndex); partIndex += geometry.getGeometryN(i).getNumPoints(); } writeCoordinates(geometry.getCoordinates(), output); }
protected boolean testTypeAndVertexEquality(Geometry geom1, Geometry geom2) { if ( !geom1.getGeometryType().equals( geom2.getGeometryType() ) ) { return false; } if ( geom1.getNumGeometries() != geom2.getNumGeometries() ) { return false; } if ( geom1.getNumPoints() != geom2.getNumPoints() ) { return false; } Coordinate[] coordinates1 = geom1.getCoordinates(); Coordinate[] coordinates2 = geom2.getCoordinates(); for ( int i = 0; i < coordinates1.length; i++ ) { Coordinate c1 = coordinates1[i]; Coordinate c2 = coordinates2[i]; if ( !testCoordinateEquality( c1, c2 ) ) { return false; } } return true; }
public static int numPoints(Geometry arg0) { if (arg0 == null) return 0; Geometry _this = arg0; return _this.getNumPoints(); }
public int getNumPoints() { return geometry.getNumPoints(); }
int numPoints = geometry.getNumPoints(); for (int i = 0; i < numGeometries; i++) { Polygon polygon = (Polygon) geometry.getGeometryN(i);
@DescribeProcess( title = "Number of Points", description = "Returns the number of vertices in a given geometry." ) @DescribeResult(description = "Total number of vertices") public static int numPoints( @DescribeParameter(name = "geom", description = "Input geometry") Geometry geom) { return geom.getNumPoints(); }
/** * Gets a point to represent the Geometry. If the Geometry is a point, this is returned. * Otherwise, the centroid is used. * * @param g the geometry to find a point for * @return a point representing the Geometry */ private static Coordinate getPoint(Geometry g) { if (g.getNumPoints() == 1) return g.getCoordinate(); return g.getCentroid().getCoordinate(); }
/** * Gets a point to represent the Geometry. If the Geometry is a point, this is returned. * Otherwise, the centroid is used. * * @param g the geometry to find a point for * @return a point representing the Geometry */ private static Coordinate getRepresentativePoint(Geometry g) { if (g.getNumPoints() == 1) return g.getCoordinate(); return g.getCentroid().getCoordinate(); }
LOGGER.finer("\tpoints: " + geom.getNumPoints()); } else { LOGGER.finer("got a null geometry back from gml parser");
coordinates += g.getNumPoints(); if (maxCoordinates > 0 && coordinates > maxCoordinates) { throw new IllegalStateException(
private static void addElemInfo( List elemInfoList, GeometryCollection geoms, final int STARTING_OFFSET, final int GTYPE) { Geometry geom; int offset = STARTING_OFFSET; int LEN = D(GTYPE) + L(GTYPE); for (int i = 0; i < geoms.getNumGeometries(); i++) { geom = geoms.getGeometryN(i); elemInfo(elemInfoList, geom, offset, GTYPE); if (geom instanceof Polygon && isRectangle((Polygon) geom)) { offset += (2 * LEN); } else { offset += (geom.getNumPoints() * LEN); } } }
ensureNonNull("geometry", geometry); if ((minPoints <= 0) || (geometry.getNumPoints() < minPoints)) { return geometry;
public void testEncode() throws Exception { Geometry geometry = GML3MockData.multiLineString(); GML3EncodingUtils.setID(geometry, "geometry"); Document dom = encode(geometry, GML.MultiLineString); // print(dom); assertEquals("geometry", getID(dom.getDocumentElement())); assertEquals(2, dom.getElementsByTagNameNS(GML.NAMESPACE, "lineStringMember").getLength()); NodeList children = dom.getElementsByTagNameNS(GML.NAMESPACE, GML.LineString.getLocalPart()); assertEquals(2, children.getLength()); assertEquals("geometry.1", getID(children.item(0))); assertEquals("geometry.2", getID(children.item(1))); checkDimension(dom, GML.MultiLineString.getLocalPart(), 2); checkDimension(dom, GML.LineString.getLocalPart(), 2); checkPosListOrdinates(dom, 2 * geometry.getGeometryN(0).getNumPoints()); } }
Geometry g = (Geometry) value; if ((g == null) || (g.getNumPoints() == 0) || (g.getCoordinates().length == 0)) { return;
final Geometry original = JTS.toGeometry(shape); final Geometry reduced = JTS.removeCollinearVertices(original); assertEquals(10, original.getNumPoints()); assertEquals(5, reduced.getNumPoints()); final double DELTA = 1E-9;
public void testSimplification() throws Exception { SimpleFeatureSource fs = dataStore.getFeatureSource(tname("road")); if (fs.getSupportedHints().contains(Hints.GEOMETRY_SIMPLIFICATION) == false) return; SimpleFeatureCollection fColl = fs.getFeatures(); Geometry original = null; try (SimpleFeatureIterator iterator = fColl.features()) { if (iterator.hasNext()) { original = (Geometry) iterator.next().getDefaultGeometry(); } } double width = original.getEnvelope().getEnvelopeInternal().getWidth(); Query query = new Query(); Hints hints = new Hints(Hints.GEOMETRY_SIMPLIFICATION, width / 2); query.setHints(hints); Geometry simplified = null; fColl = fs.getFeatures(query); try (SimpleFeatureIterator iterator = fColl.features()) { if (iterator.hasNext()) simplified = (Geometry) iterator.next().getDefaultGeometry(); } assertTrue(original.getNumPoints() >= simplified.getNumPoints()); }
public void testGeneralization() throws Exception { SimpleFeatureSource fs = dataStore.getFeatureSource(tname("lake")); if (fs.getSupportedHints().contains(Hints.GEOMETRY_GENERALIZATION) == false) return; SimpleFeatureCollection fColl = fs.getFeatures(); Geometry original = null; try (SimpleFeatureIterator iterator = fColl.features()) { if (iterator.hasNext()) { original = (Geometry) iterator.next().getDefaultGeometry(); } } double width = original.getEnvelope().getEnvelopeInternal().getWidth(); Query query = new Query(); Hints hints = new Hints(Hints.GEOMETRY_GENERALIZATION, width / 2); query.setHints(hints); Geometry generalized = null; fColl = fs.getFeatures(query); try (SimpleFeatureIterator iterator = fColl.features()) { if (iterator.hasNext()) { generalized = (Geometry) iterator.next().getDefaultGeometry(); } } assertTrue(original.getNumPoints() >= generalized.getNumPoints()); }
geometry = reader.read(WKT); assertNotNull("parsed perfect circle", geometry); assertEquals(11, geometry.getNumPoints());