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


Java Geometry.getNumGeometries方法代碼示例

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


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

示例1: convexHullOneLevel

import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
private static Geometry convexHullOneLevel(final Geometry geometry)
{
   if (geometry.getNumGeometries() > 1)
   {
      Geometry [] convex_hulls = new Geometry [geometry.getNumGeometries()];
      for (int igeom=0; igeom<geometry.getNumGeometries(); igeom++)
      {
         convex_hulls[igeom] = geometry.getGeometryN(igeom).convexHull();
      }
      return
         geometry.getFactory().createGeometryCollection(convex_hulls);
   }
   else
   {
      return geometry.convexHull();
   }
}
 
開發者ID:SentinelDataHub,項目名稱:dhus-core,代碼行數:18,代碼來源:NominatimGeocoder.java

示例2: polyStats

import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
private static FeatureStats polyStats(Geometry geom) {
  final FeatureStats featureStats = new FeatureStats();

  for (int i = 0; i < geom.getNumGeometries(); ++i) {
    final Polygon nextPoly = (Polygon) geom.getGeometryN(i);

    // Stats: exterior ring
    final LineString exteriorRing = nextPoly.getExteriorRing();
    featureStats.totalPts += exteriorRing.getNumPoints();
    featureStats.repeatedPts += checkRepeatedPoints2d(exteriorRing);

    // Stats: interior rings
    for (int ringIndex = 0; ringIndex < nextPoly.getNumInteriorRing(); ++ringIndex) {

      final LineString nextInteriorRing = nextPoly.getInteriorRingN(ringIndex);
      featureStats.totalPts += nextInteriorRing.getNumPoints();
      featureStats.repeatedPts += checkRepeatedPoints2d(nextInteriorRing);
    }
  }

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

示例3: splitMultiPolygons

import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
private void splitMultiPolygons(){
	List<Geometry>clone=new ArrayList<>(maskGeometries);
	for(Geometry gt:clone){
		if(gt instanceof MultiPolygon){
			int n=gt.getNumGeometries();
			for(int i=0;i<n;i++){
				Polygon pp=(Polygon)gt.getGeometryN(i);
				maskGeometries.add(pp);
			}
			maskGeometries.remove(gt);
		}
	}
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:14,代碼來源:MaskGeometries.java

示例4: splitMultiPolygons

import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
/**
    * 
    */
   public void splitMultiPolygons(){
	List<Geometry>clone=new ArrayList<>(this.geoms);
	for(Geometry gt:clone){
		if(gt instanceof MultiPolygon){
			int n=gt.getNumGeometries();
			for(int i=0;i<n;i++){
				Polygon pp=(Polygon)gt.getGeometryN(i);
				put(pp,(AttributesGeometry)pp.getUserData());
			}
			geoms.remove(gt);
		}
	}
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:17,代碼來源:GeometryImage.java

示例5: polygonsFrom

import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
public static Stream<Polygon> polygonsFrom(Geometry g) {
    if (g instanceof Polygon) {
        return Stream.of((Polygon) g);
    }
    else if (g instanceof MultiPolygon) {
        Builder<Polygon> builder = Stream.builder();
        for (int i = 0; i < g.getNumGeometries(); i++) {
            builder.add((Polygon) g.getGeometryN(i));
        }
        return builder.build();
    }
    return Stream.empty();
}
 
開發者ID:Mappy,項目名稱:fpm,代碼行數:14,代碼來源:PolygonsUtils.java

示例6: flatFeatureList

import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
/**
 * <p>Recursively convert a {@link Geometry}, which may be an instance of
 * {@link GeometryCollection} with mixed
 * element types, into a flat list containing only the following {@link Geometry} types:</p>
 * <ul>
 * <li>{@link Point}</li>
 * <li>{@link LineString}</li>
 * <li>{@link Polygon}</li>
 * <li>{@link MultiPoint}</li>
 * <li>{@link MultiLineString}</li>
 * <li>{@link MultiPolygon}</li>
 * </ul>
 * <p>WARNING: Any other Geometry types that were not mentioned in the list above will be
 * discarded!</p>
 * <p>Useful for converting a generic geometry into a list of simple MVT-feature-ready
 * geometries.</p>
 *
 * @param geom geometry to flatten
 * @return list of MVT-feature-ready geometries
 */
public static List<Geometry> flatFeatureList(Geometry geom) {
  final List<Geometry> singleGeoms = new ArrayList<>();
  final Stack<Geometry> geomStack = new Stack<>();

  Geometry nextGeom;
  int nextGeomCount;

  geomStack.push(geom);
  while (!geomStack.isEmpty()) {
    nextGeom = geomStack.pop();

    if (nextGeom instanceof Point
        || nextGeom instanceof MultiPoint
        || nextGeom instanceof LineString
        || nextGeom instanceof MultiLineString
        || nextGeom instanceof Polygon
        || nextGeom instanceof MultiPolygon) {

      singleGeoms.add(nextGeom);

    } else if (nextGeom instanceof GeometryCollection) {

      // Push all child geometries
      nextGeomCount = nextGeom.getNumGeometries();
      for (int i = 0; i < nextGeomCount; ++i) {
        geomStack.push(nextGeom.getGeometryN(i));
      }

    }
  }

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

示例7: pointStats

import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
private static FeatureStats pointStats(Geometry geom) {
  final FeatureStats featureStats = new FeatureStats();

  final HashSet<Point> pointSet = new HashSet<>(geom.getNumPoints());
  featureStats.totalPts = geom.getNumPoints();

  for (int i = 0; i < geom.getNumGeometries(); ++i) {
    final Point p = (Point) geom.getGeometryN(i);
    featureStats.repeatedPts += pointSet.add(p) ? 0 : 1;
  }

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

示例8: lineStats

import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
private static FeatureStats lineStats(Geometry geom) {
  final FeatureStats featureStats = new FeatureStats();

  for (int i = 0; i < geom.getNumGeometries(); ++i) {
    final LineString lineString = (LineString) geom.getGeometryN(i);
    featureStats.totalPts += lineString.getNumPoints();
    featureStats.repeatedPts += checkRepeatedPoints2d(lineString);
  }

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

示例9: smoothMultiLineString

import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
private static Geometry smoothMultiLineString(GeometryFactory factory,
        GeometrySmoother smoother, Geometry geom, double fit) {

    final int N = geom.getNumGeometries();
    LineString[] smoothed = new LineString[N];

    for (int i = 0; i < N; i++) {
        smoothed[i] = (LineString) smoothLineString(factory, smoother, geom.getGeometryN(i),
                fit);
    }

    return factory.createMultiLineString(smoothed);
}
 
開發者ID:GIScience,項目名稱:openrouteservice,代碼行數:14,代碼來源:JTS.java

示例10: smoothMultiPolygon

import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
private static Geometry smoothMultiPolygon(GeometryFactory factory, GeometrySmoother smoother,
        Geometry geom, double fit) {

    final int N = geom.getNumGeometries();
    Polygon[] smoothed = new Polygon[N];

    for (int i = 0; i < N; i++) {
        smoothed[i] = smoother.smooth((Polygon) geom.getGeometryN(i), fit);
    }

    return factory.createMultiPolygon(smoothed);
}
 
開發者ID:GIScience,項目名稱:openrouteservice,代碼行數:13,代碼來源:JTS.java

示例11: smoothGeometryCollection

import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
private static Geometry smoothGeometryCollection(GeometryFactory factory,
        GeometrySmoother smoother, Geometry geom, double fit) {

    final int N = geom.getNumGeometries();
    Geometry[] smoothed = new Geometry[N];

    for (int i = 0; i < N; i++) {
        smoothed[i] = smooth(geom.getGeometryN(i), fit, factory, smoother);
    }

    return factory.createGeometryCollection(smoothed);
}
 
開發者ID:GIScience,項目名稱:openrouteservice,代碼行數:13,代碼來源:JTS.java

示例12: simplifyGeometry

import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
private static Geometry simplifyGeometry(final Geometry input_geometry,
      final int max_output_points, final double cluster_factor)
{
   // Return null if the input geometry is null
   if (input_geometry == null)
   {
      return null;
   }

   // Return the input geometry if the number of points is already lower
   // or equal to the maximum allowed
   if (input_geometry.getNumPoints() <= max_output_points)
   {
      return input_geometry;
   }

   // Assign local geometry to refine
   Geometry geometry = input_geometry;

   if (geometry.getNumGeometries() > 1)
   {
      geometry = convexHullOneLevel(geometry).union();
      geometry = clusterizeGeometry(geometry, cluster_factor);
   }

   int current_point_number = geometry.getNumPoints();
   int previous_point_number = -1;

   int iteration_count = 0;

   double tolerance = 0.005;

   while ((current_point_number > max_output_points) &&
          (iteration_count < 10))
   {
      previous_point_number = current_point_number;
      current_point_number = geometry.getNumPoints();
      if (current_point_number == previous_point_number)
      {
         iteration_count += 1;
      }
      else
      {
         iteration_count = 0;
      }

      geometry =
         TopologyPreservingSimplifier.simplify(geometry,
               tolerance);

      tolerance += 0.005;
   }

   return geometry;
}
 
開發者ID:SentinelDataHub,項目名稱:dhus-core,代碼行數:56,代碼來源:NominatimGeocoder.java

示例13: clusterizeGeometry

import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類
private static Geometry clusterizeGeometry(final Geometry geometry,
      final double distance_ratio)
{
   if (geometry == null)
   {
      return null;
   }

   int number_geometries = geometry.getNumGeometries();

   if (number_geometries > 1)
   {
      Geometry [] clustered_geometries =
         new Geometry [number_geometries];

      for (int igeom=0; igeom<number_geometries-1; igeom++)
      {
         Geometry current_geometry = geometry.getGeometryN(igeom);
         Point current_centroid = current_geometry.getCentroid();

         if ((current_geometry == null) ||
             (current_centroid == null))
         {
            // TODO Warning
            continue;
         }

         ArrayList<Geometry> current_cluster = new ArrayList<Geometry>();

         current_cluster.add(current_geometry);

         for (int jgeom=igeom+1; jgeom<number_geometries; jgeom++)
         {
            Geometry next_geometry = geometry.getGeometryN(jgeom);
            Point next_centroid = next_geometry.getCentroid();

            if ((next_geometry == null) ||
                (next_centroid == null))
            {
               // TODO Warning
               continue;
            }

            double distance = current_geometry.distance(next_geometry);
            double centroids_distance =
               current_centroid.distance(next_centroid);

            if (distance < (centroids_distance * distance_ratio))
            {
               current_cluster.add(next_geometry);
            }
         }

         Geometry [] current_cluster_array =
               new Geometry [current_cluster.size()];

         clustered_geometries[igeom] =
            geometry.getFactory().createGeometryCollection(
               current_cluster.toArray(current_cluster_array));
      }

      clustered_geometries[number_geometries-1] =
         geometry.getGeometryN(number_geometries-1);

      return convexHullOneLevel(
         geometry.getFactory().createGeometryCollection(
            clustered_geometries)).union();
   }
   else
   {
      return geometry;
   }
}
 
開發者ID:SentinelDataHub,項目名稱:dhus-core,代碼行數:74,代碼來源:NominatimGeocoder.java


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