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

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

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

Polygon.contains介绍

暂无

代码示例

代码示例来源:origin: opentripplanner/OpenTripPlanner

if (shell.contains(hole)) {
  ((List<LinearRing>) shell.getUserData()).add(hole);
  break outer;

代码示例来源:origin: opentripplanner/OpenTripPlanner

if (shell.contains(hole)) {
  ((List<LinearRing>) shell.getUserData()).add(hole);
  break outer;

代码示例来源:origin: opentripplanner/OpenTripPlanner

if (!ring.toJtsPolygon().contains(area.toJTSMultiPolygon())) {
  continue;

代码示例来源:origin: opentripplanner/OpenTripPlanner

if (!ring.toJtsPolygon().contains(area.toJTSMultiPolygon())) {
  continue;
  GeometryFactory geometryFactory = GeometryUtils.getGeometryFactory();
  LineString line = geometryFactory.createLineString(coordinates);
  if (poly != null && poly.contains(line)) {

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

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

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

/**
 * Splits a Polygon using a LineString.
 *
 * @param polygon
 * @param lineString
 * @return
 */
public static Collection<Polygon> polygonWithLineSplitter(Polygon polygon, LineString lineString) {
  Collection<Polygon> polygons = splitPolygonizer(polygon, lineString);
  if (polygons != null && polygons.size() > 1) {
    List<Polygon> pols = new ArrayList<Polygon>();
    for (Polygon pol : polygons) {
      if (polygon.contains(pol.getInteriorPoint())) {
        pols.add(pol);
      }
    }
    return pols;
  }
  return null;
}

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

/**
 * Splits a Polygon using a LineString.
 *
 * @param polygon
 * @param lineString
 * @return
 */
private static Collection<Polygon> polygonWithLineSplitter(Polygon polygon, LineString lineString) throws SQLException {
  Collection<Polygon> polygons = splitPolygonizer(polygon, lineString);
  if (polygons != null && polygons.size() > 1) {
    List<Polygon> pols = new ArrayList<Polygon>();
    for (Polygon pol : polygons) {
      if (polygon.contains(pol.getInteriorPoint())) {
        pols.add(pol);
      }
    }
    return pols;
  }
  return null;
}

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

/**
 * Splits a Polygon using a LineString.
 *
 * @param polygon
 * @param lineString
 * @return
 */
private static Collection<Polygon> polygonWithLineSplitter(Polygon polygon, LineString lineString) throws SQLException {
  Collection<Polygon> polygons = splitPolygonizer(polygon, lineString);
  if (polygons != null && polygons.size() > 1) {
    List<Polygon> pols = new ArrayList<Polygon>();
    for (Polygon pol : polygons) {
      if (polygon.contains(pol.getInteriorPoint())) {
        pols.add(pol);
      }
    }
    return pols;
  }
  return null;
}

代码示例来源:origin: kiselev-dv/gazetteer

@SuppressWarnings("unchecked")
private void one2OneJoin(List<JSONObject> polygons, Map<JSONObject, JSONObject> result) {
  for(JSONObject placeV : polygons) {
    Polygon polyg = GeoJsonWriter.getPolygonGeometry(placeV);
    Envelope polygonEnvelop = polyg.getEnvelopeInternal();
    for (JSONObject pnt : (List<JSONObject>)addrPointsIndex.query(polygonEnvelop)) {
      JSONArray pntg = pnt.getJSONObject(GeoJsonWriter.GEOMETRY).getJSONArray(GeoJsonWriter.COORDINATES);
      if(polyg.contains(factory.createPoint(new Coordinate(pntg.getDouble(0), pntg.getDouble(1))))){
        result.put(pnt, placeV);
      }
    }
  }
}

代码示例来源:origin: sitewhere/sitewhere

public <T extends IZone> ZoneMatcher(IDeviceLocation location, List<T> zones) {
this.location = location;
for (IZone zone : zones) {
  Polygon zonePoly = GeoUtils.createPolygonForZone(zone);
  ZoneContainment containment = (zonePoly.contains(GeoUtils.createPointForLocation(location)))
    ? ZoneContainment.Inside : ZoneContainment.Outside;
  ZoneRelationship relationship = new ZoneRelationship(location, zone, containment);
  relationships.put(zone.getToken(), relationship);
}
}

代码示例来源:origin: com.sitewhere/sitewhere-core

public <T extends IZone> ZoneMatcher(IDeviceLocation location, List<T> zones) {
this.location = location;
for (IZone zone : zones) {
  Polygon zonePoly = GeoUtils.createPolygonForZone(zone);
  ZoneContainment containment = (zonePoly.contains(GeoUtils.createPointForLocation(location)))
    ? ZoneContainment.Inside : ZoneContainment.Outside;
  ZoneRelationship relationship = new ZoneRelationship(location, zone, containment);
  relationships.put(zone.getToken(), relationship);
}
}

代码示例来源:origin: kiselev-dv/gazetteer

if (pp != null) {
  Coordinate c = getCoordinateFromGJSON(pp);
  if(polygon.contains(fatory.createPoint(c))) {

代码示例来源:origin: DataSystemsLab/GeoSpark

private boolean intersects(Polygon polygon)
{
  if (intersects(polygon.getExteriorRing())) {
    return true;
  }
  if (polygon.contains(factory.createPoint(centerPoint))) {
    return true;
  }
  if (polygon.getNumInteriorRing() == 0) {
    return false;
  }
  for (int i = 0; i < polygon.getNumInteriorRing(); i++) {
    if (intersects(polygon.getInteriorRingN(i))) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: org.datasyslab/geospark

private boolean intersects(Polygon polygon)
{
  if (intersects(polygon.getExteriorRing())) {
    return true;
  }
  if (polygon.contains(factory.createPoint(centerPoint))) {
    return true;
  }
  if (polygon.getNumInteriorRing() == 0) {
    return false;
  }
  for (int i = 0; i < polygon.getNumInteriorRing(); i++) {
    if (intersects(polygon.getInteriorRingN(i))) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: dhis2/dhis2-core

"{\"type\":\"Polygon\", \"coordinates\":" + multiPolygonJson + "}" ) );
contains = polygon.contains( point );

代码示例来源:origin: kiselev-dv/gazetteer

if (polygon.contains(p.getInteriorPoint()))
  output.add(p);

代码示例来源:origin: kodapan/osm-common

public double calculate(Polygon polygon, Coordinate coordinate, double precisionKilometers, GeometryFactory geometryFactory) {
 Point point = new Point(new CoordinateArraySequence(new Coordinate[]{coordinate}), geometryFactory);
 if (polygon.contains(point)) {
  // todo distance to border? well if that should be the case then factor this method out of this class!
  return 0;
 }
 double smallestDistance = Double.MAX_VALUE;
 Coordinate[] coordinates = polygon.getCoordinates();
 for (int i = 1; i < coordinates.length; i++) {
  for (Coordinate interpolated : new LineInterpolation().interpolate(precisionKilometers, coordinates[i - 1], coordinates[i])) {
   double distance = calculate(interpolated, coordinate);
   if (distance < smallestDistance) {
    smallestDistance = distance;
   }
  }
 }
 return smallestDistance;
}

代码示例来源:origin: org.geoserver.extension/imagemap

Geometry geo=(Geometry)ft.getDefaultGeometry();
if(!clippingBox.contains(geo)) {
  try {
    Geometry clippedGeometry=clippingBox.intersection(geo);

代码示例来源:origin: sitewhere/sitewhere

@Override
public void onLocation(IDeviceEventContext context, IDeviceLocation location) throws SiteWhereException {
for (ZoneTest test : zoneTests) {
  Polygon poly = getZonePolygon(test.getZoneToken());
  ZoneContainment containment = (poly.contains(GeoUtils.createPointForLocation(location)))
    ? ZoneContainment.Inside
    : ZoneContainment.Outside;
  if (test.getCondition() == containment) {
  DeviceAlertCreateRequest alert = new DeviceAlertCreateRequest();
  alert.setType(test.getAlertType());
  alert.setLevel(test.getAlertLevel());
  alert.setMessage(test.getAlertMessage());
  alert.setUpdateState(false);
  alert.setEventDate(new Date());
  getDeviceEventManagement().addDeviceAlerts(location.getDeviceAssignmentId(), alert);
  }
}
}

代码示例来源:origin: com.sitewhere/sitewhere-core

@Override
public void onLocationNotFiltered(IDeviceLocation location) throws SiteWhereException {
for (ZoneTest test : zoneTests) {
  Polygon poly = getZonePolygon(test.getZoneToken());
  ZoneContainment containment = (poly.contains(GeoUtils.createPointForLocation(location)))
    ? ZoneContainment.Inside : ZoneContainment.Outside;
  if (test.getCondition() == containment) {
  DeviceAlertCreateRequest alert = new DeviceAlertCreateRequest();
  alert.setType(test.getAlertType());
  alert.setLevel(test.getAlertLevel());
  alert.setMessage(test.getAlertMessage());
  alert.setUpdateState(false);
  alert.setEventDate(new Date());
  SiteWhere.getServer().getDeviceEventManagement(getTenant())
    .addDeviceAlert(location.getDeviceAssignmentToken(), alert);
  }
}
}

相关文章