當前位置: 首頁>>代碼示例>>Java>>正文


Java Envelope.intersects方法代碼示例

本文整理匯總了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);
    }
 
開發者ID:gegy1000,項目名稱:Earth,代碼行數:26,代碼來源:CascadedPolygonUnion.java

示例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;
}
 
開發者ID:GIScience,項目名稱:openrouteservice,代碼行數:21,代碼來源:RealTrafficDataProvider.java

示例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));
}
 
開發者ID:gegy1000,項目名稱:Earth,代碼行數:22,代碼來源:VoronoiDiagramBuilder.java

示例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;
}
 
開發者ID:GIScience,項目名稱:openrouteservice,代碼行數:39,代碼來源:IsochroneUtility.java

示例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;
}
 
開發者ID:GIScience,項目名稱:openrouteservice,代碼行數:28,代碼來源:IsochroneMapCollection.java

示例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);
    }
}
 
開發者ID:gegy1000,項目名稱:Earth,代碼行數:8,代碼來源:LineSegmentIndex.java

示例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;
}
 
開發者ID:gegy1000,項目名稱:Earth,代碼行數:15,代碼來源:RobustLineIntersector.java

示例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;
}
 
開發者ID:gegy1000,項目名稱:Earth,代碼行數:40,代碼來源:RobustLineIntersector.java

示例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);
        }
    }
 
開發者ID:gegy1000,項目名稱:Earth,代碼行數:33,代碼來源:MonotoneChain.java

示例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;
}
 
開發者ID:gegy1000,項目名稱:Earth,代碼行數:78,代碼來源:CGAlgorithms.java


注:本文中的com.vividsolutions.jts.geom.Envelope.intersects方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。