Create Points at Line Vertices
I'm having a little trouble getting line geometry coordinates to make a point. Basically what we're trying to do is have the user select a line feature (road) and be able to add points to a feature service at the lines start, end or midpoint. i was able to do a display capture geometry to get the line, run a query task on the feature and run a Get Geometry <Line> to create the line geometry. I implemented 2 nested For Each loops to get the paths of the line and then the points at each. I set an alert to view each points X, Y and was able to get this working. I'm a little stuck here and not sure what to do with this collection of X,Y's. Also tried was the Get Centroid, Extract Line and Extract Point activities. Any help would be appreciated.
0
-
Hi Brian,
You can work directly with the path's MapPoint objects that the X and Y values come from. You'll likely want to build a feature (ESRI.ArcGIS.Client.Graphic) around your desired point or around each point, and then add that feature to a featureset or a collection of features. Then you can use the featurset/collection in an AddFeatures activity's "Features" property.- To build a featureset, Assign yourPointFSVariable = New FeatureSet(). Make sure to set the spatial reference for the featureset, eg- yourPointFSVariable.SpatialReference = yourLineFS.SpatialReference
- To build a feature, Assign yourGraphicVariable = New ESRI.ArcGIS.Client.Graphic(). Then you can assign yourGraphicVariable.Geometry = thePointFromThePath. I can't remember off the top of my head, but you might also need to assign the yourGraphicVariable.Geometry.SpatialReference.
- To add a feature to a featureset, you can use the AddToCollection activity. The TypeArgument is ESRI.ArcGIS.Client.Graphic, the collection is yourPointFSVariable.Features and the item is yourGraphicVariable.
-Amanda0 -
thank you Amanda. What I ended up doing was Getting the Geometry of a line selection and then getting the centroid of that line. I then projected that result to a single geometry, buffered and turned the graphic into an envelope. I created a new map point and assigned the value to read new ESRI.ArcGIS.Client.Geometry.MapPoint(((envelope2.Xmax + envelope2.Xmin)/2), ((envelope2.Ymax + envelope2.Ymin)/2 ),spatialreference1). This map point is working as the centroid and I'm able to add a markup to the map from the workflow. My problem now is getting this map point feature to be able to supply to the Add Features activity. I tried to cast the map point back to a geometry, then assign the new geometry to a graphic, insert the graphic into a list and finally Add Features. The workflow runs but the point is not placed in the right location and has no display. A record shows in my feature service table but I think it has an empty Geometry. Is there an easier way to get the map point into the Add Features activity? It seems like I'm having issues converting the map point into a geometry. 0 -
I was able to solve this by assigning the graphic geometry to the map point created from the X,Y. 0
Du måste logga in om du vill lämna en kommentar.
Kommentarer
3 kommentarer