本文整理了Java中com.vividsolutions.jts.geom.Geometry.isEmpty()
方法的一些代码示例,展示了Geometry.isEmpty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Geometry.isEmpty()
方法的具体详情如下:
包路径:com.vividsolutions.jts.geom.Geometry
类名称:Geometry
方法名:isEmpty
[英]Tests whether the set of points covered by this Geometry
is empty.
[中]测试此Geometry
覆盖的点集是否为空。
代码示例来源:origin: osmandapp/Osmand
/**
* JTS 1.14 does not support intersection on a {@link GeometryCollection}. This function works around this
* by performing intersection on a flat list of geometry. The resulting list is pre-filtered for invalid
* or empty geometry (outside of bounds). Invalid geometry are logged as errors.
*
* @param envelope non-list geometry defines bounding area
* @param dataGeoms geometry pre-passed through {@link #flatFeatureList(Geometry)}
* @return list of geometry from {@code data} intersecting with {@code envelope}.
*/
private static List<Geometry> flatIntersection(Geometry envelope, List<Geometry> dataGeoms) {
final List<Geometry> intersectedGeoms = new ArrayList<>(dataGeoms.size());
Geometry nextIntersected;
for(Geometry nextGeom : dataGeoms) {
try {
// AABB intersection culling
if(envelope.getEnvelopeInternal().intersects(nextGeom.getEnvelopeInternal())) {
nextIntersected = envelope.intersection(nextGeom);
if(!nextIntersected.isEmpty()) {
nextIntersected.setUserData(nextGeom.getUserData());
intersectedGeoms.add(nextIntersected);
}
}
} catch (TopologyException e) {
//LoggerFactory.getLogger(JtsAdapter.class).error(e.getMessage(), e);
}
}
return intersectedGeoms;
}
代码示例来源:origin: opentripplanner/OpenTripPlanner
public void setGeom(Geometry geom) throws EmptyPolygonException, UnsupportedGeometryException {
if (geom instanceof MultiPolygon) {
if (geom.isEmpty()) {
throw new EmptyPolygonException();
}
if (geom.getNumGeometries() > 1) {
// LOG.warn("Multiple polygons in MultiPolygon, using only the first.");
// TODO percolate this warning up somehow
}
this.geom = geom.getGeometryN(0);
} else if( geom instanceof Point || geom instanceof Polygon){
this.geom = geom;
} else {
throw new UnsupportedGeometryException( "Non-point, non-polygon Geometry, not supported." );
}
// cache a representative point
Point point = geom.getCentroid();
this.lat = point.getY();
this.lon = point.getX();
}
代码示例来源:origin: com.vividsolutions/jts
public boolean isEmpty() {
for (int i = 0; i < geometries.length; i++) {
if (!geometries[i].isEmpty()) {
return false;
}
}
return true;
}
代码示例来源:origin: opentripplanner/OpenTripPlanner
Geometry intersection = seg2.intersection(seg);
Point p = null;
if (intersection.isEmpty()) {
continue;
} else if (intersection instanceof Point) {
代码示例来源:origin: com.vividsolutions/jts
/**
* Determines the {@link Location} of a point in an areal {@link Geometry}.
* Currently this will never return a value of BOUNDARY.
*
* @param p the point to test
* @param geom the areal geometry to test
* @return the Location of the point in the geometry
*/
public static int locate(Coordinate p, Geometry geom)
{
if (geom.isEmpty()) return Location.EXTERIOR;
if (containsPoint(p, geom))
return Location.INTERIOR;
return Location.EXTERIOR;
}
代码示例来源:origin: com.vividsolutions/jts
private void extractElements(Geometry geom, List elems)
{
if (geom == null)
return;
for (int i = 0; i < geom.getNumGeometries(); i++) {
Geometry elemGeom = geom.getGeometryN(i);
if (skipEmpty && elemGeom.isEmpty())
continue;
elems.add(elemGeom);
}
}
代码示例来源:origin: com.vividsolutions/jts
public boolean hasRepeatedPoint(Geometry g)
{
if (g.isEmpty()) return false;
if (g instanceof Point) return false;
else if (g instanceof MultiPoint) return false;
// LineString also handles LinearRings
else if (g instanceof LineString) return hasRepeatedPoint(((LineString) g).getCoordinates());
else if (g instanceof Polygon) return hasRepeatedPoint((Polygon) g);
else if (g instanceof GeometryCollection) return hasRepeatedPoint((GeometryCollection) g);
else throw new UnsupportedOperationException(g.getClass().getName());
}
代码示例来源:origin: com.vividsolutions/jts
private void checkExpectedEmpty()
{
// can't check areal features
if (input.getDimension() >= 2) return;
// can't check positive distances
if (distance > 0.0) return;
// at this point can expect an empty result
if (! result.isEmpty()) {
isValid = false;
errorMsg = "Result is non-empty";
errorIndicator = result;
}
report("ExpectedEmpty");
}
代码示例来源:origin: com.vividsolutions/jts
protected Geometry transformMultiPoint(MultiPoint geom, Geometry parent) {
List transGeomList = new ArrayList();
for (int i = 0; i < geom.getNumGeometries(); i++) {
Geometry transformGeom = transformPoint((Point) geom.getGeometryN(i), geom);
if (transformGeom == null) continue;
if (transformGeom.isEmpty()) continue;
transGeomList.add(transformGeom);
}
return factory.buildGeometry(transGeomList);
}
代码示例来源:origin: com.vividsolutions/jts
private Geometry boundaryMultiLineString(MultiLineString mLine)
{
if (geom.isEmpty()) {
return getEmptyMultiPoint();
}
Coordinate[] bdyPts = computeBoundaryCoordinates(mLine);
// return Point or MultiPoint
if (bdyPts.length == 1) {
return geomFact.createPoint(bdyPts[0]);
}
// this handles 0 points case as well
return geomFact.createMultiPoint(bdyPts);
}
代码示例来源:origin: com.vividsolutions/jts
protected Geometry transformMultiLineString(MultiLineString geom, Geometry parent) {
List transGeomList = new ArrayList();
for (int i = 0; i < geom.getNumGeometries(); i++) {
Geometry transformGeom = transformLineString((LineString) geom.getGeometryN(i), geom);
if (transformGeom == null) continue;
if (transformGeom.isEmpty()) continue;
transGeomList.add(transformGeom);
}
return factory.buildGeometry(transGeomList);
}
代码示例来源:origin: com.vividsolutions/jts
protected Geometry transformMultiPolygon(MultiPolygon geom, Geometry parent) {
List transGeomList = new ArrayList();
for (int i = 0; i < geom.getNumGeometries(); i++) {
Geometry transformGeom = transformPolygon((Polygon) geom.getGeometryN(i), geom);
if (transformGeom == null) continue;
if (transformGeom.isEmpty()) continue;
transGeomList.add(transformGeom);
}
return factory.buildGeometry(transGeomList);
}
代码示例来源:origin: com.vividsolutions/jts
public Geometry getResultGeometry()
{
// empty input produces an empty result
if (inputGeom.isEmpty()) return (Geometry) inputGeom.clone();
return (new DPTransformer(isEnsureValidTopology)).transform(inputGeom);
}
代码示例来源:origin: com.vividsolutions/jts
public boolean equalsExact(Geometry other, double tolerance) {
if (!isEquivalentClass(other)) {
return false;
}
if (isEmpty() && other.isEmpty()) {
return true;
}
if (isEmpty() != other.isEmpty()) {
return false;
}
return equal(((Point) other).getCoordinate(), this.getCoordinate(), tolerance);
}
代码示例来源:origin: com.vividsolutions/jts
public Geometry getResultGeometry()
{
// empty input produces an empty result
if (inputGeom.isEmpty()) return (Geometry) inputGeom.clone();
linestringMap = new HashMap();
inputGeom.apply(new LineStringMapBuilderFilter());
lineSimplifier.simplify(linestringMap.values());
Geometry result = (new LineStringTransformer()).transform(inputGeom);
return result;
}
代码示例来源:origin: com.vividsolutions/jts
public GeometryCollection map(GeometryCollection gc)
{
List mapped = new ArrayList();
for (int i = 0; i < gc.getNumGeometries(); i++) {
Geometry g = mapOp.map(gc.getGeometryN(i));
if (!g.isEmpty())
mapped.add(g);
}
return gc.getFactory().createGeometryCollection(
GeometryFactory.toGeometryArray(mapped));
}
}
代码示例来源:origin: com.vividsolutions/jts
protected Geometry transformGeometryCollection(GeometryCollection geom, Geometry parent) {
List transGeomList = new ArrayList();
for (int i = 0; i < geom.getNumGeometries(); i++) {
Geometry transformGeom = transform(geom.getGeometryN(i));
if (transformGeom == null) continue;
if (pruneEmptyGeometry && transformGeom.isEmpty()) continue;
transGeomList.add(transformGeom);
}
if (preserveGeometryCollectionType)
return factory.createGeometryCollection(GeometryFactory.toGeometryArray(transGeomList));
return factory.buildGeometry(transGeomList);
}
代码示例来源:origin: com.vividsolutions/jts
private void add(Geometry g)
{
if (g.isEmpty()) return;
if (g instanceof Polygon) addPolygon((Polygon) g);
// LineString also handles LinearRings
else if (g instanceof LineString) addLineString((LineString) g);
else if (g instanceof Point) addPoint((Point) g);
else if (g instanceof MultiPoint) addCollection((MultiPoint) g);
else if (g instanceof MultiLineString) addCollection((MultiLineString) g);
else if (g instanceof MultiPolygon) addCollection((MultiPolygon) g);
else if (g instanceof GeometryCollection) addCollection((GeometryCollection) g);
else throw new UnsupportedOperationException(g.getClass().getName());
}
private void addCollection(GeometryCollection gc)
代码示例来源:origin: com.vividsolutions/jts
private void checkValid(Geometry g)
{
validErr = null;
// empty geometries are always valid!
if (g.isEmpty()) return;
if (g instanceof Point) checkValid((Point) g);
else if (g instanceof MultiPoint) checkValid((MultiPoint) g);
// LineString also handles LinearRings
else if (g instanceof LinearRing) checkValid( (LinearRing) g);
else if (g instanceof LineString) checkValid( (LineString) g);
else if (g instanceof Polygon) checkValid( (Polygon) g);
else if (g instanceof MultiPolygon) checkValid( (MultiPolygon) g);
else if (g instanceof GeometryCollection) checkValid( (GeometryCollection) g);
else throw new UnsupportedOperationException(g.getClass().getName());
}
代码示例来源:origin: com.vividsolutions/jts
private boolean computeSimple(Geometry geom)
{
nonSimpleLocation = null;
if (geom.isEmpty()) return true;
if (geom instanceof LineString) return isSimpleLinearGeometry(geom);
if (geom instanceof MultiLineString) return isSimpleLinearGeometry(geom);
if (geom instanceof MultiPoint) return isSimpleMultiPoint((MultiPoint) geom);
if (geom instanceof Polygonal) return isSimplePolygonal(geom);
if (geom instanceof GeometryCollection) return isSimpleGeometryCollection(geom);
// all other geometry types are simple by definition
return true;
}
内容来源于网络,如有侵权,请联系作者删除!