本文整理汇总了Java中com.vividsolutions.jts.geom.Envelope.intersects方法的典型用法代码示例。如果您正苦于以下问题:Java Envelope.intersects方法的具体用法?Java Envelope.intersects怎么用?Java Envelope.intersects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.vividsolutions.jts.geom.Envelope
的用法示例。
在下文中一共展示了Envelope.intersects方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: unionOptimized
import com.vividsolutions.jts.geom.Envelope; //导入方法依赖的package包/类
private Geometry unionOptimized(Geometry g0, Geometry g1) {
Envelope g0Env = g0.getEnvelopeInternal();
Envelope g1Env = g1.getEnvelopeInternal();
//*
if (!g0Env.intersects(g1Env)) {
Geometry combo = GeometryCombiner.combine(g0, g1);
// System.out.println("Combined");
// System.out.println(combo);
return combo;
}
//*/
// System.out.println(g0.getNumGeometries() + ", " + g1.getNumGeometries());
if (g0.getNumGeometries() <= 1 && g1.getNumGeometries() <= 1) {
return this.unionActual(g0, g1);
}
// for testing...
// if (true) return g0.union(g1);
Envelope commonEnv = g0Env.intersection(g1Env);
return this.unionUsingEnvelopeIntersection(g0, g1, commonEnv);
// return UnionInteracting.union(g0, g1);
}
示例2: getFeatures
import com.vividsolutions.jts.geom.Envelope; //导入方法依赖的package包/类
public List<TrafficFeatureInfo> getFeatures(Envelope env)
{
if (env == null)
return features;
if (quadTree == null)
buildQuadTree();
List<TrafficFeatureInfo> list = quadTree.query(env);
List<TrafficFeatureInfo> result = new ArrayList<TrafficFeatureInfo>(list.size());
for(TrafficFeatureInfo tfi : list)
{
Envelope fe = tfi.getEnvelope();
if (fe != null && fe.intersects(env))
result.add(tfi);
}
return result;
}
示例3: clipGeometryCollection
import com.vividsolutions.jts.geom.Envelope; //导入方法依赖的package包/类
private static Geometry clipGeometryCollection(Geometry geom, Envelope clipEnv) {
Geometry clipPoly = geom.getFactory().toGeometry(clipEnv);
List clipped = new ArrayList();
for (int i = 0; i < geom.getNumGeometries(); i++) {
Geometry g = geom.getGeometryN(i);
Geometry result = null;
// don't clip unless necessary
if (clipEnv.contains(g.getEnvelopeInternal())) {
result = g;
} else if (clipEnv.intersects(g.getEnvelopeInternal())) {
result = clipPoly.intersection(g);
// keep vertex key info
result.setUserData(g.getUserData());
}
if (result != null && !result.isEmpty()) {
clipped.add(result);
}
}
return geom.getFactory().createGeometryCollection(GeometryFactory.toGeometryArray(clipped));
}
示例4: computeIntersection
import com.vividsolutions.jts.geom.Envelope; //导入方法依赖的package包/类
private static List<IsochronesIntersection> computeIntersection(Isochrone isoLine, Integer isoIndex, IsochroneMap isoMap, Integer isoMapIndex, IsochroneMapCollection isochroneMaps, List<Integer> processedPairs)
{
List<IsochronesIntersection> result = null;
Envelope isoEnvelope = isoLine.getEnvelope();
Geometry isoGeometry = isoLine.getGeometry();
for (int im = isoMapIndex + 1; im < isochroneMaps.size(); im++)
{
IsochroneMap isoMap2 = isochroneMaps.getIsochrone(im);
if (!Objects.equals(isoMap2, isoMap) && isoMap2.getEnvelope().intersects(isoEnvelope))
{
int ii = 0;
for (Isochrone isoLine2 : isoMap2.getIsochrones())
{
if (isoEnvelope.intersects(isoLine2.getEnvelope()))
{
Geometry geomIntersection = isoGeometry.intersection(isoLine2.getGeometry());
if (geomIntersection != null && geomIntersection.isEmpty() == false)
{
if (result == null)
result = new ArrayList<IsochronesIntersection>();
IsochronesIntersection isoIntersection = new IsochronesIntersection(geomIntersection);
isoIntersection.addContourRefs(new Pair<Integer, Integer>(isoMapIndex, isoIndex));
isoIntersection.addContourRefs(new Pair<Integer, Integer>(im, ii));
result.add(isoIntersection);
}
}
ii++;
}
}
}
return result;
}
示例5: computeIntersection
import com.vividsolutions.jts.geom.Envelope; //导入方法依赖的package包/类
public Geometry computeIntersection()
{
if (_isochroneMaps.size() == 0)
return null;
if (_isochroneMaps.size() == 1)
return _isochroneMaps.get(0).getIsochrone(0).getGeometry();
Isochrone iso = _isochroneMaps.get(0).getIsochrone(0);
Geometry geomIntersection = iso.getGeometry();
Envelope envIntersection = iso.getEnvelope();
for (int i = 1; i < _isochroneMaps.size(); ++i)
{
iso = _isochroneMaps.get(i).getIsochrone(0);
if (envIntersection.intersects(iso.getEnvelope()))
{
geomIntersection = geomIntersection.intersection(iso.getGeometry());
if (geomIntersection == null || geomIntersection.isEmpty())
return null;
}
else
return null;
}
return geomIntersection;
}
示例6: visitItem
import com.vividsolutions.jts.geom.Envelope; //导入方法依赖的package包/类
@Override
public void visitItem(Object item) {
LineSegment seg = (LineSegment) item;
if (Envelope.intersects(seg.p0, seg.p1, this.querySeg.p0, this.querySeg.p1)) {
this.items.add(item);
}
}
示例7: computeIntersection
import com.vividsolutions.jts.geom.Envelope; //导入方法依赖的package包/类
@Override
public void computeIntersection(Coordinate p, Coordinate p1, Coordinate p2) {
this.isProper = false;
// do between check first, since it is faster than the orientation test
if (Envelope.intersects(p1, p2, p)) {
if ((CGAlgorithms.orientationIndex(p1, p2, p) == 0)
&& (CGAlgorithms.orientationIndex(p2, p1, p) == 0)) {
isProper = !(p.equals(p1) || p.equals(p2));
this.result = POINT_INTERSECTION;
return;
}
}
this.result = NO_INTERSECTION;
}
示例8: computeCollinearIntersection
import com.vividsolutions.jts.geom.Envelope; //导入方法依赖的package包/类
private int computeCollinearIntersection(Coordinate p1, Coordinate p2,
Coordinate q1, Coordinate q2) {
boolean p1q1p2 = Envelope.intersects(p1, p2, q1);
boolean p1q2p2 = Envelope.intersects(p1, p2, q2);
boolean q1p1q2 = Envelope.intersects(q1, q2, p1);
boolean q1p2q2 = Envelope.intersects(q1, q2, p2);
if (p1q1p2 && p1q2p2) {
this.intPt[0] = q1;
this.intPt[1] = q2;
return COLLINEAR_INTERSECTION;
}
if (q1p1q2 && q1p2q2) {
this.intPt[0] = p1;
this.intPt[1] = p2;
return COLLINEAR_INTERSECTION;
}
if (p1q1p2 && q1p1q2) {
this.intPt[0] = q1;
this.intPt[1] = p1;
return q1.equals(p1) && !p1q2p2 && !q1p2q2 ? POINT_INTERSECTION : COLLINEAR_INTERSECTION;
}
if (p1q1p2 && q1p2q2) {
this.intPt[0] = q1;
this.intPt[1] = p2;
return q1.equals(p2) && !p1q2p2 && !q1p1q2 ? POINT_INTERSECTION : COLLINEAR_INTERSECTION;
}
if (p1q2p2 && q1p1q2) {
this.intPt[0] = q2;
this.intPt[1] = p1;
return q2.equals(p1) && !p1q1p2 && !q1p2q2 ? POINT_INTERSECTION : COLLINEAR_INTERSECTION;
}
if (p1q2p2 && q1p2q2) {
this.intPt[0] = q2;
this.intPt[1] = p2;
return q2.equals(p2) && !p1q1p2 && !q1p1q2 ? POINT_INTERSECTION : COLLINEAR_INTERSECTION;
}
return NO_INTERSECTION;
}
示例9: computeSelect
import com.vividsolutions.jts.geom.Envelope; //导入方法依赖的package包/类
private void computeSelect(
Envelope searchEnv,
int start0, int end0,
MonotoneChainSelectAction mcs) {
Coordinate p0 = this.pts[start0];
Coordinate p1 = this.pts[end0];
mcs.tempEnv1.init(p0, p1);
//Debug.println("trying:" + p0 + p1 + " [ " + start0 + ", " + end0 + " ]");
// terminating condition for the recursion
if (end0 - start0 == 1) {
//Debug.println("computeSelect:" + p0 + p1);
mcs.select(this, start0);
return;
}
// nothing to do if the envelopes don't overlap
if (!searchEnv.intersects(mcs.tempEnv1)) {
return;
}
// the chains overlap, so split each in half and iterate (binary search)
int mid = (start0 + end0) / 2;
// Assert: mid != start or end (since we checked above for end - start <= 1)
// check terminating conditions before recursing
if (start0 < mid) {
this.computeSelect(searchEnv, start0, mid, mcs);
}
if (mid < end0) {
this.computeSelect(searchEnv, mid, end0, mcs);
}
}
示例10: distanceLineLine
import com.vividsolutions.jts.geom.Envelope; //导入方法依赖的package包/类
/**
* Computes the distance from a line segment AB to a line segment CD
* <p>
* Note: NON-ROBUST!
*
* @param A a point of one line
* @param B the second point of (must be different to A)
* @param C one point of the line
* @param D another point of the line (must be different to A)
*/
public static double distanceLineLine(Coordinate A, Coordinate B,
Coordinate C, Coordinate D) {
// check for zero-length segments
if (A.equals(B)) {
return distancePointLine(A, C, D);
}
if (C.equals(D)) {
return distancePointLine(D, A, B);
}
// AB and CD are line segments
/*
* from comp.graphics.algo
*
* Solving the above for r and s yields
*
* (Ay-Cy)(Dx-Cx)-(Ax-Cx)(Dy-Cy)
* r = ----------------------------- (eqn 1)
* (Bx-Ax)(Dy-Cy)-(By-Ay)(Dx-Cx)
*
* (Ay-Cy)(Bx-Ax)-(Ax-Cx)(By-Ay)
* s = ----------------------------- (eqn 2)
* (Bx-Ax)(Dy-Cy)-(By-Ay)(Dx-Cx)
*
* Let P be the position vector of the
* intersection point, then
* P=A+r(B-A) or
* Px=Ax+r(Bx-Ax)
* Py=Ay+r(By-Ay)
* By examining the values of r & s, you can also determine some other limiting
* conditions:
* If 0<=r<=1 & 0<=s<=1, intersection exists
* r<0 or r>1 or s<0 or s>1 line segments do not intersect
* If the denominator in eqn 1 is zero, AB & CD are parallel
* If the numerator in eqn 1 is also zero, AB & CD are collinear.
*/
boolean noIntersection = false;
if (!Envelope.intersects(A, B, C, D)) {
noIntersection = true;
} else {
double denom = (B.x - A.x) * (D.y - C.y) - (B.y - A.y) * (D.x - C.x);
if (denom == 0) {
noIntersection = true;
} else {
double r_num = (A.y - C.y) * (D.x - C.x) - (A.x - C.x) * (D.y - C.y);
double s_num = (A.y - C.y) * (B.x - A.x) - (A.x - C.x) * (B.y - A.y);
double s = s_num / denom;
double r = r_num / denom;
if ((r < 0) || (r > 1) || (s < 0) || (s > 1)) {
noIntersection = true;
}
}
}
if (noIntersection) {
return MathUtil.min(
distancePointLine(A, C, D),
distancePointLine(B, C, D),
distancePointLine(C, A, B),
distancePointLine(D, A, B));
}
// segments intersect
return 0.0;
}