如何从几何图形arcgis android中查找中心点?
我正在开发一个应用程序,我想在我的地图上显示几何中心的调用。我是arcgis新手。我尝试了很多,但我无法在中心调用,请任何人帮助我解决这个问题 我的代码如何从几何图形arcgis android中查找中心点?,android,computational-geometry,arcgis,Android,Computational Geometry,Arcgis,我正在开发一个应用程序,我想在我的地图上显示几何中心的调用。我是arcgis新手。我尝试了很多,但我无法在中心调用,请任何人帮助我解决这个问题 我的代码 SimpleFillSymbol sfs = new SimpleFillSymbol( Color.RED); sfs.setAlpha(5);
SimpleFillSymbol sfs = new SimpleFillSymbol(
Color.RED);
sfs.setAlpha(5);
graphic = new Graphic(feature.getGeometry(),
sfs, feature.getAttributes());
Polygon polygon = (Polygon) graphic
.getGeometry();
int polygonpointscount=polygon.getPointCount();
if(polygonpointscount!=0)
{
pointsize=polygonpointscount/2;
}
Point midpoint = polygon.getPoint(pointsize);
Callout callout = mMapView.getCallout();
if (callout != null
&& callout.isShowing()) {
callout.hide();
}
//Set the content, show the view
callout.setContent(adminsearchloadView(governorate_Name,
area_Name,
block_Number));
callout.setStyle(R.xml.calloutstyle);
callout.setMaxHeight(100000);
callout.setMaxWidth(100000);
callout.refresh();
callout.show(midpoint);
如果使用arcgis服务器,可以尝试“要素到点”:计算质心图层 简短回答:使用 长答覆: 从你的代码
int polygonpointscount=polygon.getPointCount();
if(polygonpointscount!=0)
{
pointsize=polygonpointscount/2;
}
Polygon.getPointCount()
返回多边形的顶点。例如,如果多边形是矩形,getPointCount()
返回角点。因此,您的标注将位于其中一个角,而不是质心
相反,使用。它不能保证返回质心,但它返回一个适合标记的内部点(在我看来,它很像质心)。确保传递一个SpatialReference
对象,该对象告诉getLabelPointForPolygon
多边形的空间参照是什么
如果必须具有质心,则需要基于ArcGIS工具创建地理处理服务。但是,getLabelPointForPolygon
更易于实现,执行速度更快,可能满足您的需要。我正在使用arcgis服务器,但无法理解您的示例您可以将所有几何图形保存到gdb。在arccatalog中打开gdb,并使用特征点工具计算其质心。然后,您可以在arcgis服务器上将新的质心图层发布为新图层谢谢@Gary,解决了我的问题,我还有一个关于多段线的问题,我无法获取多段线的中心点,请告诉我如何获取多段线的中心点和延伸度您可以尝试(多段线延伸多路径)获取多段线的边界框,然后调用Envelope的getCenter、getCenterX和getCenterY方法。