概述
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方法代码示例所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复