/// <summary> /// Returns a list of spatial relationships between two geometries /// </summary> /// <param name="a">The 'a' in "a contains b"</param> /// <param name="b">The 'b' in "a contains b"</param> /// <returns>A list of spatial relationships that are true for a and b.</returns> private static List <SpatialRelationship> GetSpatialRelationships(Geometry a, Geometry b) { List <SpatialRelationship> relationships = new List <SpatialRelationship>(); if (GeometryEngine.Crosses(a, b)) { relationships.Add(SpatialRelationship.Crosses); } if (GeometryEngine.Contains(a, b)) { relationships.Add(SpatialRelationship.Contains); } if (GeometryEngine.Disjoint(a, b)) { relationships.Add(SpatialRelationship.Disjoint); } if (GeometryEngine.Intersects(a, b)) { relationships.Add(SpatialRelationship.Intersects); } if (GeometryEngine.Overlaps(a, b)) { relationships.Add(SpatialRelationship.Overlaps); } if (GeometryEngine.Touches(a, b)) { relationships.Add(SpatialRelationship.Touches); } if (GeometryEngine.Within(a, b)) { relationships.Add(SpatialRelationship.Within); } return(relationships); }
// Accepts two user shapes and adds them to the graphics layer private async Task AcceptShapeAsync() { // Shape One Geometry shapeOne = await mapView.Editor.RequestShapeAsync( (DrawShape)comboShapeOne.SelectedValue, _symbols[comboShapeOne.SelectedIndex]); _graphicsLayer.Graphics.Add(new Graphic(shapeOne, _symbols[comboShapeOne.SelectedIndex])); // Shape Two Geometry shapeTwo = await mapView.Editor.RequestShapeAsync( (DrawShape)comboShapeTwo.SelectedValue, _symbols[comboShapeTwo.SelectedIndex]); _graphicsLayer.Graphics.Add(new Graphic(shapeTwo, _symbols[comboShapeTwo.SelectedIndex])); var relations = new List <Tuple <string, bool> >(); relations.Add(new Tuple <string, bool>("Contains", GeometryEngine.Contains(shapeOne, shapeTwo))); relations.Add(new Tuple <string, bool>("Crosses", GeometryEngine.Crosses(shapeOne, shapeTwo))); relations.Add(new Tuple <string, bool>("Disjoint", GeometryEngine.Disjoint(shapeOne, shapeTwo))); relations.Add(new Tuple <string, bool>("Equals", GeometryEngine.Equals(shapeOne, shapeTwo))); relations.Add(new Tuple <string, bool>("Intersects", GeometryEngine.Intersects(shapeOne, shapeTwo))); relations.Add(new Tuple <string, bool>("Overlaps", GeometryEngine.Overlaps(shapeOne, shapeTwo))); relations.Add(new Tuple <string, bool>("Touches", GeometryEngine.Touches(shapeOne, shapeTwo))); relations.Add(new Tuple <string, bool>("Within", GeometryEngine.Within(shapeOne, shapeTwo))); resultsListView.ItemsSource = relations; resultsPanel.Visibility = Visibility.Visible; }
internal async void FlashStreet() { if (StreetLayer != null && StreetLayer is FeatureLayer) { if (Type == "INTERSECTS") { QueryParameters _query = new QueryParameters(); _query.WhereClause = $"REGISTEREDNAME = '{SelectedPrimaryStreet.name}' and STREETTYPE = '{SelectedPrimaryStreet.type}' and QUADRANT = '{SelectedPrimaryStreet.quad}'"; var prifeatures = await StreetLayer.FeatureTable.QueryFeaturesAsync(_query); _query.WhereClause = $"REGISTEREDNAME = '{SelectedIntersectingStreet.name}' and STREETTYPE = '{SelectedIntersectingStreet.type}' and QUADRANT = '{SelectedIntersectingStreet.quad}'"; var intfeatures = await StreetLayer.FeatureTable.QueryFeaturesAsync(_query); var showfeatures = new List <Feature>(); foreach (var prifeature in prifeatures) { foreach (var intfeature in intfeatures) { if (GeometryEngine.Touches(prifeature.Geometry, intfeature.Geometry)) { showfeatures.Add(prifeature); showfeatures.Add(intfeature); } } } var strings = showfeatures.Select(feature => $"OBJECTID = {feature.Attributes["OBJECTID"]?.ToString()}"); _query.WhereClause = String.Join(" or ", strings.ToArray()); StreetLayer.SelectFeaturesAsync(_query, Esri.ArcGISRuntime.Mapping.SelectionMode.New); await Task.Delay(1 * 1000); StreetLayer.ClearSelection(); } else { QueryParameters _query = new QueryParameters(); _query.WhereClause = $"REGISTEREDNAME = '{SelectedPrimaryStreet.name}' and STREETTYPE = '{SelectedPrimaryStreet.type}' and QUADRANT = '{SelectedPrimaryStreet.quad}'"; _query.WhereClause = _query.WhereClause + $" and FROMLEFTTHEORETICRANGE = '{SelectedRange.leftLower}' and TOLEFTTHEORETICRANGE = '{SelectedRange.leftUpper}' and FROMRIGHTTHEORETICRANGE = '{SelectedRange.rightLower}' and TORIGHTTHEORETICRANGE = '{SelectedRange.rightUpper}'"; StreetLayer.SelectFeaturesAsync(_query, Esri.ArcGISRuntime.Mapping.SelectionMode.New); await Task.Delay(1 * 1000); StreetLayer.ClearSelection(); } } }
// Accepts two user shapes and adds them to the graphics layer private async Task AcceptShapeAsync() { // Shape One DrawShape drawShape1 = (DrawShape)comboShapeOne.SelectedItem; Geometry shapeOne = null; if (drawShape1 == DrawShape.Point) { shapeOne = await mapView.Editor.RequestPointAsync(); } else { shapeOne = await mapView.Editor.RequestShapeAsync(drawShape1, _symbols[comboShapeOne.SelectedIndex]); } graphicsLayer.Graphics.Add(new Graphic(shapeOne, _symbols[comboShapeOne.SelectedIndex])); // Shape Two Geometry shapeTwo = await mapView.Editor.RequestShapeAsync( (DrawShape)comboShapeTwo.SelectedItem, _symbols[comboShapeTwo.SelectedIndex]); graphicsLayer.Graphics.Add(new Graphic(shapeTwo, _symbols[comboShapeTwo.SelectedIndex])); Dictionary <string, bool> relations = new Dictionary <string, bool>(); relations["Contains"] = GeometryEngine.Contains(shapeOne, shapeTwo); relations["Crosses"] = GeometryEngine.Crosses(shapeOne, shapeTwo); relations["Disjoint"] = GeometryEngine.Disjoint(shapeOne, shapeTwo); relations["Equals"] = GeometryEngine.Equals(shapeOne, shapeTwo); relations["Intersects"] = GeometryEngine.Intersects(shapeOne, shapeTwo); relations["Overlaps"] = GeometryEngine.Overlaps(shapeOne, shapeTwo); relations["Touches"] = GeometryEngine.Touches(shapeOne, shapeTwo); relations["Within"] = GeometryEngine.Within(shapeOne, shapeTwo); resultsPanel.Visibility = Visibility.Visible; resultsListView.ItemsSource = relations; }
internal async void ZoomToStreet() { if (StreetLayer != null && StreetLayer is FeatureLayer) { if (Type == "INTERSECTS") { QueryParameters _query = new QueryParameters(); _query.WhereClause = $"REGISTEREDNAME = '{SelectedPrimaryStreet.name}' and STREETTYPE = '{SelectedPrimaryStreet.type}' and QUADRANT = '{SelectedPrimaryStreet.quad}'"; var prifeatures = await StreetLayer.FeatureTable.QueryFeaturesAsync(_query); _query.WhereClause = $"REGISTEREDNAME = '{SelectedIntersectingStreet.name}' and STREETTYPE = '{SelectedIntersectingStreet.type}' and QUADRANT = '{SelectedIntersectingStreet.quad}'"; var intfeatures = await StreetLayer.FeatureTable.QueryFeaturesAsync(_query); var showfeatures = new List <Feature>(); foreach (var prifeature in prifeatures) { foreach (var intfeature in intfeatures) { if (GeometryEngine.Touches(prifeature.Geometry, intfeature.Geometry)) { showfeatures.Add(prifeature); showfeatures.Add(intfeature); } } } var strings = showfeatures.Select(feature => $"OBJECTID = {feature.Attributes["OBJECTID"]?.ToString()}"); _query.WhereClause = String.Join(" or ", strings.ToArray()); var features = await StreetLayer.FeatureTable.QueryFeaturesAsync(_query); if (features.Count() > 0) { try { var newGeometry = GeometryEngine.Union(features.Select(ft => ft.Geometry)); MapVM.MapView?.SetViewpointGeometryAsync(newGeometry, 2); }catch (Exception e) { MessageBox.Show(e.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } } else { QueryParameters _query = new QueryParameters(); _query.WhereClause = $"REGISTEREDNAME = '{SelectedPrimaryStreet.name}' and STREETTYPE = '{SelectedPrimaryStreet.type}' and QUADRANT = '{SelectedPrimaryStreet.quad}'"; _query.WhereClause = _query.WhereClause + $" and FROMLEFTTHEORETICRANGE = '{SelectedRange.leftLower}' and TOLEFTTHEORETICRANGE = '{SelectedRange.leftUpper}' and FROMRIGHTTHEORETICRANGE = '{SelectedRange.rightLower}' and TORIGHTTHEORETICRANGE = '{SelectedRange.rightUpper}'"; var features = await StreetLayer.FeatureTable.QueryFeaturesAsync(_query); if (features.Count() > 0) { try { var newGeometry = GeometryEngine.Union(features.Select(ft => ft.Geometry)); MapVM.MapView?.SetViewpointGeometryAsync(newGeometry, 2); } catch (Exception e) { MessageBox.Show(e.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } } } }