Select to view content in your preferred language

How To Edit Multiple Points

1893
6
11-16-2016 10:20 AM
FredyDi_Sano
Deactivated User

Is there any way to edit multiple points at once? 

For my app, I'd like the user to select multiple polygon regions that all share a common vertex. I'd run the editor on one of the regions and adjust the shared vertex while the other polygon's would adjust their shared vertex to the new point. I know you can't edit geometry once it's been created but is this something the point builder is used for?

Or is there another way to do this?

Thanks!

0 Kudos
6 Replies
JenniferNery
Esri Regular Contributor

The SketchEditor currently works with one geometry at a time. If by 'shared vertex' you mean same start/end point in a polygon geometry where updating one, updates the other - this is the current behavior.

But it sounds like you are working with multiple polygon geometries where some vertices may be shared and an update vertex in one polygon need to also update vertices in other polygons if shared, is this correct? If yes, I think you can use PolygonBuilder for each of your polygon geometries. On every part, Points will get you the unique vertices, while GetPoint(index) and SetPoint(index, newLocation) will give you the current location and update the vertex from specified position. You can then set feature or graphic Geometry with polygonBuilder.ToGeometry() to convert back to polygon.

0 Kudos
FredyDi_Sano
Deactivated User

I figured this out actually. It was a combination of a few things.

The biggest issue I've had so far with this SDK is that Geometries are tightly locked and can't be edited. I get that is for performance reasons but at the low level, the graphics API will allow you to create geometry buffers with different flags to determine if it should be static or dynamic and thus there should be a flag that allows us to determine that.

That said, even converting a Graphic into a PolygonBuilder doesn't cut is as you can't edit the individual MapPoints so I had to call EditGeometryAsync with a progress class and track each vertex update call, from there I rebuild the geometry list each time using PolygonBuilder and move only the shared vertices.

A true pain to get around the locked geometry limitation! 

0 Kudos
JenniferNery
Esri Regular Contributor

Hi Fredy,

Are you using v10.2.x? Editor.EditGeometryAsync was replaced by SketchEditor.StartAsync in v100.0.

I'm not sure I understand what you mean by geometry is locked. You can update graphic.Geometry by setting it to polygonBuilder.ToGeometry() after you've made edits in the builder. Also, RenderingMode of Static | Dynamic is a property on GraphicsOverlay. I don't think you'll get this information from the graphic.

Do you mind sharing some code-snippet? It's interesting use case and I'm wondering if there's anything in the API that can help with this.

Thanks.

Jennifer

0 Kudos
FredyDi_Sano
Deactivated User

I did not know about the new v100.0 (hell of a jump in release numbers eh? )

What I meant about locked geometry is that both RequestShapeAsync and EditGeometryAsync return Geometry.Geometry objects which are attached to Graphics. The issue is that Geometries are immutable so in order to edit it you first need to build a PolygonBuilder with the geometry, then edit it and then attach the new geometry back to the graphic.

When I talk about static vs dynamic geometry, I was referring to how DirectX (and OpenGL) allow you to create geometry buffers which, I assume, has something to do with why you've decided to make geometry immutable. Not sure if that is still the case in V100.00.

0 Kudos
JenniferNery
Esri Regular Contributor

Yup you are correct. Geometries are immutable and can only be modified through geometry builders. And yes, we still have RenderingMode property on GraphicsOverlay that lets you choose between Static | Dynamic. These are still true in the new version of the API. Also the return value when you await RequestShapeAsync/EditGeometryAsync (v10.2.x) or StartAsync(v100.0) is of type Geometry which you can assign to an ArcGISFeature or Graphic.

What kind of layer/overlay are you working with? Are you trying to update multiple graphics at once? I'm not sure how Editor can help with this since it works with only one geometry at a time and have no knowledge of other geometries that might share the same vertex. But perhaps some GeometryEngine methods can help? GeometryEngine.Relate, GeometryEngine.NearestCoordinate, GeometryEngine.NearestVertex? I'm curious to hear your solution for v10.2.x.

Thanks.

Jennifer

0 Kudos
FredyDi_Sano
Deactivated User

Sorry for the late reply. 

I'm working with graphic layers and so what I wanted was to have the user be able to select multiple polygons in a layer and allow them to edit multiple shared points at a time. 

I can't post specific code as this is a project for a client and under NDA but I can describe what I did.

The trick here was to collect a group of graphics to be edited and call EditGeometryAsync on the last graphic in that list. I use the ProgressChanged delegate to determine when a point was moved, from there I iterate all the MapPoints in the selected graphics list (minus the last one as that is the graphic being edited) and use the PolygonBuilder to generate a new polygon geometry. For each MapPoint being added to the new polygon, I'd check to see if it was within a very small distance to the edited point and if it was, I'd use MapPoint.MoveTo() to generate the new point otherwise I'd copy the original point at that location back in.

0 Kudos