本文整理了Java中com.vividsolutions.jts.geom.Polygon.intersects()
方法的一些代码示例,展示了Polygon.intersects()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Polygon.intersects()
方法的具体详情如下:
包路径:com.vividsolutions.jts.geom.Polygon
类名称:Polygon
方法名:intersects
暂无
代码示例来源:origin: org.geotools/gt-render
public boolean intersects(Geometry g) {
return polygon.intersects(g);
}
代码示例来源:origin: OneBusAway/onebusaway-application-modules
protected List<EnterpriseGeocoderResult> filterResultsByWktPolygon(List<EnterpriseGeocoderResult> input) {
if(_wktFilterPolygon == null) {
return input;
}
List<EnterpriseGeocoderResult> output = new ArrayList<EnterpriseGeocoderResult>();
for(EnterpriseGeocoderResult result : input) {
Coordinate coordinate = new Coordinate(result.getLongitude(), result.getLatitude());
Geometry point = _geometryFactory.createPoint(coordinate);
if(_wktFilterPolygon.intersects(point)) {
output.add(result);
}
}
return output;
}
代码示例来源:origin: kiselev-dv/gazetteer
private void many2ManyJoin(JSONObject object, Polygon polyg, Map<JSONObject, List<JSONObject>> result, SpatialIndex index) {
Envelope polygonEnvelop = polyg.getEnvelopeInternal();
for (Object entry : index.query(polygonEnvelop)) {
JSONArray pntg = ((JSONObject)entry).getJSONObject(GeoJsonWriter.GEOMETRY).getJSONArray(GeoJsonWriter.COORDINATES);
Coordinate pnt = new Coordinate(pntg.getDouble(0), pntg.getDouble(1));
JSONObject obj = (JSONObject) entry;
if(polyg.intersects(factory.createPoint(pnt))) {
if(result.get(obj) == null) {
result.put(obj, new ArrayList<JSONObject>());
}
result.get(obj).add(object);
}
}
}
代码示例来源:origin: org.orbisgis/orbisgis-core
/**
* Cut a MultiPolygon with a Polygon.
*
* @param multiPolygon
* @param extrudePolygon
* @return
*/
public static MultiPolygon cutMultiPolygonWithPolygon(MultiPolygon multiPolygon, Polygon extrudePolygon) {
ArrayList<Polygon> polygons = new ArrayList<Polygon>();
for (int i = 0; i < multiPolygon.getNumGeometries(); i++) {
Polygon subGeom = (Polygon) multiPolygon.getGeometryN(i);
if (extrudePolygon.intersects(subGeom)) {
List<Polygon> result = cutPolygonWithPolygon(subGeom, extrudePolygon);
polygons.addAll(result);
} else {
polygons.add(subGeom);
}
}
return FACTORY.createMultiPolygon(polygons.toArray(new Polygon[polygons.size()]));
}
代码示例来源:origin: osmlab/atlas
/**
* Query country boundaries which cover/partially cover given {@link PolyLine}
*
* @param polyLine
* Any {@link PolyLine} or {@link Polygon}
* @return a list of {@link CountryBoundary}
*/
public List<CountryBoundary> boundaries(final PolyLine polyLine)
{
return this.boundariesHelper(() -> this.query(polyLine.bounds().asEnvelope()),
boundary -> boundary.intersects(JTS_POLYLINE_CONVERTER.convert(polyLine)));
}
代码示例来源:origin: kiselev-dv/gazetteer
private static MultiPolygon substract(MultiPolygon outer, MultiPolygon inner) {
List<Polygon> polygons = new ArrayList<Polygon>();
if(inner != null && !inner.isEmpty()) {
for(int j = 0; j < outer.getNumGeometries(); j++) {
Polygon outerN = (Polygon) outer.getGeometryN(j);
for(int i = 0; i < inner.getNumGeometries(); i++) {
Polygon innerN = (Polygon) inner.getGeometryN(i);
if(outerN.intersects(innerN)) {
outerN = (Polygon) outerN.difference(innerN);
}
}
if(!outerN.isEmpty()) {
polygons.add(outerN);
}
}
}
Polygon[] ps = polygons.toArray(new Polygon[polygons.size()]);
MultiPolygon mp = geometryFactory.createMultiPolygon(ps);
if(mp.isValid()) {
return mp;
}
return null;
}
代码示例来源:origin: osmlab/atlas
.filter(polygon -> polygon.intersects(target)).collect(Collectors.toList());
boolean usingNearestNeighbor = false;
if (polygons.size() == 1 || isSameCountry(polygons))
.filter(polygon -> polygon.intersects(target))
.map(polygon -> getGeometryProperty(polygon, ISOCountryTag.KEY))
.findFirst();
polygons.stream().filter(polygon -> polygon.intersects(target))
.map(polygon -> getGeometryProperty(polygon, ISOCountryTag.KEY))
.collect(Collectors.toList()));
代码示例来源:origin: osmlab/atlas
/**
* Query country boundaries which cover/partially cover given {@link PolyLine}, with an
* extension square box
*
* @param polyLine
* Any {@link PolyLine} or {@link Polygon}
* @param extension
* Extension {@link Distance}
* @return a list of {@link CountryBoundary}
*/
public List<CountryBoundary> boundaries(final PolyLine polyLine, final Distance extension)
{
return this.boundariesHelper(
() -> this.query(polyLine.bounds().expand(extension).asEnvelope()),
boundary -> boundary.intersects(JTS_POLYLINE_CONVERTER.convert(polyLine)));
}
代码示例来源:origin: deegree/deegree3
/**
* Tests the currently selected label position for intersection with the current selection of another label position.
* If both labels are not rotated, an efficient AABB test is used, otherwise a polygon intersection is done
*
* @param labelPosOption
* Another {@link PointLabelPositionOptions} to intersect with
*
*/
boolean intersectsSelection( PointLabelPositionOptions labelPosOption ){
if( label.getStyling().rotation != 0 || labelPosOption.label.getStyling().rotation != 0 ){
return selectedPolygon.intersects( labelPosOption.selectedPolygon);
}else
return ((selMinX < labelPosOption.getSelectedMaxX()) && (selMaxX > labelPosOption.getSelectedMinX()) && (selMinY < labelPosOption.getSelectedMaxY()) && (selMaxY > labelPosOption.getSelectedMinY()));
}
代码示例来源:origin: deegree/deegree3
/**
* Tests if the bounding rectangle of all possible positions intersects with the bounding rectangle of another PointLabelPositionOptions-object
* If both labels are not rotated, an efficient AABB test is used, otherwise a polygon intersection is done
*
* @param labelPosOption
* Another {@link PointLabelPositionOptions} to intersect with
*
*/
boolean intersectsAny( PointLabelPositionOptions labelPosOption ){
if( label.getStyling().rotation != 0 || labelPosOption.label.getStyling().rotation != 0 ){
return totalPolygon.intersects( labelPosOption.totalPolygon);
}else
return ((totalMinX < labelPosOption.getMaxX()) && (totalMaxX > labelPosOption.getMinX()) && (totalMinY < labelPosOption.getMaxY()) && (totalMaxY > labelPosOption.getMinY()));
}
代码示例来源:origin: osmlab/atlas
final Polygon geoBox = buildGeoBox(currentX, currentX + incrementValue,
currentY, currentY + incrementValue);
if (geoBox.intersects(polygon))
代码示例来源:origin: osmlab/atlas
final Polygon geoBox = buildGeoBox(minX, maxX, minY, maxY);
if (!geoBox.intersects(polygon))
代码示例来源:origin: kiselev-dv/gazetteer
Polygon inner = f.createPolygon(interior);
if (inner.intersects(outer)) {
Polygon difference = (Polygon) outer.difference(inner);
if (difference.isValid()) {
代码示例来源:origin: org.integratedmodelling/klab-engine
Point point = pm.createPoint(new Coordinate(xy[0], xy[1]));
for (int j = 0; j < pairs.size(); j++) {
if (pairs.get(j).getFirst().intersects(point)) {
index[i] = (short) (j + 1);
break;
代码示例来源:origin: org.locationtech.geogig/geogig-datastore
@Test
public void touchesFilter() throws Exception {
Envelope bounds = testNode.bounds().get();
bounds.translate(-1 * bounds.getWidth(), 0);
Polygon touching = JTS.toGeometry(bounds);
// just a preflight test
assertTrue(JTS.toGeometry(bounds).intersects(touching));
Touches filter;
Filter pre;
Filter post;
filter = (Touches) toFilter(String.format("Touches(the_geom, %s)", touching));
pre = ff.intersects(ff.property("@bounds"), ff.literal(touching));
post = filter;
assertFilter(filter, pre, post);
}
内容来源于网络,如有侵权,请联系作者删除!