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


Java Geometry.intersection方法代碼示例

本文整理匯總了Java中com.vividsolutions.jts.geom.Geometry.intersection方法的典型用法代碼示例。如果您正苦於以下問題:Java Geometry.intersection方法的具體用法?Java Geometry.intersection怎麽用?Java Geometry.intersection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.vividsolutions.jts.geom.Geometry的用法示例。


在下文中一共展示了Geometry.intersection方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: flatIntersection

import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
/**
 * JTS 1.14 does not support intersection on a {@link GeometryCollection}. This function works
 * around this by performing intersection on a flat list of geometry. The resulting list is
 * pre-filtered for invalid or empty geometry (outside of bounds). Invalid geometry are logged as
 * errors.
 *
 * @param envelope  non-list geometry defines bounding area
 * @param dataGeoms geometry pre-passed through {@link #flatFeatureList(Geometry)}
 * @return list of geometry from {@code data} intersecting with {@code envelope}.
 */
private static List<Geometry> flatIntersection(Geometry envelope, List<Geometry> dataGeoms) {
  final List<Geometry> intersectedGeoms = new ArrayList<>(dataGeoms.size());

  Geometry nextIntersected;
  for (Geometry nextGeom : dataGeoms) {
    try {

      // AABB intersection culling
      if (envelope.getEnvelopeInternal().intersects(nextGeom.getEnvelopeInternal())) {

        nextIntersected = envelope.intersection(nextGeom);
        if (!nextIntersected.isEmpty()) {
          nextIntersected.setUserData(nextGeom.getUserData());
          intersectedGeoms.add(nextIntersected);
        }
      }

    } catch (TopologyException ex) {
      LoggerFactory.getLogger(JtsAdapter.class).error(ex.getMessage(), ex);
    }
  }

  return intersectedGeoms;
}
 
開發者ID:OrdnanceSurvey,項目名稱:vt-support,代碼行數:35,代碼來源:JtsAdapter.java

示例2: computeIntersection

import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的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

示例3: computeIntersection

import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的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


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