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


Java Geometry.isEmpty方法代碼示例

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


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

示例1: checkGMLFootprint

import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
/**
 * Check GML Footprint validity
 */
public static boolean checkGMLFootprint (String footprint)
{
   try
   {
      Configuration configuration = new GMLConfiguration ();
      Parser parser = new Parser (configuration);

      Geometry geom =
            (Geometry) parser.parse (new InputSource (
                  new StringReader (footprint)));
      if (!geom.isEmpty() && !geom.isValid())
      {
         LOGGER.error("Wrong footprint");
         return false;
      }
   }
   catch (Exception e)
   {
      LOGGER.error("Error in extracted footprint: " + e.getMessage());
      return false;
   }
   return true;
}
 
開發者ID:SentinelDataHub,項目名稱:dhus-core,代碼行數:27,代碼來源:ProcessingUtils.java

示例2: 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

示例3: createFeature

import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
public Feature createFeature(String id, Geometry geometry, SimpleFeatureType featureType) {

        if (geometry == null || geometry.isEmpty()) {
            return null;
        }

        SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(featureType);
        SimpleFeature feature = null;

        Object[] newData = new Object[featureType.getDescriptors().size()];

        int i = 0;

        if (geometry.getGeometryType().equals("Point")) {
            Point[] points = new Point[1];
            points[0] = (Point) geometry;
            newData[i] = geometry.getFactory().createMultiPoint(points);
        } else if (geometry.getGeometryType().equals("LineString")) {
            LineString[] lineString = new LineString[1];
            lineString[0] = (LineString) geometry;
            newData[i] = geometry.getFactory().createMultiLineString(lineString);
        } else if (geometry.getGeometryType().equals("Polygon")) {
            Polygon[] polygons = new Polygon[1];
            polygons[0] = (Polygon) geometry;
            newData[i] = geometry.getFactory().createMultiPolygon(polygons);
        } else {
            newData[i] = geometry;
        }

        feature = featureBuilder.buildFeature(id, newData);

        return feature;
    }
 
開發者ID:52North,項目名稱:javaps-geotools-backend,代碼行數:34,代碼來源:GTHelper.java

示例4: extractPoint

import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
public Geometry extractPoint(final Collection<Geometry> lines) {
	Geometry point = null;
	for (final Iterator<Geometry> i = lines.iterator(); i.hasNext();) {
		final Geometry geometry = i.next();
		if (!geometry.isEmpty()) {
			point = geometry.getFactory().createPoint(geometry.getCoordinate());
		}
	}
	return point;
}
 
開發者ID:geowe,項目名稱:sig-seguimiento-vehiculos,代碼行數:11,代碼來源:LineNoder.java

示例5: 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

示例6: 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

示例7: validate

import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
private void validate(final Geometry geom, final List<ValidationResult> validationErrors) {
	
	if (geom.isEmpty()) {
		return;
	}

	if (geom instanceof GeometryCollection) {
		final GeometryCollection gc = (GeometryCollection) geom;
		for (int numGeom = 0; numGeom < gc.getNumGeometries(); numGeom++) {
			validate(gc.getGeometryN(numGeom), validationErrors);
		}
	}

	final ValidationResult result = new ValidationResult();
	result.setWkt(geom.toText());
	final List<String> messages = new ArrayList<String>();
	
	if (!geom.isValid()) {
		messages.add("Error en topología básica");
	}

	if (!geom.isSimple()) {
		messages.add("No es una geometría simple");
	}

	if (repeatedPointTester.hasRepeatedPoint(geom)) {
		messages.add("Se encuentran vértices repetidos");
	}

	if (geom instanceof Polygon) {
		final Polygon polygon = (Polygon) geom;
		if (CGAlgorithms.isCCW(polygon.getExteriorRing().getCoordinates())) {
			messages.add("Error en orientación del polígono");
		} else {

			for (int numRing = 0; numRing < polygon.getNumInteriorRing(); numRing++) {
				if (!CGAlgorithms.isCCW(polygon.getInteriorRingN(numRing).getCoordinates())) {
					messages.add("Error en orientación del polígono en anillos interiores");
					break;
				}
			}
		}

		if (!validateMinPolygonArea(geom)) {
			messages.add("Error en validación mínima de area de un polígono");
		}
	}

	if (!validateMinSegmentLength(geom)) {
		messages.add("Error en validación mínima de longitud de segmento. Coordenadas");
		result.setErrorsPoints(errorCoordinates);
	}


	if(!messages.isEmpty()) {
		result.setMessages(messages);
		validationErrors.add(result);
	}		
}
 
開發者ID:geowe,項目名稱:sig-seguimiento-vehiculos,代碼行數:60,代碼來源:GeometryValidator.java


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