首页 > 代码库 > Java调用AE实现创建泰森多边形(voronoi图)

Java调用AE实现创建泰森多边形(voronoi图)

在网上搜索 AE 创建泰森多边形,都是基于VB或者C#的,

鉴于C#和Java相近,就将C#的代码翻译成Java,

但修改后的程序运行无结果,

经多次尝试,设置了addFromFeatureClass方法的第三个参数,终于获得了泰森多边形。

现把代码共享,如下:

 

 

public void CreatVoronoi(IFeatureClass pointFeaCls,IFeatureClass voronoiFeaCls,IPolygon clippingPolygon){    try {   if (pointFeaCls.getShapeType() == esriGeometryType.esriGeometryPoint)   {    if(pointFeaCls.featureCount(null)>2)    {            //      FeatureClass fc=new FeatureClass(pointFeaCls);            IEnvelope pEnv =clippingPolygon.getEnvelope();// (IEnvelope)fc.getExtent();      pEnv.setSpatialReferenceByRef(clippingPolygon.getSpatialReference());      ITinEdit pTinEdit = new Tin();      pTinEdit.initNew(pEnv);      pTinEdit.addFromFeatureClass(pointFeaCls, null, pointFeaCls.getFields().getField(0) , null, esriTinSurfaceType.esriTinMassPoint,  null);      pTinEdit.refresh();      ITinNodeCollection pTinNodeCollection = (ITinNodeCollection)pTinEdit;            pTinNodeCollection.convertToVoronoiRegions(voronoiFeaCls, null, clippingPolygon,"","");                 System.out.println("voronoiFeaCls:"+voronoiFeaCls.featureCount(null));    }    else     System.out.println("必须输入至少3个点!");   }   else    System.out.println("必须输入点数据!");  } catch (AutomationException e) {   // TODO Auto-generated catch block   e.printStackTrace();  } catch (IOException e) {   // TODO Auto-generated catch block   e.printStackTrace();  }//  return voronoiFeaCls; }