本文整理了Java中org.locationtech.jts.geom.Geometry.union()
方法的一些代码示例,展示了Geometry.union()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Geometry.union()
方法的具体详情如下:
包路径:org.locationtech.jts.geom.Geometry
类名称:Geometry
方法名:union
[英]Computes the union of all the elements of this geometry.
This method supports GeometryCollections (which the other overlay operations currently do not).
The result obeys the following contract:
代码示例来源:origin: geotools/geotools
public static Geometry union(Geometry arg0, Geometry arg1) {
if (arg0 == null || arg1 == null) return null;
Geometry _this = arg0;
return _this.union(arg1);
}
代码示例来源:origin: locationtech/spatial4j
private static Geometry unionGeometryCollection(Geometry geom) {
if (geom instanceof GeometryCollection) {
return geom.union();
}
return geom;
}
代码示例来源:origin: geotools/geotools
public Geometry union() {
return geometry.union();
}
代码示例来源:origin: geotools/geotools
public Geometry union(Geometry other) {
return geometry.union(other);
}
代码示例来源:origin: geotools/geotools
/**
* Returns true if the geometry covers the entire world
*
* @param geometry
* @return
*/
private boolean isWorld(Literal geometry) {
if (geometry != null) {
Geometry g = geometry.evaluate(null, Geometry.class);
if (g != null) {
return JTS.toGeometry(WORLD).equalsTopo(g.union());
}
}
return false;
}
代码示例来源:origin: geotools/geotools
@DescribeProcess(
title = "Union",
description =
"Returns a geometry representing all points contained in any of the geometries in a geometry collection."
)
@DescribeResult(description = "Union of input geometries")
public static Geometry union(
@DescribeParameter(name = "geom", description = "Input geometries (minimum 2)", min = 2)
Geometry... geoms) {
Geometry result = null;
for (Geometry g : geoms) {
if (result == null) {
result = g;
} else {
result = result.union(g);
}
}
return result;
}
代码示例来源:origin: geotools/geotools
@DescribeProcess(title = "Split Polygon", description = "Splits a polygon by a linestring")
@DescribeResult(description = "The collection of split polygons")
public static Geometry splitPolygon(
@DescribeParameter(name = "polygon", description = "Polygon to split") Geometry polygon,
@DescribeParameter(name = "line", description = "Linestring to split by")
LineString line) {
Geometry nodedLinework = polygon.getBoundary().union(line);
Geometry polys = polygonize(nodedLinework);
// Only keep polygons which are inside the input
List<Polygon> output = new ArrayList<Polygon>();
for (int i = 0; i < polys.getNumGeometries(); i++) {
Polygon candpoly = (Polygon) polys.getGeometryN(i);
// use interior point to test for inclusion in parent
if (polygon.contains(candpoly.getInteriorPoint())) {
output.add(candpoly);
}
}
return polygon.getFactory()
.createGeometryCollection(GeometryFactory.toGeometryArray(output));
}
代码示例来源:origin: org.n52.sensorweb.sos/hibernate-common
private Geometry mergeGeometries(Geometry geom, List<Object> list) {
for (Object extent : list) {
if (extent != null) {
if (geom == null) {
geom = (Geometry) extent;
} else {
geom.union((Geometry) extent);
}
}
}
return geom;
}
代码示例来源:origin: locationtech/jts
private Geometry repeatedUnion(List geoms)
{
Geometry union = null;
for (Iterator i = geoms.iterator(); i.hasNext(); ) {
Geometry g = (Geometry) i.next();
if (union == null)
union = g.copy();
else
union = union.union(g);
}
return union;
}
代码示例来源:origin: locationtech/jts
public static Geometry bufferByComponents(Geometry g, double distance)
{
return componentBuffers(g, distance).union();
}
代码示例来源:origin: locationtech/jts
(new FailureChecker() { void operation() {
b.union(a);
} }).check(IllegalArgumentException.class);
}
代码示例来源:origin: locationtech/jts
(new FailureChecker() { void operation() {
a.union(b);
} }).check(IllegalArgumentException.class);
代码示例来源:origin: org.opengeo/geodb
@Override
protected void add(Geometry geometry) {
if (result == null) {
result = geometry;
} else {
if (geometry != null) {
result = result.union(geometry.getEnvelope());
}
}
}
代码示例来源:origin: locationtech/jts
public static Geometry logoLines(Geometry g)
{
return create_J(g)
.union(create_T(g))
.union(create_S(g));
}
代码示例来源:origin: locationtech/jts
public static Geometry unionUsingGeometryCollection(Geometry a, Geometry b)
{
Geometry gc = a.getFactory().createGeometryCollection(
new Geometry[] { a, b});
return gc.union();
}
代码示例来源:origin: locationtech/jts
/**
* Computes the set-theoretic union 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 union of the input Geometries.
*/
public Geometry union(Geometry geom0, Geometry geom1)
{
Geometry[] geom = removeCommonBits(geom0, geom1);
return computeResultPrecision(geom[0].union(geom[1]));
}
代码示例来源:origin: locationtech/jts
public static Geometry invokeGeometryOverlayMethod(int opCode, Geometry g0, Geometry g1)
{
switch (opCode) {
case OverlayOp.INTERSECTION: return g0.intersection(g1);
case OverlayOp.UNION: return g0.union(g1);
case OverlayOp.DIFFERENCE: return g0.difference(g1);
case OverlayOp.SYMDIFFERENCE: return g0.symDifference(g1);
}
throw new IllegalArgumentException("Unknown overlay op code");
}
代码示例来源:origin: locationtech/jts
public double measure(Geometry g1, Geometry g2)
{
double areaInt = g1.intersection(g2).getArea();
double areaUnion = g1.union(g2).getArea();
return areaInt / areaUnion;
}
代码示例来源:origin: locationtech/jts
public void testNoding() throws Exception {
Geometry a = reader.read("LINESTRING(0 0, 100 100)");
Geometry b = reader.read("LINESTRING(0 100, 100 0)");
List lineStrings = Arrays.asList(new Object[] {a, b});
Geometry nodedLineStrings = (LineString) lineStrings.get(0);
for (int i = 1; i < lineStrings.size(); i++) {
nodedLineStrings = nodedLineStrings.union((LineString)lineStrings.get(i));
}
assertEquals("MULTILINESTRING ((0 0, 50 50), (50 50, 100 100), (0 100, 50 50), (50 50, 100 0))", nodedLineStrings.toString());
}
代码示例来源:origin: locationtech/jts
private Geometry dissolveLines(Geometry lines) {
Geometry dissolved = lines.union();
LineMerger merger = new LineMerger();
merger.add(dissolved);
Collection mergedColl = merger.getMergedLineStrings();
Geometry merged = lines.getFactory().buildGeometry(mergedColl);
return merged;
}
内容来源于网络,如有侵权,请联系作者删除!