本文整理了Java中org.locationtech.jts.geom.Geometry.intersection()
方法的一些代码示例,展示了Geometry.intersection()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Geometry.intersection()
方法的具体详情如下:
包路径:org.locationtech.jts.geom.Geometry
类名称:Geometry
方法名:intersection
[英]Computes a Geometry
representing the point-set which is common to both this Geometry
and the other
Geometry.
The intersection of two geometries of different dimension produces a result geometry of dimension less than or equal to the minimum dimension of the input geometries. The result geometry may be a heterogeneous GeometryCollection. If the result is empty, it is an atomic geometry with the dimension of the lowest input dimension.
Intersection of GeometryCollections is supported only for homogeneous collection types.
Non-empty heterogeneous GeometryCollection arguments are not supported.
[中]计算表示此Geometry
和other
几何体共用的点集的Geometry
。
两个不同尺寸的几何图形的交点生成的结果几何图形的尺寸小于或等于输入几何图形的最小尺寸。结果几何体可能是非均匀几何体集合。如果结果为空,则它是具有最低输入维度维度的原子几何体。
只有同构集合类型才支持GeometryCollection的交集。
不支持非空的异构GeometryCollection参数。
代码示例来源:origin: geotools/geotools
public static Geometry intersection(Geometry arg0, Geometry arg1) {
if (arg0 == null || arg1 == null) return null;
Geometry _this = arg0;
return _this.intersection(arg1);
}
代码示例来源:origin: geotools/geotools
public Geometry intersection(Geometry other) {
return geometry.intersection(other);
}
代码示例来源:origin: geotools/geotools
private boolean polygonOverlap(Geometry g1, Geometry g2) {
// TODO: try to use relate instead
Geometry intersection = g1.intersection(g2);
return intersection != null && intersection.getDimension() == 2;
}
代码示例来源:origin: geotools/geotools
/**
* Helper method for {@link #intersection(Geometry, Geometry) intersection(Geometry, Geometry)}
*/
private static List<Geometry> intersection(GeometryCollection gc, Geometry g) {
List<Geometry> ret = new ArrayList<Geometry>();
final int size = gc.getNumGeometries();
for (int i = 0; i < size; i++) {
Geometry g1 = gc.getGeometryN(i);
collect(g1.intersection(g), ret);
}
return ret;
}
代码示例来源:origin: geotools/geotools
Geometry secondTargetGeometry = reprojectAndDensify(second, firstCRS, null);
double numeratorArea =
(double) (firstTargetGeometry.intersection(secondTargetGeometry)).getArea();
if (divideFirst) {
double denom = firstTargetGeometry.getArea();
代码示例来源:origin: geotools/geotools
@DescribeProcess(
title = "Intersection",
description =
"Returns a geometry representing the points that two geometries have in common. The result may be a heterogeneous geometry collection. If no intersection, returns an empty geometry."
)
@DescribeResult(description = "Intersection of geometries")
public static Geometry intersection(
@DescribeParameter(name = "a", description = "First input geometry") Geometry a,
@DescribeParameter(name = "b", description = "Second input geometry") Geometry b) {
return a.intersection(b);
}
代码示例来源:origin: geotools/geotools
private Geometry clipToWorldFeatureTypeGeometry(Geometry geom) {
// Oracle cannot deal with filters using geometries that span beyond the whole world
if (isFeatureTypeGeometryGeodetic() && !WORLD.contains(geom.getEnvelopeInternal())) {
Geometry result = geom.intersection(JTS.toGeometry(WORLD));
if (result != null && !result.isEmpty()) {
if (result instanceof GeometryCollection) {
result = distillSameTypeGeometries((GeometryCollection) result, geom);
}
return result;
}
}
return geom;
}
代码示例来源:origin: geotools/geotools
g = sanitizePolygons(g.intersection(JTS.toGeometry(WORLD)));
Geometry quadrant =
JTS.toGeometry(new Envelope(lon, lon + 90, lat, lat + 90));
Geometry cut = sanitizePolygons(g.intersection(quadrant));
if (!cut.isEmpty()) {
if (cut instanceof Polygon) {
代码示例来源:origin: mapsforge/mapsforge
ret = tileBBJTS.intersection(geometry);
代码示例来源:origin: geotools/geotools
result = geometry.intersection(mask);
} catch (Exception e1) {
+ precision);
result = reduced.intersection(mask);
break;
} catch (Exception e3) {
代码示例来源:origin: locationtech/spatial4j
/**
* This "pages" through standard geo boundaries offset by multiples of 360
* longitudinally that intersect geom, and the intersecting results of a page
* and the geom are shifted into the standard -180 to +180 and added to a new
* geometry that is returned.
*/
private static Geometry cutUnwrappedGeomInto360(Geometry geom) {
Envelope geomEnv = geom.getEnvelopeInternal();
if (geomEnv.getMinX() >= -180 && geomEnv.getMaxX() <= 180)
return geom;
assert geom.isValid() : "geom";
//TODO opt: support geom's that start at negative pages --
// ... will avoid need to previously shift in unwrapDateline(geom).
List<Geometry> geomList = new ArrayList<Geometry>();
//page 0 is the standard -180 to 180 range
for (int page = 0; true; page++) {
double minX = -180 + page * 360;
if (geomEnv.getMaxX() <= minX)
break;
Geometry rect = geom.getFactory().toGeometry(new Envelope(minX, minX + 360, -90, 90));
assert rect.isValid() : "rect";
Geometry pageGeom = rect.intersection(geom);//JTS is doing some hard work
assert pageGeom.isValid() : "pageGeom";
shiftGeomByX(pageGeom, page * -360);
geomList.add(pageGeom);
}
return UnaryUnionOp.union(geomList);
}
代码示例来源:origin: geotools/geotools
mappedMask = mappedMask.buffer(maskingBuffer);
mappedMaskBox = mappedMaskBox.buffer(maskingBuffer);
mappedMask = mappedMask.intersection(mappedMaskBox);
代码示例来源:origin: geotools/geotools
Expression clipToWorld(BinarySpatialOperator filter, Expression e) {
if (e instanceof Literal) {
Geometry eval = e.evaluate(filter, Geometry.class);
// Oracle cannot deal with filters using geometries that span beyond the whole world
// in case the
if (dialect != null
&& isCurrentGeometryGeodetic()
&& !WORLD.contains(eval.getEnvelopeInternal())) {
Geometry result = eval.intersection(JTS.toGeometry(WORLD));
if (result != null && !result.isEmpty()) {
if (result instanceof GeometryCollection) {
result = distillSameTypeGeometries((GeometryCollection) result, eval);
}
FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
e = ff.literal(result);
}
}
}
return e;
}
代码示例来源:origin: geotools/geotools
/**
* Return the intersection of two Geometries. <br>
* This method relies completely on {@link Geometry#intersection(Geometry)} but also tries to
* unroll <TT>GeometryCollection</TT>s.
*
* @param g1
* @param g2
* @return true if the two geometries intersect.
*/
public static Geometry intersection(Geometry g1, Geometry g2) {
if (g1 instanceof GeometryCollection) {
if (g2 instanceof GeometryCollection) {
return intersection((GeometryCollection) g1, (GeometryCollection) g2);
} else {
List<Geometry> ret = intersection((GeometryCollection) g1, g2);
return g1.getFactory()
.createGeometryCollection(GeometryFactory.toGeometryArray(ret));
}
} else {
if (g2 instanceof GeometryCollection) {
List<Geometry> ret = intersection((GeometryCollection) g2, g1);
return g1.getFactory()
.createGeometryCollection(GeometryFactory.toGeometryArray(ret));
} else {
return g1.intersection(g2);
}
}
}
代码示例来源:origin: geotools/geotools
CoordinateSequenceFactory csf = gf.getCoordinateSequenceFactory();
Polygon fence = gf.createPolygon(buildBoundsString(gf, csf), null);
return g.intersection(fence);
} else {
return clipPolygon((Polygon) g);
代码示例来源:origin: geotools/geotools
currentGeom.intersection(
(Geometry) second.getDefaultGeometry());
代码示例来源:origin: geotools/geotools
} else {
if (geom.getEnvelopeInternal().intersects(clip.getEnvelopeInternal())) {
clipped = clip.intersection(geom);
代码示例来源:origin: locationtech/jts
/**
* Computes the set-theoretic intersection of two {@link Geometry}s, using enhanced precision.
* @param geom0 the first Geometry
* @param geom1 the second Geometry
* @return the Geometry representing the set-theoretic intersection of the input Geometries.
*/
public Geometry intersection(Geometry geom0, Geometry geom1)
{
Geometry[] geom = removeCommonBits(geom0, geom1);
return computeResultPrecision(geom[0].intersection(geom[1]));
}
代码示例来源:origin: locationtech/jts
public static double areaDiff(Geometry g0, Geometry g1)
{
double areaA = g0.getArea();
double areaAdiffB = g0.difference(g1).getArea();
double areaAintB = g0.intersection(g1).getArea();
return areaA - areaAdiffB - areaAintB;
}
代码示例来源:origin: locationtech/jts
public void testTriangles()
throws ParseException
{
Geometry a = rdr.read("POLYGON ((545 317, 617 379, 581 321, 545 317))");
Geometry b = rdr.read("POLYGON ((484 290, 558 359, 543 309, 484 290))");
a.intersection(b);
}
}
内容来源于网络,如有侵权,请联系作者删除!