我是靠谱客的博主 幽默航空,最近开发中收集的这篇文章主要介绍java geom_Java Geometry.distance方法代码示例,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

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

{

Geometry current_geometry = geometry.getGeometryN(igeom);

Point current_centroid = current_geometry.getCentroid();

if ((current_geometry == null) ||

(current_centroid == null))

{

// TODO Warning

continue;

}

ArrayList current_cluster = new ArrayList();

current_cluster.add(current_geometry);

for (int jgeom=igeom+1; 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;

}

}

最后

以上就是幽默航空为你收集整理的java geom_Java Geometry.distance方法代码示例的全部内容,希望文章能够帮你解决java geom_Java Geometry.distance方法代码示例所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(61)

评论列表共有 0 条评论

立即
投稿
返回
顶部