首先这里建议使用arcgis的GEO数据处理方式
// create and load the service geodatabase
ServiceGeodatabase serviceGeodatabase = new ServiceGeodatabase(url);
serviceGeodatabase.loadAsync();
serviceGeodatabase.addDoneLoadingListener(() -> {});
-
通过地图上点击查询或元素字段查询等办法,找到对应的标识物feature。点击查询的标识物在
Result.getElements()
中取第一个get(0)。
call get on the future to get the result -
layer.selectFeature(feature)为选中,可加选后的效果
-
创建新的点线面对象
point,polyline,polygon(geometry)
point的创建
// create a point geometry with a location and spatial reference // Point(latitude, longitude, spatial reference) val point = Point(-118.8065, 34.0005, SpatialReferences.getWgs84())
polyline的创建
// create a point collection with a spatial reference, and add three points to it val polylinePoints = PointCollection(SpatialReferences.getWgs84()).apply { // Point(latitude, longitude) add(Point(-118.8215, 34.0139)) add(Point(-118.8148, 34.0080)) add(Point(-118.8088, 34.0016)) } // create a polyline geometry from the point collection val polyline = Polyline(polylinePoints)
polygon的创建
// create a point collection with a spatial reference, and add five points to it val polygonPoints = PointCollection(SpatialReferences.getWgs84()).apply { // Point(latitude, longitude) add(Point(-118.8189, 34.0137)) add(Point(-118.8067, 34.0215)) add(Point(-118.7914, 34.0163)) add(Point(-118.7959, 34.0085)) add(Point(-118.8085, 34.0035)) } // create a polygon geometry from the point collection val polygon = Polygon(polygonPoints)
-
使用之前找标识物的对象进行修改
feature.setGeometry(geometry);
使用新的点线面进行替换
-
GEO数据更新提交
updateFeatureAsync(feature)
具体代码如下:
//类似添加操作 try { // add the feature to the local table val addFeatureFuture: ListenableFuture<Void> = damageTable.addFeatureAsync(arcgisFeature) // Update the feature on the local table. //damageTable.updateFeatureAsync(arcgisFeature) addFeatureFuture.addDoneListener { // If the feature table is a service feature table, then // apply edits to its service geodatabase ... } } catch (e: Exception) { e.printStackTrace() }
-
apply edits once the update has completed( apply edits to its service geodatabase)。发现这一步有时不添加,结果也能成功。尽量参考官方文档,加上这一步的操作比较好点。
以上是arcgis点线面等位置修改的详细思路,需要使用GEO数据服务方式。因为之前只使用ServiceFeatureTable服务方式后,发现结果没有变化。如果有不对或更好的思路,可以告诉我,相互交流学习。
arcgis几何空间对象GEOMETRY接口,参考文档网址如下:
https://developers.arcgis.com/android/spatial-and-data-analysis/geometry/