Codota Logo
Geometry.isEmpty
Code IndexAdd Codota to your IDE (free)

How to use
isEmpty
method
in
com.vividsolutions.jts.geom.Geometry

Best Java code snippets using com.vividsolutions.jts.geom.Geometry.isEmpty (Showing top 20 results out of 558)

  • Common ways to obtain Geometry
private void myMethod () {
Geometry g =
  • Codota IconGeometryCollection gc;gc.getGeometryN(n)
  • Codota IconSimpleFeature feature;(Geometry) feature.getDefaultGeometry()
  • Codota IconString wellKnownText;new WKTReader().read(wellKnownText)
  • Smart code suggestions by Codota
}
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;
}
com.vividsolutions.jts.geomGeometryisEmpty

Javadoc

Tests whether the set of points covered by this Geometry is empty.

Popular methods of Geometry

  • getEnvelopeInternal
    Gets an Envelope containing the minimum and maximum x and y values in this Geometry. If the geometr
  • getCoordinates
    Returns an array containing the values of all the vertices for this geometry. If the geometry is a c
  • getCentroid
    Computes the centroid of this Geometry. The centroid is equal to the centroid of the set of componen
  • getGeometryN
    Returns an element Geometry from a GeometryCollection(or this, if the geometry is not a collection).
  • toText
    Returns the Well-known Text representation of this Geometry. For a definition of the Well-known Text
  • getNumGeometries
    Returns the number of Geometrys in a GeometryCollection(or 1, if the geometry is not a collection).
  • getFactory
    Gets the factory which contains the context in which this geometry was created.
  • getGeometryType
    Returns the name of this Geometry's actual class.
  • getSRID
    Returns the ID of the Spatial Reference System used by the Geometry. JTS supports Spatial Reference
  • getCoordinate
    Returns a vertex of this Geometry (usually, but not necessarily, the first one). The returned coordi
  • intersection
    Computes a Geometry representing the point-set which is common to both this Geometry and the other
  • buffer
    Computes a buffer area around this geometry having the given width and with a specified accuracy of
  • intersection,
  • buffer,
  • contains,
  • getArea,
  • getEnvelope,
  • intersects,
  • union,
  • apply,
  • getLength

Popular in Java

  • Making http requests using okhttp
  • scheduleAtFixedRate (Timer)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • startActivity (Activity)
  • FileInputStream (java.io)
    A FileInputStream obtains input bytes from a file in a file system. What files are available depends
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • Path (java.nio.file)
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • JCheckBox (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now