本文整理汇总了Java中com.vividsolutions.jts.operation.overlay.OverlayOp类的典型用法代码示例。如果您正苦于以下问题:Java OverlayOp类的具体用法?Java OverlayOp怎么用?Java OverlayOp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OverlayOp类属于com.vividsolutions.jts.operation.overlay包,在下文中一共展示了OverlayOp类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: intersection
import com.vividsolutions.jts.operation.overlay.OverlayOp; //导入依赖的package包/类
/**
* Computes a <code>Geometry</code> representing the point-set which is
* common to both this <code>Geometry</code> and the <code>other</code> Geometry.
* <p>
* 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 heterogenous {@link GeometryCollection}.
* If the result is empty, it is an atomic geometry
* with the dimension of the lowest input dimension.
* <p>
* Intersection of {@link GeometryCollection}s is supported
* only for homogeneous collection types.
* <p>
* Non-empty heterogeneous {@link GeometryCollection} arguments are not supported.
*
* @param other the <code>Geometry</code> with which to compute the intersection
* @return a Geometry representing the point-set common to the two <code>Geometry</code>s
* @throws TopologyException if a robustness error occurs
* @throws IllegalArgumentException if the argument is a non-empty heterogeneous <code>GeometryCollection</code>
*/
public Geometry intersection(Geometry other) {
/**
* TODO: MD - add optimization for P-A case using Point-In-Polygon
*/
// special case: if one input is empty ==> empty
if (this.isEmpty() || other.isEmpty()) {
return OverlayOp.createEmptyResult(OverlayOp.INTERSECTION, this, other, this.factory);
}
// compute for GCs
if (this.isGeometryCollection()) {
final Geometry g2 = other;
return GeometryCollectionMapper.map(
(GeometryCollection) this,
g -> g.intersection(g2));
}
// if (isGeometryCollection(other))
// return other.intersection(this);
this.checkNotGeometryCollection(this);
this.checkNotGeometryCollection(other);
return SnapIfNeededOverlayOp.overlayOp(this, other, OverlayOp.INTERSECTION);
}
示例2: symDifference
import com.vividsolutions.jts.operation.overlay.OverlayOp; //导入依赖的package包/类
/**
* Computes a <coe>Geometry </code> representing the closure of the point-set
* which is the union of the points in this <code>Geometry</code> which are not
* contained in the <code>other</code> Geometry,
* with the points in the <code>other</code> Geometry not contained in this
* <code>Geometry</code>.
* If the result is empty, it is an atomic geometry
* with the dimension of the highest input dimension.
* <p>
* Non-empty {@link GeometryCollection} arguments are not supported.
*
* @param other the <code>Geometry</code> with which to compute the symmetric
* difference
* @return a Geometry representing the point-set symmetric difference of this <code>Geometry</code>
* with <code>other</code>
* @throws TopologyException if a robustness error occurs
* @throws IllegalArgumentException if either input is a non-empty GeometryCollection
*/
public Geometry symDifference(Geometry other) {
// handle empty geometry cases
if (this.isEmpty() || other.isEmpty()) {
// both empty - check dimensions
if (this.isEmpty() && other.isEmpty()) {
return OverlayOp.createEmptyResult(OverlayOp.SYMDIFFERENCE, this, other, this.factory);
}
// special case: if either input is empty ==> result = other arg
if (this.isEmpty()) {
return (Geometry) other.clone();
}
if (other.isEmpty()) {
return (Geometry) this.clone();
}
}
this.checkNotGeometryCollection(this);
this.checkNotGeometryCollection(other);
return SnapIfNeededOverlayOp.overlayOp(this, other, OverlayOp.SYMDIFFERENCE);
}
示例3: isValidResult
import com.vividsolutions.jts.operation.overlay.OverlayOp; //导入依赖的package包/类
private boolean isValidResult(int overlayOp, int[] location) {
boolean expectedInterior = OverlayOp.isResultOfOp(location[0], location[1], overlayOp);
boolean resultInInterior = (location[2] == Location.INTERIOR);
// MD use simpler: boolean isValid = (expectedInterior == resultInInterior);
boolean isValid = expectedInterior == resultInInterior;
if (!isValid) {
this.reportResult(overlayOp, location, expectedInterior);
}
return isValid;
}
示例4: isValidResult
import com.vividsolutions.jts.operation.overlay.OverlayOp; //导入依赖的package包/类
private boolean isValidResult(int overlayOp, int[] location) {
boolean expectedInterior = OverlayOp.isResultOfOp(location[0], location[1], overlayOp);
boolean resultInInterior = (location[2] == Location.INTERIOR);
// MD use simpler: boolean isValid = (expectedInterior == resultInInterior);
boolean isValid = !(expectedInterior ^ resultInInterior);
if (!isValid) reportResult(overlayOp, location, expectedInterior);
return isValid;
}
示例5: intersection
import com.vividsolutions.jts.operation.overlay.OverlayOp; //导入依赖的package包/类
/**
* Computes a <code>Geometry</code> representing the point-set which is
* common to both this <code>Geometry</code> and the <code>other</code> Geometry.
* <p/>
* 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 heterogenous {@link GeometryCollection}.
* If the result is empty, it is an atomic geometry
* with the dimension of the lowest input dimension.
* <p/>
* Intersection of {@link GeometryCollection}s is supported
* only for homogeneous collection types.
* <p/>
* Non-empty heterogeneous {@link GeometryCollection} arguments are not supported.
*
* @param other the <code>Geometry</code> with which to compute the intersection
* @return a Geometry representing the point-set common to the two <code>Geometry</code>s
* @throws TopologyException if a robustness error occurs
* @throws IllegalArgumentException if the argument is a non-empty heterogeneous <code>GeometryCollection</code>
*/
public Geometry intersection(Geometry other) {
/**
* TODO: MD - add optimization for P-A case using Point-In-Polygon
*/
// special case: if one input is empty ==> empty
if (this.isEmpty() || other.isEmpty())
return OverlayOp.createEmptyResult(OverlayOp.INTERSECTION, this, other, factory);
// compute for GCs
if (this.isGeometryCollection()) {
final Geometry g2 = other;
return GeometryCollectionMapper.map(
(GeometryCollection) this,
new GeometryMapper.MapOp() {
public Geometry map(Geometry g) {
return g.intersection(g2);
}
});
}
// if (isGeometryCollection(other))
// return other.intersection(this);
checkNotGeometryCollection(this);
checkNotGeometryCollection(other);
return SnapIfNeededOverlayOp.overlayOp(this, other, OverlayOp.INTERSECTION);
}
示例6: isValidResult
import com.vividsolutions.jts.operation.overlay.OverlayOp; //导入依赖的package包/类
private boolean isValidResult(int overlayOp, int[] location)
{
boolean expectedInterior = OverlayOp.isResultOfOp(location[0], location[1], overlayOp);
boolean resultInInterior = (location[2] == Location.INTERIOR);
// MD use simpler: boolean isValid = (expectedInterior == resultInInterior);
boolean isValid = ! (expectedInterior ^ resultInInterior);
if (! isValid) reportResult(overlayOp, location, expectedInterior);
return isValid;
}
示例7: getResultGeometry
import com.vividsolutions.jts.operation.overlay.OverlayOp; //导入依赖的package包/类
public Geometry getResultGeometry(int opCode)
{
// Geometry[] selfSnapGeom = new Geometry[] { selfSnap(geom[0]), selfSnap(geom[1])};
Geometry[] prepGeom = snap(geom);
Geometry result = OverlayOp.overlayOp(prepGeom[0], prepGeom[1], opCode);
return prepareResult(result);
}
示例8: intersection
import com.vividsolutions.jts.operation.overlay.OverlayOp; //导入依赖的package包/类
/**
* Computes a <code>Geometry</code> representing the point-set which is
* common to both this <code>Geometry</code> and the <code>other</code> Geometry.
* <p>
* 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 heterogenous {@link GeometryCollection}.
* If the result is empty, it is an atomic geometry
* with the dimension of the lowest input dimension.
* <p>
* Intersection of {@link GeometryCollection}s is supported
* only for homogeneous collection types.
* <p>
* Non-empty heterogeneous {@link GeometryCollection} arguments are not supported.
*
* @param other the <code>Geometry</code> with which to compute the intersection
* @return a Geometry representing the point-set common to the two <code>Geometry</code>s
* @throws TopologyException if a robustness error occurs
* @throws IllegalArgumentException if the argument is a non-empty heterogeneous <code>GeometryCollection</code>
*/
public Geometry intersection(Geometry other)
{
/**
* TODO: MD - add optimization for P-A case using Point-In-Polygon
*/
// special case: if one input is empty ==> empty
if (this.isEmpty() || other.isEmpty())
return OverlayOp.createEmptyResult(OverlayOp.INTERSECTION, this, other, factory);
// compute for GCs
if (this.isGeometryCollection()) {
final Geometry g2 = other;
return GeometryCollectionMapper.map(
(GeometryCollection) this,
new GeometryMapper.MapOp() {
public Geometry map(Geometry g) {
return g.intersection(g2);
}
});
}
// if (isGeometryCollection(other))
// return other.intersection(this);
checkNotGeometryCollection(this);
checkNotGeometryCollection(other);
return SnapIfNeededOverlayOp.overlayOp(this, other, OverlayOp.INTERSECTION);
}
示例9: getIntersection
import com.vividsolutions.jts.operation.overlay.OverlayOp; //导入依赖的package包/类
public List<String> getIntersection(final List<String> wktLayer1,
final List<String> wktLayer2) {
return getOverlay(wktLayer1, wktLayer2, OverlayOp.INTERSECTION);
}
示例10: getDifference
import com.vividsolutions.jts.operation.overlay.OverlayOp; //导入依赖的package包/类
public List<String> getDifference(final List<String> wktLayer1,
final List<String> wktLayer2) {
return getOverlay(wktLayer1, wktLayer2, OverlayOp.DIFFERENCE);
}
示例11: getSymDifference
import com.vividsolutions.jts.operation.overlay.OverlayOp; //导入依赖的package包/类
public List<String> getSymDifference(final List<String> wktLayer1,
final List<String> wktLayer2) {
return getOverlay(wktLayer1, wktLayer2, OverlayOp.SYMDIFFERENCE);
}
示例12: getOverlay
import com.vividsolutions.jts.operation.overlay.OverlayOp; //导入依赖的package包/类
public List<String> getOverlay(final Geometry layer1,
final Geometry layer2, final int op) {
final List<String> resultLayer = new ArrayList<String>();
Geometry geomContorno = null;
switch (op) {
case OverlayOp.INTERSECTION:
geomContorno = EnhancedPrecisionOp.intersection(
layer1.buffer(TOLERANCIA), layer2.buffer(TOLERANCIA));
break;
case OverlayOp.DIFFERENCE:
geomContorno = EnhancedPrecisionOp.difference(
layer1.buffer(TOLERANCIA), layer2.buffer(TOLERANCIA));
break;
case OverlayOp.SYMDIFFERENCE:
geomContorno = EnhancedPrecisionOp.symDifference(
layer1.buffer(TOLERANCIA), layer2.buffer(TOLERANCIA));
break;
default:
break;
}
if (geomContorno != null) {
if (geomContorno instanceof Polygon) {
resultLayer.add(geomContorno.toText());
} else if (geomContorno instanceof MultiPolygon) {
final MultiPolygon multiPolygon = (MultiPolygon) geomContorno;
for (int i = 0; i < multiPolygon.getNumGeometries(); i++) {
final Polygon pol = (Polygon) multiPolygon.getGeometryN(i);
resultLayer.add(pol.toText());
}
} else if (geomContorno instanceof GeometryCollection) {
final GeometryCollection gc = (GeometryCollection) geomContorno;
for (int i = 0; i < gc.getNumGeometries(); i++) {
final Geometry geom = gc.getGeometryN(i);
resultLayer.add(geom.toText());
}
}
}
return resultLayer;
}
示例13: intersection
import com.vividsolutions.jts.operation.overlay.OverlayOp; //导入依赖的package包/类
public static Geometry intersection(Geometry g0, Geometry g1) {
return overlayOp(g0, g1, OverlayOp.INTERSECTION);
}
示例14: union
import com.vividsolutions.jts.operation.overlay.OverlayOp; //导入依赖的package包/类
public static Geometry union(Geometry g0, Geometry g1) {
return overlayOp(g0, g1, OverlayOp.UNION);
}
示例15: difference
import com.vividsolutions.jts.operation.overlay.OverlayOp; //导入依赖的package包/类
public static Geometry difference(Geometry g0, Geometry g1) {
return overlayOp(g0, g1, OverlayOp.DIFFERENCE);
}