com.vividsolutions.jts.geom.Polygon.covers()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(5.9k)|赞(0)|评价(0)|浏览(108)

本文整理了Java中com.vividsolutions.jts.geom.Polygon.covers()方法的一些代码示例,展示了Polygon.covers()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Polygon.covers()方法的具体详情如下:
包路径:com.vividsolutions.jts.geom.Polygon
类名称:Polygon
方法名:covers

Polygon.covers介绍

暂无

代码示例

代码示例来源:origin: org.geotools/gt-render

public boolean covers(Geometry g) {
  return polygon.covers(g);
}

代码示例来源:origin: org.opengis.cite/ets-kml2

/**
 * [Test] Verifies that a kml:Model element has a valid location (that
 * specifies the position of the model origin).
 */
@Test(description = "ATC-133, ATC-150")
public void modelLocation() {
  JTSGeometryBuilder geomBuilder = new JTSGeometryBuilder();
  Polygon crsPolygon = geomBuilder.buildPolygon(new Envelope(-180, 180,
      -90, 90));
  for (int i = 0; i < targetElements.getLength(); i++) {
    Element model = (Element) targetElements.item(i);
    NodeList location = model.getElementsByTagNameNS(KML2.NS_NAME,
        "Location");
    if (location.getLength() == 0) {
      throw new AssertionError(ErrorMessage.format(
          ErrorMessageKeys.MISSING_INFOSET_ITEM, "kml:Location",
          XMLUtils.buildXPointer(model)));
    }
    Point jtsPoint = geomBuilder
        .buildPointFromLocation((Element) location.item(0));
    Assert.assertTrue(
        crsPolygon.covers(jtsPoint),
        ErrorMessage.format(ErrorMessageKeys.OUTSIDE_CRS,
            jtsPoint.toText()));
  }
}

代码示例来源:origin: org.opengis.cite/ets-kml2

/**
 * [Test] Verifies that a kml:LineString element has valid coordinates. It
 * must contain two or more coordinate tuple in the default CRS.
 */
@Test(description = "ATC-103, ATC-115")
public void validLineStringCoordinates() {
  JTSGeometryBuilder geomBuilder = new JTSGeometryBuilder();
  Polygon crsPolygon = geomBuilder.buildPolygon(new Envelope(-180, 180,
      -90, 90));
  for (int i = 0; i < targetElements.getLength(); i++) {
    Element line = (Element) targetElements.item(i);
    Assert.assertTrue(coordsValidator.isValid(line),
        coordsValidator.getErrorMessages());
    LineString jtsLine = geomBuilder.buildLineString(line);
    Assert.assertTrue(
        crsPolygon.covers(jtsLine),
        ErrorMessage.format(ErrorMessageKeys.OUTSIDE_CRS,
            jtsLine.toText()));
  }
}

代码示例来源:origin: org.opengis.cite/ets-kml2

/**
 * [Test] Verifies that a kml:Point element has valid coordinates. It must
 * contain exactly one coordinate tuple in the default CRS.
 */
@Test(description = "ATC-103, ATC-114")
public void validPointCoordinates() {
  JTSGeometryBuilder geomBuilder = new JTSGeometryBuilder();
  Polygon crsPolygon = geomBuilder.buildPolygon(new Envelope(-180, 180,
      -90, 90));
  for (int i = 0; i < targetElements.getLength(); i++) {
    Element point = (Element) targetElements.item(i);
    Assert.assertTrue(coordsValidator.isValid(point),
        coordsValidator.getErrorMessages());
    Point jtsPoint = geomBuilder.buildPoint(point);
    Assert.assertTrue(
        crsPolygon.covers(jtsPoint),
        ErrorMessage.format(ErrorMessageKeys.OUTSIDE_CRS,
            jtsPoint.toText()));
  }
}

代码示例来源:origin: org.opengis.cite/ets-kml2

XMLUtils.buildXPointer(polygon)));
Assert.assertTrue(crsPolygon.covers(jtsPolygon), ErrorMessage
    .format(ErrorMessageKeys.OUTSIDE_CRS, jtsPolygon.toText()));

代码示例来源:origin: osmlab/atlas

/**
 * Query country boundaries which cover given {@link Location}
 *
 * @param location
 *            Any {@link Location}
 * @return a list of {@link CountryBoundary}
 */
public List<CountryBoundary> boundaries(final Location location)
{
  return this.boundariesHelper(() -> this.query(location.bounds().asEnvelope()),
      boundary -> boundary.covers(JTS_POINT_CONVERTER.convert(location)));
}

代码示例来源:origin: org.opengis.cite/ets-kml2

/**
 * [Test] Verifies that a kml:LinearRing element has valid coordinates. It
 * must contain a sequence of four or more coordinate tuples in the default
 * CRS. Furthermore, the first and last control points must be coincident
 * (i.e. the ring is explicitly closed).
 */
@Test(description = "ATC-103, ATC-116")
public void validLinearRingCoordinates() {
  JTSGeometryBuilder geomBuilder = new JTSGeometryBuilder();
  Polygon crsPolygon = geomBuilder.buildPolygon(new Envelope(-180, 180,
      -90, 90));
  for (int i = 0; i < targetElements.getLength(); i++) {
    Element ring = (Element) targetElements.item(i);
    Assert.assertTrue(coordsValidator.isValid(ring),
        coordsValidator.getErrorMessages());
    LinearRing jtsRing = null;
    try {
      jtsRing = geomBuilder.buildLinearRing(ring);
    } catch (IllegalArgumentException ex) {
      throw new AssertionError(ErrorMessage.format(
          ErrorMessageKeys.OPEN_RING,
          XMLUtils.buildXPointer(ring)));
    }
    Assert.assertTrue(
        crsPolygon.covers(jtsRing),
        ErrorMessage.format(ErrorMessageKeys.OUTSIDE_CRS,
            jtsRing.toText()));
  }
}

代码示例来源:origin: org.orbisgis/h2gis

/**
 *
 *  @param g1 Geometry instance or null
 *  @param g2 Geometry instance or null
 *  @return minimum distance in meters between two geometries
 */
private static Double distancePointPolygon(Geometry g1, Geometry g2) {
  Double distance = Double.MAX_VALUE;
  Double ringDistance;
  Point point;
  Polygon polygon;
  if (g1 instanceof Polygon) {
    point = (Point) g2;
    polygon = (Polygon) g1;
  } else {
    point = (Point) g1;
    polygon = (Polygon) g2;
  }
  if (polygon.covers(point)) {
    return 0.0;
  }
  for (int i = 0; i < polygon.getExteriorRing().getNumPoints(); i++) {
    ringDistance = distancePointToPoint(polygon.getExteriorRing().getPointN(i), point);
    if (ringDistance < distance) {
      distance = ringDistance;
    }
  }
  return distance;
}

代码示例来源:origin: org.orbisgis/h2gis-functions

/**
 *
 *  @param g1 Geometry instance or null
 *  @param g2 Geometry instance or null
 *  @return minimum distance in meters between two geometries
 */
private static Double distancePointPolygon(Geometry g1, Geometry g2) {
  Double distance = Double.MAX_VALUE;
  Double ringDistance;
  Point point;
  Polygon polygon;
  if (g1 instanceof Polygon) {
    point = (Point) g2;
    polygon = (Polygon) g1;
  } else {
    point = (Point) g1;
    polygon = (Polygon) g2;
  }
  if (polygon.covers(point)) {
    return 0.0;
  }
  for (int i = 0; i < polygon.getExteriorRing().getNumPoints(); i++) {
    ringDistance = distancePointToPoint(polygon.getExteriorRing().getPointN(i), point);
    if (ringDistance < distance) {
      distance = ringDistance;
    }
  }
  return distance;
}

代码示例来源:origin: osmlab/atlas

|| polygon.covers(geoBox))

代码示例来源:origin: osmlab/atlas

return polygon.covers(point);

代码示例来源:origin: osmlab/atlas

return polygon.covers(JTS_POLYGON_CONVERTER.convert(rectangle));

代码示例来源:origin: org.opengis.cite/ets-kml2

new ErrorLocator(-1, -1, XMLUtils.buildXPointer(quad)));
if (!crsPolygon.covers(jtsPolygon)) {
  errHandler.addError(ErrorSeverity.ERROR, ErrorMessage.format(
      ErrorMessageKeys.OUTSIDE_CRS, jtsPolygon.toText()),

相关文章