POST
|
I think I have a reproducer now. However, the difference in numbers is not as big as yours and does not change if I create UtilityNetwork with or without a map. Electric Distribution Line Unique Elements `4052` vs Features From Elements `4066` (more features than elements) Electric Distribution Junction Unique Elements `3334` vs Features From Elements `3334` Electric Distribution Device Unique Elements `5045` vs Features From Elements `5425` (more features than elements) var FeatureServerUrl = "https://sampleserver7.arcgisonline.com/arcgis/rest/services/UtilityNetwork/NapervilleElectric/FeatureServer";
var map = new Map(Basemap.CreateDarkGrayCanvasVector());
map.InitialViewpoint = new Viewpoint(InitialExtent);
map.OperationalLayers.Add(new FeatureLayer(new Uri($"{FeatureServiceUrl}/115")));
map.OperationalLayers.Add(new FeatureLayer(new Uri($"{FeatureServiceUrl}/110")));
map.OperationalLayers.Add(new FeatureLayer(new Uri($"{FeatureServiceUrl}/100")));
await map.LoadAsync();
_un = await UtilityNetwork.CreateAsync(new Uri(FeatureServiceUrl), map);
var networkSource = _un.Definition.GetNetworkSource("Electric Distribution Device");
var assetGroup = networkSource?.GetAssetGroup("Circuit Breaker");
var assetType = assetGroup?.GetAssetType("Three Phase");
var terminal = assetType?.TerminalConfiguration?.Terminals?.FirstOrDefault(t => t.Name == "Source");
var globalId = Guid.Parse("{B8493B23-B40B-4E3E-8C4B-0DD83C28D2CC}");
var element = _un.CreateElement(assetType, globalId, terminal);
var parameters = new UtilityTraceParameters(UtilityTraceType.Connected, new[] { element });
var result = await _un.TraceAsync(parameters);
if (result.FirstOrDefault() is UtilityElementTraceResult elementResult)
{
if (elementResult.Warnings.Count > 0)
MessageBox.Show(string.Join("\n", elementResult.Warnings), "Trace Result Warnings", MessageBoxButton.OK);
foreach (var layer in MyMapView.Map.OperationalLayers.OfType<FeatureLayer>())
{
var elements = elementResult.Elements.Where(el => el.NetworkSource.FeatureTable == layer.FeatureTable);
var features = await _un.GetFeaturesForElementsAsync(elements);
var distinctIds = (from f in elements select f.ObjectId).Distinct();
System.Diagnostics.Debug.WriteLine($"{layer.FeatureTable.DisplayName}\t:\t Unique Elements `{distinctIds.Count()}` vs Features From Elements `{features.Count()}`");
layer.SelectFeatures(features);
}
} In your case, could there be layers that did not load or required credential? You can add the following to troubleshoot. // Check if any layer failed
MyMapView.LayerViewStateChanged += (s, e) =>
{
var error = e.LayerViewState.Error ?? e.Layer.LoadError;
if (error != null)
System.Diagnostics.Debug.WriteLine($"{e.Layer.Name} had an error {error.Message}");
};
// Check if any layer required credential
AuthenticationManager.Current.ChallengeHandler = new ChallengeHandler(async(info) =>
{
return await AuthenticationManager.Current.GenerateCredentialAsync(info.ServiceUri, "<username>", "<password>");
});
... View more
08-12-2020
05:57 PM
|
0
|
0
|
2532
|
POST
|
The 5856 elements may not be distinct and may also be belonging to other layers. Do you do something like this? var result = await _un.TraceAsync(_parameters);
if (result.FirstOrDefault() is UtilityElementTraceResult elementResult)
{
if (elementResult.Warnings.Count > 0)
MessageBox.Show(string.Join("\n", elementResult.Warnings), "Trace Result Warnings", MessageBoxButton.OK);
foreach (var layer in MyMapView.Map.OperationalLayers.OfType<FeatureLayer>())
{
var elements = elementResult.Elements.Where(el => el.NetworkSource.FeatureTable == layer.FeatureTable);
var features = await _un.GetFeaturesForElementsAsync(elements);
layer.SelectFeatures(features);
}
} I added this check and the counts seem to match. var distinctIds = (from f in elements select f.ObjectId).Distinct();
System.Diagnostics.Debug.WriteLine($"Unique Elements `{distinctIds.Count()}` vs Features From Elements `{features.Count()}`");
... View more
08-12-2020
03:10 PM
|
0
|
1
|
2532
|
POST
|
What version of ArcGIS Runtime SDK for .NET are you using? I believe we fixed a bug in 100.6 which is as you describe GetFeaturesForElementsAsync does not return all features. A workaround for that release is to select or query by object id var query = new QueryParameters();
foreach (var id in (from f in elementGroup select f.ObjectId).Distinct())
query.ObjectIds.Add(id);
layer.SelectFeaturesAsync(query, SelectionMode.New); Can you clarify what invalid results you get? when I create it using UtilityNetwork.CreateAsync Method (Uri, Map) method I am getting the invalid results. If UtilityNetwork was created with a map, the UtilityNetwork.Definition.NetworkSources which have a FeatureTable property will be the same instances in your map. If you created UtilityNetwork first and you wanted to build your map from it, you can also do foreach (var ns in _un.Definition.NetworkSources)
{
if (ns.SourceUsageType == UtilityNetworkSourceUsageType.SubnetLine)
continue;
map.OperationalLayers.Insert(0, new FeatureLayer(ns.FeatureTable));
}
... View more
08-12-2020
02:31 PM
|
0
|
3
|
2532
|
POST
|
Can you share some code snippet on how you are handling authentication challenge or adding credentials? At what stage in your app do you get error code 498 (invalid token)? The default client handler we use checks for requests with invalid token and if a token credential is available for the request, it will refresh the token. You can use ArcGISHttpClientHandler.HttpRequestBegin to find out which request is failing or if you have already set challenge handler Authentication.Current.ChallengeHandler = new ChallengeHandler ((info) =>{ // you can check here }); Thanks.
... View more
02-05-2019
01:00 PM
|
0
|
1
|
458
|
POST
|
Here's an example of using ResultOffset and MaxFeatures. The table need to support pagination for you to do this. Yes, you will need to know total count using QueryFeaturesCountAsync and determine how many features you want a page to calculate the number of pages. This will let you compute the appropriate ResultOffset. public MainWindow()
{
InitializeComponent();
_parameters = new QueryParameters() { WhereClause = "1=1" };
_table = new ServiceFeatureTable(new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/2"));
_table.Loaded += (s, e) =>
{
var table = (ServiceFeatureTable)s;
if (table.LoadStatus == LoadStatus.Loaded)
MessageBox.Show($"SupportsPagination : {table.LayerInfo?.SupportsPagination}");
};
RecordsPerPage.ItemsSource = new int[] { 10, 20, 30, 40, 50 };
RecordsPerPage.SelectedItem = 25;
}
private ServiceFeatureTable _table;
private QueryParameters _parameters;
private int _totalFeatureCount;
private int _currentPageIndex;
private int _recordsPerPage;
private int _totalPages;
private async void OnFirstPageClick(object sender, RoutedEventArgs e)
{
_currentPageIndex = 0;
await GetResultForPageAsync();
}
private async void OnPreviousPageClick(object sender, RoutedEventArgs e)
{
if (_currentPageIndex - 1 < 0)
return;
_currentPageIndex--;
await GetResultForPageAsync();
}
private async void OnNextPageClick(object sender, RoutedEventArgs e)
{
if (_currentPageIndex + 1 > _totalPages)
return;
_currentPageIndex++;
await GetResultForPageAsync();
}
private async void OnLastPageClick(object sender, RoutedEventArgs e)
{
_currentPageIndex = _totalPages - 1;
await GetResultForPageAsync();
}
private async void OnRecordsPerPageChanged(object sender, SelectionChangedEventArgs e)
{
try
{
_currentPageIndex = 0;
if (_totalFeatureCount == 0)
_totalFeatureCount = (int)(await _table.QueryFeatureCountAsync(_parameters));
_recordsPerPage = (int)RecordsPerPage.SelectedItem;
_totalPages = _totalFeatureCount / _recordsPerPage;
await GetResultForPageAsync();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.GetType().Name);
}
}
private async Task GetResultForPageAsync()
{
try
{
Result.ItemsSource = Enumerable.Empty<ArcGISFeature>();
CurrentPageNumber.Text = $"{_currentPageIndex + 1}";
TotalPages.Text = $"{_totalPages}";
_parameters.ResultOffset = _currentPageIndex * _recordsPerPage;
_parameters.MaxFeatures = _recordsPerPage;
var result = await _table.QueryFeaturesAsync(_parameters, QueryFeatureFields.LoadAll);
Result.ItemsSource = result.ToArray();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.GetType().Name);
}
} <Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<DataGrid x:Name="Result"
AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Attributes[STATE_NAME]}"
Header="State Name" />
<DataGridTextColumn Binding="{Binding Attributes[POP2000]}"
Header="Population 2000" />
<DataGridTextColumn Binding="{Binding Attributes[POP2007]}"
Header="Population 2007" />
<DataGridTextColumn Binding="{Binding Attributes[HOUSEHOLDS]}"
Header="Households" />
<DataGridTextColumn Binding="{Binding Attributes[FAMILIES]}"
Header="Families" />
</DataGrid.Columns>
</DataGrid>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Button Content="|<<"
Click="OnFirstPageClick" />
<Button Grid.Column="1"
Content="<"
Click="OnPreviousPageClick" />
<Button Grid.Column="2"
Content=">"
Click="OnNextPageClick" />
<Button Grid.Column="3"
Content=">>|"
Click="OnLastPageClick" />
<TextBlock Grid.Column="4"
x:Name="CurrentPageNumber" />
<TextBlock Grid.Column="5"
Text=" of " />
<TextBlock Grid.Column="6"
x:Name="TotalPages" />
<TextBlock Grid.Column="7"
Text="Show : " />
<ComboBox Grid.Column="8"
SelectionChanged="OnRecordsPerPageChanged"
x:Name="RecordsPerPage" />
</Grid>
</Grid>
... View more
02-05-2019
11:12 AM
|
5
|
1
|
982
|
POST
|
Thanks for the follow-up. Undo from move or delete are both addressed in the same issue. I don't have a reference number I can share but fix is on its way for next release.
... View more
01-30-2019
01:43 PM
|
0
|
0
|
3993
|
POST
|
You can use GeometryEngine.Intersects method to decide whether graphic needs to be selected. For example, in code below. GraphicsOverlay contain points and a polygon geometry is used for selection. Once point graphics are available, draw polygon (double-tap to complete draw), then mark graphic as selected based on return value of GeometryEngine.Intersects method. Geometries might need to be in the same SpatialReference, so you might need to use GeometryEngine.Project. MyMapView.Map = new Map(SpatialReferences.Wgs84);
MyMapView.SpatialReferenceChanged += async (s, e) =>
{
var geometry = await MyMapView.SketchEditor.StartAsync(SketchCreationMode.Polygon, false);
var overlay = MyMapView.GraphicsOverlays.FirstOrDefault();
if (overlay != null)
{
foreach (var g in overlay.Graphics)
{
g.IsSelected = GeometryEngine.Intersects(g.Geometry, geometry);
}
}
};
MyMapView.GraphicsOverlays.Add(new GraphicsOverlay() { Renderer = new SimpleRenderer(new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Color.Yellow, 12d)) });
AddRandomGraphics();
}
private void AddRandomGraphics()
{
var random = new Random();
var overlay = MyMapView.GraphicsOverlays.FirstOrDefault();
if (overlay != null)
{
for (int i = 0; i < 10; i++)
{
var mp = new MapPoint(random.Next(-180, 180), random.Next(-90, 90), SpatialReferences.Wgs84);
overlay.Graphics.Add(new Graphic(mp));
}
}
}
... View more
01-23-2019
10:12 AM
|
0
|
0
|
534
|
POST
|
Thank you for your feedback. This appears to be a regression between v100.2.1 and v100.3 that dragging vertex or geometry is not part of the undo stack. I have logged an issue for this so we can fix in future releases of the API. Meanwhile, you may use GeometryChanged event to track the old geometry to be restored on Undo. UndoCommand is meant to bring back the previous state of geometry. When a new vertex was added, the new vertex will be removed. When a vertex is deleted, the deleted vertex is added back. When a vertex is moved, the moved vertex is moved back to its previous location. When the geometry is scaled, rotated or resized, its previous shape and location is restored. Possible workaround: public MainWindow()
{
InitializeComponent();
MyMapView.SketchEditor.GeometryChanged += (s, e) =>
{
undoStack.Push(e.OldGeometry);
};
}
private readonly Stack<Geometry> undoStack = new Stack<Geometry>();
private void OnUndo(object sender, RoutedEventArgs e)
{
MyMapView.SketchEditor.ReplaceGeometry(undoStack.Pop());
}
... View more
01-22-2019
12:40 PM
|
0
|
0
|
3993
|
POST
|
I think this will be the runtime equivalent method then: GeometryEngine.CreatePointAlong Method
... View more
01-22-2019
10:48 AM
|
1
|
1
|
4257
|
POST
|
Adding the table to Map will not trigger table load, unlike when table is added as layer to the Map because it would at least try to render the features based on map extent. This is because non-spatial table is not in use unless you were to query it. Table will load upon query if you hadn't already explicitly called table.LoadAsync(). But in the case of ManualCache, this table will be empty until you have called PopulateFeaturesAsync().
... View more
01-15-2019
10:36 AM
|
0
|
0
|
364
|
POST
|
Yes, .Net Framework 4.6.1 is minimum requirement. I have not seen "Unsupported Version 0.0".. can you try uninstall nuget references first and then install v100.4? It will install these two When asked to resolve namespaces, there's a few of those between these two releases.. you can just define using statement, for example. Hopefully, you've got sample simplified just to see if render issue on picture symbol in composite symbol is resolved. using Colors = System.Drawing.Color;
... View more
12-27-2018
02:23 PM
|
0
|
2
|
1882
|
POST
|
I just tried the code with Composite Symbol that I shared earlier against 100.1 and it still works for me. RenderingMode is a property of GraphicsOverlay. I think you're right Dynamic is default for points. Another thing that caught my attention in your code is GraphicsLayer (this is v10.2.x class). Maybe the mix of SDK version is not working well. You can start a smaller application to maybe narrow down the issue? Also, can you return composite symbol directly? There seems to be no need for this to be async process. return await Task.Factory.StartNew<Symbol>(() => { return pc; }); Thanks for sharing symbol image and geometry. Another thought was maybe it detects collision and hide the picture symbol but they both show here: Another thing you can do is identify graphic that has impartial symbol rendered and get its symbol ToJson(). CompositeSymbol might throw NotSupportedException, but its Symbols picture and text can be deserialized, you can check then if these seem correct. MapView.GeoViewTapped with MapView.IdentifyGraphicsOverlaysAsync will get you the graphic.
... View more
12-27-2018
11:13 AM
|
0
|
5
|
1882
|
POST
|
The error message sound similar to this bug. By any chance did you use ArcGIS Pro with Japanese Language Pack enabled? BUG-000116547: ArcGISWebException - Failed to create service - exception thrown by ArcGIS Runtime local server 100.3 when trying to run a local service from a local geoprocessing package Also, you can query shapefile table. The query result is also an IFeatureSet (see doc).
... View more
12-27-2018
10:53 AM
|
1
|
1
|
779
|
POST
|
I just read your response in StackOverflow and I'm curious about this. The only thing that fixes it is reloading the map If you're able to share 1 graphic geometry and symbol, Map's SpatialReference/extent, I can try to reproduce. You can get geometry/symbol JSON using ToJson() and you can do MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry) to get more info. When you update to new SDK version, does it work?
... View more
12-27-2018
10:25 AM
|
1
|
8
|
1882
|
POST
|
Thank you for sharing here, in case other people have run into the same issues, they'd be able to chime in. I'm not sure if you had a chance to try these suggestions so I'll post it here as well. If icon path was used in an Image control, do you see the image? It may be that icon path is incorrect or build action or copy to output directory need to change (see: msdn doc) If the icon path is good, does the symbol render outside CompositeSymbol (using only PictureMarkerSymbol)? If yes, does it get fixed by updating SDK to 100.4 or maybe updating GraphicsRenderingMode or maybe as you zoom-in/out of the map? I am not able to reproduce with the following code where note.png is added as Content, Copy if newer. MyMapView.Map = new Map(SpatialReferences.Wgs84);
var symbol = new CompositeSymbol();
symbol.Symbols.Add(new PictureMarkerSymbol(new Uri("pack://application:,,,/note.png")));
symbol.Symbols.Add(new TextSymbol("1", Color.Black, 10, Esri.ArcGISRuntime.Symbology.HorizontalAlignment.Center, Esri.ArcGISRuntime.Symbology.VerticalAlignment.Middle));
var overlay = new GraphicsOverlay();
overlay.Graphics.Add(new Graphic(new MapPoint(0, 0), symbol));
MyMapView.GraphicsOverlays.Add(overlay);
... View more
12-27-2018
10:13 AM
|
0
|
10
|
1882
|
Title | Kudos | Posted |
---|---|---|
1 | 2 weeks ago | |
1 | 11-13-2023 09:05 AM | |
1 | 04-26-2011 06:50 PM | |
1 | 05-26-2023 09:30 AM | |
4 | 05-26-2023 09:42 AM |
Online Status |
Offline
|
Date Last Visited |
a week ago
|