Java Code Examples for org.locationtech.jts.geom.Geometry#covers()

The following examples show how to use org.locationtech.jts.geom.Geometry#covers() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: H2IndexingAbstractGeoSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Check distributed query.
 *
 * @throws ParseException If failed.
 */
private void checkDistributedQuery() throws ParseException {
    IgniteCache<Integer, Enemy> c1 = grid(0).cache("enemy");
    IgniteCache<Integer, EnemyCamp> c2 = grid(0).cache("camp");

    final Geometry lethalArea = new WKTReader().read("POLYGON((30 30, 30 70, 70 70, 70 30, 30 30))");

    int expectedEnemies = 0;

    for (Cache.Entry<Integer, Enemy> e : c1) {
        final Integer campID = e.getValue().campId;

        if (30 <= campID && campID < ENEMYCAMP_SAMPLES_COUNT) {
            final EnemyCamp camp = c2.get(campID);

            if (lethalArea.covers(camp.coords))
                expectedEnemies++;
        }
    }

    final SqlFieldsQuery query = new SqlFieldsQuery("select e._val, c._val from \"enemy\".Enemy e, " +
        "\"camp\".EnemyCamp c where e.campId = c._key and c.coords && ?").setArgs(lethalArea);

    List<List<?>> result = c1.query(query.setDistributedJoins(true)).getAll();

    assertEquals(expectedEnemies, result.size());
}
 
Example 2
Source File: GeometryHullToolTest.java    From geowave with Apache License 2.0 5 votes vote down vote up
private static boolean coversPoints(final Geometry coverer, final Geometry pointsToCover) {
  for (final Coordinate coordinate : pointsToCover.getCoordinates()) {
    if (!coverer.covers(coverer.getFactory().createPoint(coordinate))) {
      return false;
    }
  }
  return true;
}
 
Example 3
Source File: Shape.java    From MeteoInfo with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * If this shape covers another one
 * @param other Other shape
 * @return Covers or not
 */
public boolean covers(Shape other){
    Geometry g1 = this.toGeometry();
    Geometry g2 = other.toGeometry();
    return g1.covers(g2);
}
 
Example 4
Source File: GeoWaveFunctions.java    From datawave with Apache License 2.0 4 votes vote down vote up
public static boolean covers(Object fieldValue, String geoString) {
    Geometry otherGeom = AbstractGeometryNormalizer.parseGeometry(geoString);
    Geometry thisGeom = getGeometryFromFieldValue(fieldValue);
    return thisGeom.covers(otherGeom);
}
 
Example 5
Source File: NoDataMetadataFactory.java    From geowave with Apache License 2.0 4 votes vote down vote up
private static NoDataMetadata createMetadata(
    final NoDataSummary noDataSummary,
    final Geometry[] shapes,
    final int width,
    final int height) {
  if (noDataSummary.indices.size() > MAX_LIST_NO_DATA) {
    Geometry finalShape;
    if ((shapes == null) || (shapes.length == 0)) {
      finalShape = null;
    } else {
      finalShape = shapes[0];
      if ((shapes.length > 1) && (finalShape != null)) {
        for (int i = 1; i < shapes.length; i++) {
          if (shapes[i] == null) {
            finalShape = null;
            break;
          } else {
            finalShape = finalShape.union(shapes[i]);
          }
        }
      }
    }
    if ((finalShape != null)
        && finalShape.covers(
            new GeometryFactory().toGeometry(new Envelope(0, width, 0, height)))) {
      // if the coverage of this geometric union ever gets to the
      // point that it fully covers the raster, stop storing it and
      // just set the geometry to null
      finalShape = null;
    }
    return new NoDataByFilter(finalShape, noDataSummary.usedNoDataValues);
  } else if (!noDataSummary.indices.isEmpty()) {
    // just go through every raster sample and determine whether it
    // qualifies as null data
    return new NoDataBySampleIndex(noDataSummary.indices);
  } else {
    // the "no data" samples in the dataset must be 0, so just return
    // null for the metadata
    return null;
  }
}
 
Example 6
Source File: GeomCovers.java    From geowave with Apache License 2.0 4 votes vote down vote up
@Override
public boolean apply(final Geometry geom1, final Geometry geom2) {
  return geom1.covers(geom2);
}