Hi,
I have a simple polyline feature layer and there are some polylines on it that I want to reshape/replace with new polylines and I'm having a little trouble with it. So, this code here works fine:
<SPAN class="keyword token">public</SPAN> <SPAN class="keyword token">async</SPAN> Task <SPAN class="token function">SetPolylineShapeAsyncViaCursor</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">int</SPAN> polylineId<SPAN class="punctuation token">,</SPAN> ArcGISGeo<SPAN class="punctuation token">.</SPAN>Polyline newPolyline<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
FeatureLayer polylineFeatureLayer <SPAN class="operator token">=</SPAN> <SPAN class="comment token">//Get feature layer</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>polylineFeatureLayer <SPAN class="operator token">==</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">return</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">await</SPAN> ArcGISTasks<SPAN class="punctuation token">.</SPAN>QueuedTask<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Run</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">=</SPAN><SPAN class="operator token">></SPAN> <SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">var</SPAN> queryFilter <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">ArcGISData<SPAN class="punctuation token">.</SPAN>QueryFilter</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
queryFilter<SPAN class="punctuation token">.</SPAN>WhereClause <SPAN class="operator token">=</SPAN> String<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Format</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"{0} = {1}"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"PID"</SPAN><SPAN class="punctuation token">,</SPAN> polylineId<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> cursor <SPAN class="operator token">=</SPAN> polylineFeatureLayer<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Search</SPAN><SPAN class="punctuation token">(</SPAN>queryFilter<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>cursor<SPAN class="punctuation token">.</SPAN><SPAN class="token function">MoveNext</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">var</SPAN> feature <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN>ArcGISData<SPAN class="punctuation token">.</SPAN>Feature<SPAN class="punctuation token">)</SPAN>cursor<SPAN class="punctuation token">.</SPAN>Current<SPAN class="punctuation token">;</SPAN>
feature<SPAN class="punctuation token">.</SPAN><SPAN class="token function">SetShape</SPAN><SPAN class="punctuation token">(</SPAN>newPolyline<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
feature<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Store</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>However, I'd very much prefer to use an EditOperation since this polyline operation is part of a bigger editing process and I eventually want to pass around an EditOperation instance that all methods use and in the end ExecuteAsync is called once. For now I'd like to have it working with a local EditOperation, but it doesn't work when I try to modify the shape via EditOperation.Reshape (it only yields an "EditOperation failed" error):
<SPAN class="keyword token">public</SPAN> <SPAN class="keyword token">async</SPAN> Task <SPAN class="token function">SetPolylineShapeAsyncViaReshape</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">int</SPAN> polylineId<SPAN class="punctuation token">,</SPAN> ArcGISGeo<SPAN class="punctuation token">.</SPAN>Polyline newPolyline<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
FeatureLayer polylineFeatureLayer <SPAN class="operator token">=</SPAN> <SPAN class="comment token">//Get feature layer</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>polylineFeatureLayer <SPAN class="operator token">==</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">return</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">long</SPAN> polylineOID <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">await</SPAN> <SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">GetPolylineOIDAsync</SPAN><SPAN class="punctuation token">(</SPAN>polylineId<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>polylineOID <SPAN class="operator token">==</SPAN> <SPAN class="operator token">-</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">return</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> polylineOperation <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">EditOperation</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
polylineOperation<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Reshape</SPAN><SPAN class="punctuation token">(</SPAN>polylineFeatureLayer<SPAN class="punctuation token">,</SPAN> polylineOID<SPAN class="punctuation token">,</SPAN> newPolyline<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">await</SPAN> polylineOperation<SPAN class="punctuation token">.</SPAN><SPAN class="token function">ExecuteAsync</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>It must be a small detail that's missing but I'd be glad if somebody could tell me what I'm doing wrong.
Thanks in adavance
Best Regards
Christian