当前位置: 首页>>代码示例>>Java>>正文


Java Point.distance方法代码示例

本文整理汇总了Java中com.vividsolutions.jts.geom.Point.distance方法的典型用法代码示例。如果您正苦于以下问题:Java Point.distance方法的具体用法?Java Point.distance怎么用?Java Point.distance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.vividsolutions.jts.geom.Point的用法示例。


在下文中一共展示了Point.distance方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: clusterizeGeometry

import com.vividsolutions.jts.geom.Point; //导入方法依赖的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.Point.distance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。