private async void ArtistListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { // Get the selected track info TrackInfo ti = ArtistListBox.SelectedItem as TrackInfo; // If the track info is good, show it in the info panel if (ti == null) { return; } ArtistInfoPanel.DataContext = ti; // Filter the layers by artist ID string artistFilter = "artistid = '" + ti.ArtistId + "'"; _artistHometownLayer.DefinitionExpression = artistFilter; _listenerLayer.DefinitionExpression = artistFilter; _otherLocationsLayer.DefinitionExpression = artistFilter; // Make sure all layers are visible except tours _artistHometownLayer.IsVisible = true; _listenerLayer.IsVisible = true; _otherLocationsLayer.IsVisible = true; _tourLayer.IsVisible = false; // Dismiss any tour event callouts ArtistMapView.DismissCallout(); // Zoom the main map to the artist hometown await ArtistMapView.SetViewpointCenterAsync(ti.HometownLocation, 250000); // Zoom the listener map to the extent of features in the listener layer QueryParameters query = new QueryParameters { WhereClause = artistFilter }; FeatureQueryResult listenerQueryResult = await _listenerLayer.FeatureTable.QueryFeaturesAsync(query); EnvelopeBuilder extentBuilder = new EnvelopeBuilder(ListenersMapView.SpatialReference); foreach (Feature f in listenerQueryResult) { extentBuilder.UnionOf(f.Geometry.Extent); } Envelope extent = extentBuilder.ToGeometry(); if (extent.IsEmpty) { return; } await ListenersMapView.SetViewpointGeometryAsync(extentBuilder.ToGeometry(), 30); }
private void UpdateMapExtent() { // Return if mapview is null. if (myMapView == null) { return; } // Get the new viewpoint. Viewpoint myViewPoint = myMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry); // Return if viewpoint is null. if (myViewPoint == null) { return; } // Get the updated extent for the new viewpoint. Envelope extent = myViewPoint.TargetGeometry as Envelope; // Return if extent is null. if (extent == null) { return; } // Create an envelope that is a bit smaller than the extent. EnvelopeBuilder envelopeBldr = new EnvelopeBuilder(extent); envelopeBldr.Expand(0.80); // Get the (only) graphics overlay in the map view. GraphicsOverlay extentOverlay = myMapView.GraphicsOverlays.FirstOrDefault(); // Return if the extent overlay is null. if (extentOverlay == null) { return; } // Get the extent graphic. Graphic extentGraphic = extentOverlay.Graphics.FirstOrDefault(); // Create the extent graphic and add it to the overlay if it doesn't exist. if (extentGraphic == null) { extentGraphic = new Graphic(envelopeBldr.ToGeometry()); extentOverlay.Graphics.Add(extentGraphic); } else { // Otherwise, update the graphic's geometry. extentGraphic.Geometry = envelopeBldr.ToGeometry(); } }
private void MapView_ExtentChanged(object sender, EventArgs e) { Envelope newExtent = null; if (MyMapView.WrapAround) { Geometry normalizedExtent = GeometryEngine.NormalizeCentralMeridian(MyMapView.Extent); if (normalizedExtent is Polygon) { var normalizedPolygon = (Polygon)normalizedExtent; if (normalizedPolygon.Parts.Count == 1) { newExtent = normalizedPolygon.Extent; } else { var newExtentBuilder = new EnvelopeBuilder(MyMapView.SpatialReference); foreach (var p in normalizedPolygon.Parts[0].GetPoints()) { if (p.X < newExtentBuilder.XMin || double.IsNaN(newExtentBuilder.XMin)) { newExtentBuilder.XMin = p.X; } if (p.Y < newExtentBuilder.YMin || double.IsNaN(newExtentBuilder.YMin)) { newExtentBuilder.YMin = p.Y; } } foreach (var p in normalizedPolygon.Parts[1].GetPoints()) { if (p.X > newExtentBuilder.XMax || double.IsNaN(newExtentBuilder.XMax)) { newExtentBuilder.XMax = p.X; } if (p.Y > newExtentBuilder.YMax || double.IsNaN(newExtentBuilder.YMax)) { newExtentBuilder.YMax = p.Y; } } newExtent = newExtentBuilder.ToGeometry(); } } else if (normalizedExtent is Envelope) { newExtent = normalizedExtent as Envelope; } } else { newExtent = MyMapView.Extent; } MinXNormalized.Text = newExtent.XMin.ToString("0.000"); MinYNormalized.Text = newExtent.YMin.ToString("0.000"); MaxXNormalized.Text = newExtent.XMax.ToString("0.000"); MaxYNormalized.Text = newExtent.YMax.ToString("0.000"); }
public async void UpdateExtents(object sender, RoutedEventArgs e) { statusTextBlock.Text = "Updating Extents"; QueryParameters queryParams = new QueryParameters(); queryParams.WhereClause = "TaxID LIKE '" + _currTaxID + "'"; FeatureQueryResult queryResult = await sfFeatTable.QueryFeaturesAsync(queryParams); List <Feature> features = queryResult.ToList(); if (features.Any()) { EnvelopeBuilder envBuilder = new EnvelopeBuilder(SpatialReference.Create(102715)); foreach (Feature feature in features) { envBuilder.UnionOf(feature.Geometry.Extent); newFeatureLayer.ClearSelection(); newFeatureLayer.SelectFeature(feature); } await MyMapView.SetViewpointGeometryAsync(envBuilder.ToGeometry(), 20); statusTextBlock.Text = ""; } else { statusTextBlock.Text = "No parcel found for current query"; } }
private void Initialize() { // Create a spatial reference that's suitable for creating planar buffers in north central Texas (State Plane). SpatialReference statePlaneNorthCentralTexas = new SpatialReference(32038); // Define a polygon that represents the valid area of use for the spatial reference. // This information is available at https://developers.arcgis.com/net/latest/wpf/guide/pdf/projected_coordinate_systems_rt100_3_0.pdf List <MapPoint> spatialReferenceExtentCoords = new List <MapPoint> { new MapPoint(-103.070, 31.720, SpatialReferences.Wgs84), new MapPoint(-103.070, 34.580, SpatialReferences.Wgs84), new MapPoint(-94.000, 34.580, SpatialReferences.Wgs84), new MapPoint(-94.00, 31.720, SpatialReferences.Wgs84) }; _spatialReferenceArea = new Polygon(spatialReferenceExtentCoords); _spatialReferenceArea = GeometryEngine.Project(_spatialReferenceArea, statePlaneNorthCentralTexas) as Polygon; // Create a map that uses the North Central Texas state plane spatial reference. Map bufferMap = new Map(statePlaneNorthCentralTexas); // Add some base layers (counties, cities, and highways). Uri usaLayerSource = new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer"); ArcGISMapImageLayer usaLayer = new ArcGISMapImageLayer(usaLayerSource); bufferMap.Basemap.BaseLayers.Add(usaLayer); // Use a new EnvelopeBuilder to expand the spatial reference extent 120%. EnvelopeBuilder envBuilder = new EnvelopeBuilder(_spatialReferenceArea.Extent); envBuilder.Expand(1.2); // Set the map's initial extent to the expanded envelope. Envelope startingEnvelope = envBuilder.ToGeometry(); bufferMap.InitialViewpoint = new Viewpoint(startingEnvelope); // Assign the map to the MapView. _myMapView.Map = bufferMap; // Create a graphics overlay to show the buffer polygon graphics. GraphicsOverlay bufferGraphicsOverlay = new GraphicsOverlay { // Give the overlay an ID so it can be found later. Id = "buffers" }; // Create a graphic to show the spatial reference's valid extent (envelope) with a dashed red line. SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, Color.Red, 5); Graphic spatialReferenceExtentGraphic = new Graphic(_spatialReferenceArea, lineSymbol); // Add the graphic to a new overlay. GraphicsOverlay spatialReferenceGraphicsOverlay = new GraphicsOverlay(); spatialReferenceGraphicsOverlay.Graphics.Add(spatialReferenceExtentGraphic); // Add the graphics overlays to the MapView. _myMapView.GraphicsOverlays.Add(bufferGraphicsOverlay); _myMapView.GraphicsOverlays.Add(spatialReferenceGraphicsOverlay); }
/// <summary> /// This method must be called on the MCT /// </summary> /// <remarks>If multiple features are selected just the ObjectID of the first feature /// in the selected set is returned</remarks> /// <param name="point"></param> /// <returns>The object id of the selected feature or -1</returns> internal static Polyline SelectLineFeature(MapPoint point) { if (OnUIThread) { throw new CalledOnWrongThreadException(); } var pt = MapView.Active.MapToClient(point); double llx = pt.X - 5; double lly = pt.Y - 5; double urx = pt.X + 5; double ury = pt.Y + 5; EnvelopeBuilder envBuilder = new EnvelopeBuilder(MapView.Active.ClientToMap(new Point(llx, lly)), MapView.Active.ClientToMap(new Point(urx, ury))); //Just get feature layers that are line types var selection = MapView.Active.SelectFeatures(envBuilder.ToGeometry()).Where( k => k.Key.ShapeType == esriGeometryType.esriGeometryPolyline ).ToList(); Polyline selectedLine = null; if (selection.Count() > 0) { //return the first of the selected features var flayer = selection.First().Key; var oid = selection.First().Value[0]; var inspector = new Inspector(); inspector.Load(flayer, oid); selectedLine = inspector["SHAPE"] as Polyline; } return(selectedLine); }
// 관리번호로 해당Feature 객체찾기 public async void SelectFct(string _FTR_CDE, string _FTR_IDN, FeatureLayer _featureLayer) { // 0.Feature 테이블 가져오기 //FeatureLayer __featureLayer = _featureLayer.Clone() as FeatureLayer; FeatureTable _featureTable = _featureLayer.FeatureTable; // Create a query parameters that will be used to Query the feature table. QueryParameters queryParams = new QueryParameters(); // Construct and assign the where clause that will be used to query the feature table. queryParams.WhereClause = " FTR_CDE = '" + _FTR_CDE + "' ORDER BY FTR_IDN DESC"; if (!FmsUtil.IsNull(_FTR_IDN)) { queryParams.WhereClause = " FTR_CDE = '" + _FTR_CDE + "' AND FTR_IDN like '%' || " + _FTR_IDN + " || '%'"; } List <Feature> features; try { // Query the feature table. FeatureQueryResult queryResult = await _featureTable.QueryFeaturesAsync(queryParams); // Cast the QueryResult to a List so the results can be interrogated. features = queryResult.ToList(); } catch (Exception e) { Messages.ShowErrMsgBox(e.Message); return; } if (features.Any()) { // Create an envelope. EnvelopeBuilder envBuilder = new EnvelopeBuilder(SpatialReferences.WebMercator); if (features.Count == 1) { //한건인 경우 선택처리 ShowFctPage(features[0]); } else { //피쳐영역 Extent 위치이동 foreach (Feature feature in features) { envBuilder.UnionOf(feature.Geometry.Extent); //복수의 피처영역 합치기 } // Zoom to the extent of the selected feature(s). await mapView.SetViewpointGeometryAsync(envBuilder.ToGeometry(), 50); } } }
private void Initialize() { // Define the route stop locations (points) MapPoint fromPoint = new MapPoint(-117.15494348793044, 32.706506537686927, SpatialReferences.Wgs84); MapPoint toPoint = new MapPoint(-117.14905088669816, 32.735308180609138, SpatialReferences.Wgs84); // Create Stop objects with the points and add them to a list of stops Stop stop1 = new Stop(fromPoint); Stop stop2 = new Stop(toPoint); _routeStops = new List <Stop> { stop1, stop2 }; // Picture marker symbols: from = car, to = checkered flag PictureMarkerSymbol carSymbol = new PictureMarkerSymbol(_carIconUri) { Height = 40, Width = 40 }; PictureMarkerSymbol flagSymbol = new PictureMarkerSymbol(_checkedFlagIconUri) { Height = 40, Width = 40, // Offset the icon so that it is anchored at the bottom of the flagpole OffsetX = 20, OffsetY = 20 }; // Create graphics for the stops Graphic fromGraphic = new Graphic(fromPoint, carSymbol) { // Make sure the icons are shown over the route line ZIndex = 1 }; Graphic toGraphic = new Graphic(toPoint, flagSymbol) { ZIndex = 1 }; // Create the graphics overlay and add the stop graphics _routeGraphicsOverlay = new GraphicsOverlay(); _routeGraphicsOverlay.Graphics.Add(fromGraphic); _routeGraphicsOverlay.Graphics.Add(toGraphic); // Get an Envelope that covers the area of the stops (and a little more) Envelope routeStopsExtent = new Envelope(fromPoint, toPoint); EnvelopeBuilder envBuilder = new EnvelopeBuilder(routeStopsExtent); envBuilder.Expand(1.5); // Create a new viewpoint apply it to the map view when the spatial reference changes Viewpoint sanDiegoViewpoint = new Viewpoint(envBuilder.ToGeometry()); _myMapView.SpatialReferenceChanged += (s, e) => _myMapView.SetViewpoint(sanDiegoViewpoint); // Add a new Map and the graphics overlay to the map view _myMapView.Map = new Map(Basemap.CreateStreets()); _myMapView.GraphicsOverlays.Add(_routeGraphicsOverlay); }
private void Initialize() { // Define the route stop locations (points) MapPoint fromPoint = new MapPoint(-117.15494348793044, 32.706506537686927, SpatialReferences.Wgs84); MapPoint toPoint = new MapPoint(-117.14905088669816, 32.735308180609138, SpatialReferences.Wgs84); // Create Stop objects with the points and add them to a list of stops Stop stop1 = new Stop(fromPoint); Stop stop2 = new Stop(toPoint); _routeStops = new List <Stop> { stop1, stop2 }; // Picture marker symbols: from = car, to = checkered flag PictureMarkerSymbol carSymbol = new PictureMarkerSymbol(_carIconUri); PictureMarkerSymbol flagSymbol = new PictureMarkerSymbol(_checkedFlagIconUri); // Add a slight offset (pixels) to the picture symbols. carSymbol.OffsetX = -carSymbol.Width / 2; carSymbol.OffsetY = -carSymbol.Height / 2; flagSymbol.OffsetX = -flagSymbol.Width / 2; flagSymbol.OffsetY = -flagSymbol.Height / 2; // Set the height and width. flagSymbol.Height = 60; flagSymbol.Width = 60; carSymbol.Height = 60; carSymbol.Width = 60; // Create graphics for the stops Graphic fromGraphic = new Graphic(fromPoint, carSymbol) { ZIndex = 1 }; Graphic toGraphic = new Graphic(toPoint, flagSymbol) { ZIndex = 1 }; // Create the graphics overlay and add the stop graphics _routeGraphicsOverlay = new GraphicsOverlay(); _routeGraphicsOverlay.Graphics.Add(fromGraphic); _routeGraphicsOverlay.Graphics.Add(toGraphic); // Get an Envelope that covers the area of the stops (and a little more) Envelope routeStopsExtent = new Envelope(fromPoint, toPoint); EnvelopeBuilder envBuilder = new EnvelopeBuilder(routeStopsExtent); envBuilder.Expand(1.5); // Create a new viewpoint apply it to the map view when the spatial reference changes Viewpoint sanDiegoViewpoint = new Viewpoint(envBuilder.ToGeometry()); MyMapView.SpatialReferenceChanged += (s, e) => MyMapView.SetViewpoint(sanDiegoViewpoint); // Add a new Map and the graphics overlay to the map view MyMapView.Map = new Map(BasemapStyle.ArcGISStreets); MyMapView.GraphicsOverlays.Add(_routeGraphicsOverlay); }
private Task <Tuple <IDisposable, long> > AddFeatureToOverlay(MapViewMouseEventArgs e) { return(QueuedTask.Run(() => { double llx = e.ClientPoint.X - 3; double lly = e.ClientPoint.Y - 3; double urx = e.ClientPoint.X + 3; double ury = e.ClientPoint.Y + 3; EnvelopeBuilder envBuilder = new EnvelopeBuilder(ActiveMapView.ClientToMap(new Point(llx, lly)), ActiveMapView.ClientToMap(new Point(urx, ury))); MapPoint mp = ActiveMapView.ClientToMap(e.ClientPoint); var cursor = _trees.Search(new SpatialQueryFilter() { FilterGeometry = envBuilder.ToGeometry(), SpatialRelationship = SpatialRelationship.Intersects }); if (cursor.MoveNext()) { return new Tuple <IDisposable, long>( ActiveMapView.AddOverlay(ActiveMapView.ClientToMap(e.ClientPoint), _overlaySymbol.MakeSymbolReference()), cursor.Current.GetObjectID()); } //var select = _trees.Select(new SpatialQueryFilter() { // FilterGeometry = envBuilder.ToGeometry(), // SpatialRelationship = SpatialRelationship.Intersects //}); //if (select.GetCount() > 0) { // return ActiveMapView.AddOverlay(ActiveMapView.ClientToMap(e.ClientPoint), _overlaySymbol.MakeSymbolReference()); //} return new Tuple <IDisposable, long>(null, -1); })); }
private async void Initialize() { // Get all the ColorRamp names from the PresetColorRampType Enumeration and put them // in an array of strings, then set the ComboBox.ItemSource to the array, and finally // select the first item in the ComboBox string[] myPresetColorRampTypes = Enum.GetNames(typeof(PresetColorRampType)); ColorRamps.ItemsSource = myPresetColorRampTypes; ColorRamps.SelectedIndex = 0; // Get all the SlopeType names from the SlopeType Enumeration and put them // in an array of strings, then set the ComboBox.ItemSource to the array, and finally // select the first item in the ComboBox string[] mySlopeTypes = Enum.GetNames(typeof(SlopeType)); SlopeTypes.ItemsSource = mySlopeTypes; SlopeTypes.SelectedIndex = 0; // Set the altitude slider min/max and initial value Altitude_Slider.Minimum = 0; Altitude_Slider.Maximum = 90; Altitude_Slider.Value = 45; // Set the azimuth slider min/max and initial value Azimuth_Slider.Minimum = 0; Azimuth_Slider.Maximum = 360; Azimuth_Slider.Value = 180; // Load the raster file using a path on disk Raster myRasterImagery = new Raster(GetRasterPath_Imagery()); // Create the raster layer from the raster RasterLayer myRasterLayerImagery = new RasterLayer(myRasterImagery); // Create a new map using the raster layer as the base map Map myMap = new Map(new Basemap(myRasterLayerImagery)); // Wait for the layer to load - this enabled being able to obtain the extent information // of the raster layer await myRasterLayerImagery.LoadAsync(); // Create a new EnvelopeBuilder from the full extent of the raster layer EnvelopeBuilder myEnvelopBuilder = new EnvelopeBuilder(myRasterLayerImagery.FullExtent); // Zoom in the extent just a bit so that raster layer encompasses the entire viewable area of the map myEnvelopBuilder.Expand(0.75); // Set the viewpoint of the map to the EnvelopeBuilder's extent myMap.InitialViewpoint = new Viewpoint(myEnvelopBuilder.ToGeometry().Extent); // Add map to the map view MyMapView.Map = myMap; // Wait for the map to load await myMap.LoadAsync(); // Enable the 'Update Renderer' button now that the map has loaded UpdateRenderer.IsEnabled = true; }
private void MapView_ExtentChanged(object sender, System.EventArgs e) { Envelope newExtent = null; // Get current viewpoints extent from the MapView var currentViewpoint = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry); var viewpointExtent = currentViewpoint.TargetGeometry.Extent; if (MyMapView.WrapAround) { Geometry normalizedExtent = GeometryEngine.NormalizeCentralMeridian(viewpointExtent); if (normalizedExtent is Polygon) { var normalizedPolygon = (Polygon)normalizedExtent; if (normalizedPolygon.Parts.Count == 1) newExtent = normalizedPolygon.Extent; else { var newExtentBuilder = new EnvelopeBuilder(MyMapView.SpatialReference); foreach (var p in normalizedPolygon.Parts[0].GetPoints()) { if (Geometry.IsNullOrEmpty(newExtent) || p.X < newExtent.XMin || double.IsNaN(newExtent.XMin)) newExtentBuilder.XMin = p.X; if (Geometry.IsNullOrEmpty(newExtent) || p.Y < newExtent.YMin || double.IsNaN(newExtent.YMin)) newExtentBuilder.YMin = p.Y; } foreach (var p in normalizedPolygon.Parts[1].GetPoints()) { if (Geometry.IsNullOrEmpty(newExtent) || p.X > newExtent.XMax || double.IsNaN(newExtent.XMax)) newExtentBuilder.XMax = p.X; if (Geometry.IsNullOrEmpty(newExtent) || p.Y > newExtent.YMax || double.IsNaN(newExtent.YMax)) newExtentBuilder.YMax = p.Y; } newExtent = newExtentBuilder.ToGeometry(); } } else if (normalizedExtent is Envelope) newExtent = normalizedExtent as Envelope; } else newExtent = viewpointExtent; MinXNormalized.Text = newExtent.XMin.ToString("0.000"); MinYNormalized.Text = newExtent.YMin.ToString("0.000"); MaxXNormalized.Text = newExtent.XMax.ToString("0.000"); MaxYNormalized.Text = newExtent.YMax.ToString("0.000"); MinXAbsolute.Text = viewpointExtent.XMin.ToString("0.000"); MinYAbsolute.Text = viewpointExtent.YMin.ToString("0.000"); MaxXAbsolute.Text = viewpointExtent.XMax.ToString("0.000"); MaxYAbsolute.Text = viewpointExtent.YMax.ToString("0.000"); }
private async Task QueryStateFeature(string stateName) { try { // Hide keyboard. _queryTextView.ResignFirstResponder(); // Create a query parameters that will be used to Query the feature table. QueryParameters queryParams = new QueryParameters(); // Trim whitespace on the state name to prevent broken queries. string formattedStateName = stateName.Trim().ToUpper(); // Construct and assign the where clause that will be used to query the feature table. queryParams.WhereClause = "upper(STATE_NAME) LIKE '%" + formattedStateName + "%'"; // Query the feature table. FeatureQueryResult queryResult = await _featureTable.QueryFeaturesAsync(queryParams); // Cast the QueryResult to a List so the results can be interrogated. List <Feature> features = queryResult.ToList(); if (features.Any()) { // Create an envelope. EnvelopeBuilder envBuilder = new EnvelopeBuilder(SpatialReferences.WebMercator); // Loop over each feature from the query result. foreach (Feature feature in features) { // Add the extent of each matching feature to the envelope. envBuilder.UnionOf(feature.Geometry.Extent); // Select each feature. _featureLayer.SelectFeature(feature); } // Zoom to the extent of the selected feature(s). await _myMapView.SetViewpointGeometryAsync(envBuilder.ToGeometry(), 50); } else { UIAlertView alert = new UIAlertView("State Not Found!", "Add a valid state name.", (IUIAlertViewDelegate)null, "OK", null); alert.Show(); } } catch (Exception ex) { UIAlertView alert = new UIAlertView("Sample error", ex.ToString(), (IUIAlertViewDelegate)null, "OK", null); alert.Show(); } }
private async Task QueryStateFeature(string stateName) { // Create dialog to display alert information AlertDialog.Builder alert = new AlertDialog.Builder(this); try { // Create a query parameters that will be used to Query the feature table QueryParameters queryParams = new QueryParameters { // Construct and assign the where clause that will be used to query the feature table WhereClause = "upper(STATE_NAME) LIKE '%" + stateName.Trim().ToUpper() + "%'" }; // Query the feature table FeatureQueryResult queryResult = await _featureTable.QueryFeaturesAsync(queryParams); // Cast the QueryResult to a List so the results can be interrogated. List <Feature> features = queryResult.ToList(); if (features.Any()) { // Create an envelope. EnvelopeBuilder envBuilder = new EnvelopeBuilder(SpatialReferences.WebMercator); // Loop over each feature from the query result. foreach (Feature feature in features) { // Add the extent of each matching feature to the envelope. envBuilder.UnionOf(feature.Geometry.Extent); // Select each feature. _featureLayer.SelectFeature(feature); } // Zoom to the extent of the selected feature(s). await _myMapView.SetViewpointGeometryAsync(envBuilder.ToGeometry(), 50); } else { alert.SetTitle("State Not Found!"); alert.SetMessage("Add a valid state name."); alert.Show(); } } catch (Exception ex) { alert.SetTitle("Sample Error"); alert.SetMessage(ex.Message); alert.Show(); } }
private async void Initialize() { try { // Set the altitude slider min/max and initial value (minimum is always 0 - do // not set _Altitude_Slider.Min = 0) _Slider_Altitude.Max = 90; _Slider_Altitude.Progress = 45; // Set the azimuth slider min/max and initial value (minimum is always 0 - do // not set _AZimuth_Slider.Min = 0) _Slider_Azimuth.Max = 360; _Slider_Azimuth.Progress = 180; // Load the raster file using a path on disk Raster myRasterImagery = new Raster(await GetRasterPath_Imagery()); // Create the raster layer from the raster RasterLayer myRasterLayerImagery = new RasterLayer(myRasterImagery); // Create a new map using the raster layer as the base map Map myMap = new Map(new Basemap(myRasterLayerImagery)); // Wait for the layer to load - this enabled being able to obtain the extent information // of the raster layer await myRasterLayerImagery.LoadAsync(); // Create a new EnvelopeBuilder from the full extent of the raster layer EnvelopeBuilder myEnvelopBuilder = new EnvelopeBuilder(myRasterLayerImagery.FullExtent); // Zoom in the extent just a bit so that raster layer encompasses the entire viewable // area of the map myEnvelopBuilder.Expand(0.75); // Set the viewpoint of the map to the EnvelopeBuilder's extent myMap.InitialViewpoint = new Viewpoint(myEnvelopBuilder.ToGeometry().Extent); // Add map to the map view _myMapView.Map = myMap; // Wait for the map to load await myMap.LoadAsync(); // Enable the 'Update Renderer' button now that the map has loaded _Button_UpdateRenderer.Enabled = true; } catch (Exception ex) { Console.WriteLine(ex); } }
private async void Initialize() { // Set the altitude slider min/max and initial value. _altitudeSlider.MinValue = 0; _altitudeSlider.MaxValue = 90; _altitudeSlider.Value = 45; // Set the azimuth slider min/max and initial value. _azimuthSlider.MinValue = 0; _azimuthSlider.MaxValue = 360; _azimuthSlider.Value = 180; // Load the raster file using a path on disk. Raster rasterImagery = new Raster(DataManager.GetDataFolder("7c4c679ab06a4df19dc497f577f111bd", "raster-file", "Shasta.tif")); // Create the raster layer from the raster. RasterLayer rasterLayerImagery = new RasterLayer(rasterImagery); // Create a new map using the raster layer as the base map. Map map = new Map(new Basemap(rasterLayerImagery)); try { // Wait for the layer to load - this enabled being able to obtain the raster layer's extent. await rasterLayerImagery.LoadAsync(); // Create a new EnvelopeBuilder from the full extent of the raster layer. EnvelopeBuilder envelopeBuilder = new EnvelopeBuilder(rasterLayerImagery.FullExtent); // Zoom in the extent just a bit so that raster layer encompasses the entire viewable area of the map. envelopeBuilder.Expand(0.75); // Set the viewpoint of the map to the EnvelopeBuilder's extent. map.InitialViewpoint = new Viewpoint(envelopeBuilder.ToGeometry().Extent); // Add map to the map view. _myMapView.Map = map; // Wait for the map to load. await map.LoadAsync(); // Enable the 'Update Renderer' button now that the map has loaded. _updateRendererButton.Enabled = true; } catch (Exception e) { new UIAlertView("Error", e.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show(); } }
public SetSpatialReference() { this.InitializeComponent(); // Create initial extend and set it note that this doesn't set MapView.SpatialReference. var envelopeBuilder = new EnvelopeBuilder(SpatialReference.Create(26777)); envelopeBuilder.XMin = 661140; envelopeBuilder.YMin = -1420246; envelopeBuilder.XMax = 3015668; envelopeBuilder.YMax = 1594451; MyMapView.Map.InitialViewpoint = new Esri.ArcGISRuntime.Controls.Viewpoint(envelopeBuilder.ToGeometry()); MyMapView.Map.SpatialReference = SpatialReference.Create(26777); //Force map spatial reference to Wkid=26777 }
private Raster SetupRaster(Raster raster, int size = 50) { // Set raster size. var evExtent = new EnvelopeBuilder(0, 0, size * 300, size * 300); raster.SetExtent(evExtent.ToGeometry()); raster.SetHeight(size); raster.SetWidth(size); raster.SetResamplingType(ArcGIS.Core.CIM.RasterResamplingType.NearestNeighbor); raster.SetNoDataValue(0); return(raster); }
private async void Initialize() { // Update the preset color ramp type options and select the first one. ColorRamps.ItemsSource = Enum.GetNames(typeof(PresetColorRampType)); ColorRamps.SelectedIndex = 0; // Update the slope options and select the first one. SlopeTypes.ItemsSource = Enum.GetNames(typeof(SlopeType)); SlopeTypes.SelectedIndex = 0; // Load the raster file using a path on disk. Raster myRasterImagery = new Raster(GetRasterPath_Imagery()); // Create the raster layer from the raster. RasterLayer myRasterLayerImagery = new RasterLayer(myRasterImagery); // Create a new map using the raster layer as the base map. Map myMap = new Map(new Basemap(myRasterLayerImagery)); try { // Wait for the layer to load - this enabled being able to obtain the extent information // of the raster layer. await myRasterLayerImagery.LoadAsync(); // Create a new EnvelopeBuilder from the full extent of the raster layer. EnvelopeBuilder myEnvelopBuilder = new EnvelopeBuilder(myRasterLayerImagery.FullExtent); // Zoom in the extent just a bit so that raster layer encompasses the entire viewable area of the map. myEnvelopBuilder.Expand(0.75); // Set the viewpoint of the map to the EnvelopeBuilder's extent. myMap.InitialViewpoint = new Viewpoint(myEnvelopBuilder.ToGeometry().Extent); // Add map to the map view. MyMapView.Map = myMap; // Wait for the map to load. await myMap.LoadAsync(); // Enable the 'Update Renderer' button now that the map has loaded. UpdateRenderer.IsEnabled = true; } catch (Exception e) { MessageBox.Show(e.ToString(), "Error"); } }
private async Task QueryStateFeature(string stateName) { try { // Create a query parameters that will be used to Query the feature table QueryParameters queryParams = new QueryParameters(); // Trim whitespace on the state name to prevent broken queries string formattedStateName = stateName.Trim().ToUpper(); // Construct and assign the where clause that will be used to query the feature table queryParams.WhereClause = "upper(STATE_NAME) LIKE '%" + formattedStateName + "%'"; // Query the feature table FeatureQueryResult queryResult = await _featureTable.QueryFeaturesAsync(queryParams); // Cast the QueryResult to a List so the results can be interrogated List <Feature> features = queryResult.ToList(); if (features.Any()) { // Create an envelope. EnvelopeBuilder envBuilder = new EnvelopeBuilder(SpatialReferences.WebMercator); foreach (Feature feature in features) { // Add the extent of each matching feature to the envelope. envBuilder.UnionOf(feature.Geometry.Extent); // Select each feature. _featureLayer.SelectFeature(feature); } // Zoom to the extent of the selected feature(s). await MyMapView.SetViewpointGeometryAsync(envBuilder.ToGeometry(), 50); } else { MessageDialog message = new MessageDialog("State Not Found!", "Add a valid state name."); await message.ShowAsync(); } } catch (Exception ex) { MessageDialog message = new MessageDialog("Sample error: " + ex, "An error occurred"); await message.ShowAsync(); } }
public static Envelope GetGraphicsEnvelope(GraphicCollection gc) { if (gc.Count == 0) { return(null); } EnvelopeBuilder envBuilder = new EnvelopeBuilder(gc[0].Geometry.Extent); Envelope env = envBuilder.ToGeometry(); foreach (Graphic g in gc) { env.Union(g.Geometry.Extent); } return(env); }
private void MapView_ExtentChanged(object sender, EventArgs e) { Envelope newExtent = null; if (MyMapView.WrapAround) { Geometry normalizedExtent = GeometryEngine.NormalizeCentralMeridian(MyMapView.Extent); if (normalizedExtent is Polygon) { var normalizedPolygon = (Polygon)normalizedExtent; if (normalizedPolygon.Parts.Count == 1) newExtent = normalizedPolygon.Extent; else { var newExtentBuilder = new EnvelopeBuilder(MyMapView.SpatialReference); foreach (var p in normalizedPolygon.Parts[0].GetPoints()) { if (p.X < newExtentBuilder.XMin || double.IsNaN(newExtentBuilder.XMin)) newExtentBuilder.XMin = p.X; if (p.Y < newExtentBuilder.YMin || double.IsNaN(newExtentBuilder.YMin)) newExtentBuilder.YMin = p.Y; } foreach (var p in normalizedPolygon.Parts[1].GetPoints()) { if (p.X > newExtentBuilder.XMax || double.IsNaN(newExtentBuilder.XMax)) newExtentBuilder.XMax = p.X; if (p.Y > newExtentBuilder.YMax || double.IsNaN(newExtentBuilder.YMax)) newExtentBuilder.YMax = p.Y; } newExtent = newExtentBuilder.ToGeometry(); } } else if (normalizedExtent is Envelope) newExtent = normalizedExtent as Envelope; } else newExtent = MyMapView.Extent; MinXNormalized.Text = newExtent.XMin.ToString("0.000"); MinYNormalized.Text = newExtent.YMin.ToString("0.000"); MaxXNormalized.Text = newExtent.XMax.ToString("0.000"); MaxYNormalized.Text = newExtent.YMax.ToString("0.000"); }
private async void Initialize() { // Set the altitude slider min/max and initial value _Altitude_Slider.MinValue = 0; _Altitude_Slider.MaxValue = 90; _Altitude_Slider.Value = 45; // Set the azimuth slider min/max and initial value _Azimuth_Slider.MinValue = 0; _Azimuth_Slider.MaxValue = 360; _Azimuth_Slider.Value = 180; // Load the raster file using a path on disk Raster myRasterImagery = new Raster(GetRasterPath_Imagery()); // Create the raster layer from the raster RasterLayer myRasterLayerImagery = new RasterLayer(myRasterImagery); // Create a new map using the raster layer as the base map Map myMap = new Map(new Basemap(myRasterLayerImagery)); // Wait for the layer to load - this enabled being able to obtain the extent information // of the raster layer await myRasterLayerImagery.LoadAsync(); // Create a new EnvelopeBuilder from the full extent of the raster layer EnvelopeBuilder myEnvelopBuilder = new EnvelopeBuilder(myRasterLayerImagery.FullExtent); // Zoom in the extent just a bit so that raster layer encompasses the entire viewable area of the map myEnvelopBuilder.Expand(0.75); // Set the viewpoint of the map to the EnvelopeBuilder's extent myMap.InitialViewpoint = new Viewpoint(myEnvelopBuilder.ToGeometry().Extent); // Add map to the map view _myMapView.Map = myMap; // Wait for the map to load await myMap.LoadAsync(); // Enable the 'Update Renderer' button now that the map has loaded _UpdateRenderer.Enabled = true; }
/// <summary> /// Get the extent for the dataset (if it has one) /// </summary> /// <remarks>Ideally, your plugin table should return an extent even if it is /// empty</remarks> /// <returns><see cref="Envelope"/></returns> public override Envelope GetExtent() { if (_gisExtent == null) { var builder = new EnvelopeBuilder(EnvelopeBuilder.CreateEnvelope( _tableInfo.ExtentLeft, _tableInfo.ExtentBottom, _tableInfo.ExtentRight, _tableInfo.ExtentTop, _spatialReference)); //Assume 0 for Z { builder.ZMin = 0; builder.ZMax = 0; } builder.HasZ = false; builder.HasM = false; return(builder.ToGeometry()); } return(_gisExtent); }
private async void Initialize() { // Load the raster file using a path on disk. Raster rasterImagery = new Raster(DataManager.GetDataFolder("7c4c679ab06a4df19dc497f577f111bd", "raster-file", "Shasta.tif")); // Create the raster layer from the raster. RasterLayer rasterLayerImagery = new RasterLayer(rasterImagery); // Create a new map using the raster layer as the base map. Map map = new Map(new Basemap(rasterLayerImagery)); try { // Wait for the layer to load - this enabled being able to obtain the raster layer's extent. await rasterLayerImagery.LoadAsync(); // Create a new EnvelopeBuilder from the full extent of the raster layer. EnvelopeBuilder envelopeBuilder = new EnvelopeBuilder(rasterLayerImagery.FullExtent); // Configure the settings view. _settingsVC = new BlendSettingsController(map); // Zoom in the extent just a bit so that raster layer encompasses the entire viewable area of the map. envelopeBuilder.Expand(0.75); // Set the viewpoint of the map to the EnvelopeBuilder's extent. map.InitialViewpoint = new Viewpoint(envelopeBuilder.ToGeometry().Extent); // Add map to the map view. _myMapView.Map = map; // Wait for the map to load. await map.LoadAsync(); } catch (Exception e) { new UIAlertView("Error", e.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show(); } }
public static Task<bool> DrawTraceResults(JObject jo) { var traceResults = new List<TraceResult>(); FeatureLayer pointFeatureLayer; FeatureLayer lineFeatureLayer; GetLayers(out pointFeatureLayer, out lineFeatureLayer); // the database and geometry interactions are considered fine-grained and must be executed on // the main CIM thread return QueuedTask.Run(() => { bool bZoom = true; EnvelopeBuilder envBuilder = new EnvelopeBuilder(); envBuilder.XMin = 0; envBuilder.XMax = 0; envBuilder.YMin = 0; envBuilder.YMax = 0; var env = envBuilder.ToGeometry().Extent; // start an edit operation to create new (random) point features var createOperation = new EditOperation(); createOperation.Name = "Trace Results"; createOperation.SelectNewFeatures = false; // get the feature class associated with the layer var pntFeatureClass = pointFeatureLayer.GetTable() as FeatureClass; var lineFeatureClass = lineFeatureLayer.GetTable() as FeatureClass; lineFeatureClass.Truncate(); pntFeatureClass.Truncate(); MapPoint newMapPoint = null; // retrieve the class definition of the point feature class var pntClassDefinition = pntFeatureClass.GetDefinition() as FeatureClassDefinition; // store the spatial reference as its own variable var spatialReference = pntClassDefinition.GetSpatialReference(); for (int i = 0; i < jo["results"].Count(); i++) { var result = jo["results"][i]; var name = result["name"].ToString(); var geomType = result["geometryType"].ToString(); var features = result["features"]; if (geomType == "esriGeometryPoint") { for (int j = 0; j < features.Count(); j++) { var pntFeature = features[j]; var atts = pntFeature["attributes"]; List<string> attributes = new List<string>(); if (name == "ServicePoint" || name == "Transformer") { int cnt = atts.Count(); foreach (var att in atts) { JProperty jpo = (JProperty)att; attributes.Add(jpo.Name + ":" + jpo.Value); } } string attributesString = string.Join("~", attributes); string.Join("~", attributes); double xCoord = Convert.ToDouble(pntFeature["geometry"]["x"]); double yCoord = Convert.ToDouble(pntFeature["geometry"]["y"]); var coord = new Coordinate(xCoord, yCoord); newMapPoint = MapPointBuilder.CreateMapPoint(coord, spatialReference); // queue feature creation createOperation.Create(pointFeatureLayer, newMapPoint); UnionEnvelopes(envBuilder, newMapPoint); //string geomString = xCoord.ToString() + "," + yCoord.ToString(); if (name == "Service Point" || name == "Transformer") { var oid = Convert.ToInt32(atts["OBJECTID"]); traceResults.Add(new TraceResult { ClassName = name, OID = oid, Attributes = attributesString, Geom = newMapPoint.X.ToString() + newMapPoint.Y.ToString() }); } } } else if (geomType == "esriGeometryPolyline") { for (int j = 0; j < features.Count(); j++) { var lineFeature = features[j]; var pathCount = lineFeature["geometry"]["paths"].Count(); for (int k = 0; k < pathCount; k++) { var path = lineFeature["geometry"]["paths"][k]; var coordPairCount = path.Count(); var lineCoordinates = new List<Coordinate>(coordPairCount); for (int l = 0; l < coordPairCount; l++) { var coord = path[l]; var x = Convert.ToDouble(coord[0]); var y = Convert.ToDouble(coord[1]); var vertex = new Coordinate(x, y); lineCoordinates.Add(vertex); } var newPolyline = PolylineBuilder.CreatePolyline(lineCoordinates, spatialReference); createOperation.Create(lineFeatureLayer, newPolyline); UnionEnvelopes(envBuilder, newPolyline); } } } } // execute the edit (feature creation) operation Map activeMap = MapView.Active.Map; var extent = envBuilder.ToGeometry().Extent; var expandedExtent = extent.Expand(1.2, 1.2, true); MapView.Active.ZoomTo(expandedExtent); return createOperation.ExecuteAsync(); }); }
public Task<bool> SelectFeaturesInDxLayers() { try { File.Delete(Common.GetConfiguration("DesignTxt")); } catch { } string designNameAndExpressDesignID = SelectedDesign.ToString(); int firstParen = designNameAndExpressDesignID.IndexOf("("); int lastParen = designNameAndExpressDesignID.IndexOf(")"); int selectedDesign = Convert.ToInt32(designNameAndExpressDesignID.Substring(firstParen + 1, lastParen - firstParen - 1)); var featuresInDesign = DxCommisionModel.GetFeaturesInDesign(selectedDesign); Dictionary<string, int> idsByName = new Dictionary<string, int>(); foreach (KeyValuePair<int, string> kvp in DxCommisionModel.GetNameByID) { if (kvp.Value != null && kvp.Key != null) { idsByName.Add(kvp.Value, kvp.Key); } } Dictionary<string, string> objectIDsToSelectByLayer = new Dictionary<string, string>(); foreach (var dxFe in featuresInDesign) { string className = DxCommisionModel.GetNameByID[dxFe.FeatureClassID]; if (objectIDsToSelectByLayer.ContainsKey(className) == false) { objectIDsToSelectByLayer.Add(className,dxFe.FeatureOID.ToString()); } else { objectIDsToSelectByLayer[className] += "," + dxFe.FeatureOID.ToString(); } } return QueuedTask.Run(() => { EnvelopeBuilder envBuilder = new EnvelopeBuilder(); if (true) { #region Get Extent from ArcGIS Pro StreamWriter sw = File.CreateText(Common.GetConfiguration("DesignTxt")); //Determine the extent //EnvelopeBuilder envBuilder = new EnvelopeBuilder(); envBuilder.XMin = 0; envBuilder.XMax = 0; envBuilder.YMin = 0; envBuilder.YMax = 0; var env = envBuilder.ToGeometry().Extent; List<FeatureLayer> dxLayers = GetDxLayers(); foreach (var f in dxLayers) { try { if (objectIDsToSelectByLayer.ContainsKey(f.Name)) { var oids = objectIDsToSelectByLayer[f.Name]; if (oids.Count() > 0) { Table table = f.GetTable(); sw.WriteLine(f.Name); foreach (string oid in oids.Split(',')) { List<Row> features = null; features = GetRowListFor(table, new QueryFilter { WhereClause = "OBJECTID = " + oid }); using (var feature = features[0]) { Geometry shape = feature.GetOriginalValue(feature.FindField("SHAPE")) as Geometry; Common.UnionEnvelopes(envBuilder, shape); sw.WriteLine(oid); } } } } } catch (Exception ex) { if (Common.GetConfiguration("DebugMessages") == "True") { MessageBox.Show("ERROR : " + ex.ToString()); } } finally { } } //Select the features //if (Common.GetConfiguration("DebugMessages") == "True") //{ // MessageBox.Show("About to close the stream"); //} sw.Close(); //if (Common.GetConfiguration("DebugMessages") == "True") //{ //MessageBox.Show("closed the stream stream"); //} ArcGIS.Core.Data.QueryFilter qf = new ArcGIS.Core.Data.QueryFilter(); //if (Common.GetConfiguration("DebugMessages") == "True") //{ // MessageBox.Show("dx layer count is " + dxLayers.Count); //} foreach (FeatureLayer fl in dxLayers) { if (objectIDsToSelectByLayer.ContainsKey(fl.Name)) { qf.WhereClause = "OBJECTID in (" + objectIDsToSelectByLayer[fl.Name] + ")"; //if (Common.GetConfiguration("DebugMessages") == "True") //{ // MessageBox.Show("Where clause for " + fl.Name + " : " + qf.WhereClause); //} try { fl.Select(qf, ArcGIS.Desktop.Mapping.SelectionCombinationMethod.New); //New works, add throws error } catch (Exception ex) { //MessageBox.Show("Selection Error " + ex.ToString()); } } } //Zoom to it //if (Common.GetConfiguration("DebugMessages") == "True") //{ // MessageBox.Show("About to zoom"); //} #endregion } else { //Get from ArcObjects } Map activeMap = MapView.Active.Map; var extent = envBuilder.ToGeometry().Extent; var expandedExtent = extent.Expand(1.2, 1.2, true); MapView.Active.ZoomTo(expandedExtent); return true; }); //return Task.FromResult(true); }
private string ValidateChangedFeatures(Layer layer) { StringBuilder resultString = new StringBuilder(); // Get utility network and geodatabase using (UtilityNetwork utilityNetwork = UtilityNetworkUtils.GetUtilityNetworkFromLayer(layer)) using (Geodatabase geodatabase = utilityNetwork.GetDatastore() as Geodatabase) { // Determine what to validate // File geodatabase - validate everything, synchronously // Default version - validate everything, asynchronously // Branch version - validate changes only, synchronously bool shouldValidateEverything; bool runAsync; if (!geodatabase.IsVersioningSupported()) { shouldValidateEverything = true; runAsync = false; } else { using (VersionManager versionManager = geodatabase.GetVersionManager()) using (Version currentVersion = versionManager.GetCurrentVersion()) { if (IsDefaultVersion(currentVersion)) { shouldValidateEverything = true; runAsync = true; } else { shouldValidateEverything = false; runAsync = false; } } } // If we validating everything, get an envelope from the dirty areas table EnvelopeBuilder envelopeBuilder = new EnvelopeBuilder(layer.GetSpatialReference()); if (shouldValidateEverything) { using (Table dirtyAreaTable = utilityNetwork.GetSystemTable(SystemTableType.DirtyAreas)) using (RowCursor rowCursor = dirtyAreaTable.Search()) { envelopeBuilder = GetExtentFromRowCursor(envelopeBuilder, rowCursor); } } // else get an envelope using version differences else { using (VersionManager versionManager = geodatabase.GetVersionManager()) using (Version currentVersion = versionManager.GetCurrentVersion()) using (Version defaultVersion = currentVersion.GetParent()) using (Geodatabase defaultGeodatabase = defaultVersion.Connect()) using (UtilityNetwork defaultUtilityNetwork = defaultGeodatabase.OpenDataset <UtilityNetwork>(utilityNetwork.GetName())) using (Table dirtyAreaTable = utilityNetwork.GetSystemTable(SystemTableType.DirtyAreas)) using (Table defaultDirtyAreaTable = defaultUtilityNetwork.GetSystemTable(SystemTableType.DirtyAreas)) using (DifferenceCursor inserts = dirtyAreaTable.Differences(defaultDirtyAreaTable, DifferenceType.Insert)) { envelopeBuilder = GetExtentFromDifferenceCursor(envelopeBuilder, inserts); } } // Run validate topology on our envelope Envelope extent = envelopeBuilder.ToGeometry(); ValidationResult result = utilityNetwork.ValidateNetworkTopologyInEditOperation(extent, runAsync ? InvocationTarget.AsynchronousService : InvocationTarget.SynchronousService); if (result.HasErrors) { resultString.AppendLine("Errors found."); } else { resultString.AppendLine("No errors found."); } } return(resultString.ToString()); }
public static ArcGIS.Core.Geometry.Geometry GetGeometry(int featureClassID, int OID, out bool isLine, FeatureLayer lineFeatureLayer, FeatureLayer pointFeatureLayer) { isLine = true; IFeatureClass fc = null; if(_fcIDToFeatureClass.ContainsKey(featureClassID) == false) { IFeatureWorkspaceManage2 fwsm2 = (IFeatureWorkspaceManage2)_fws; string className = fwsm2.GetObjectClassNameByID(featureClassID); _fcIDToFeatureClass.Add(featureClassID,_fws.OpenFeatureClass(className) ); } fc = _fcIDToFeatureClass[featureClassID]; var shape = fc.GetFeature(OID).Shape; if (shape.GeometryType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint) { IPoint pnt = (IPoint)shape; //var coord = new Coordinate(xCoord, yCoord); //newMapPoint = MapPointBuilder.CreateMapPoint(coord, spatialReference); isLine = false; } else { isLine = true; } bool isLineForLambda = isLine; QueuedTask.Run(() => { EnvelopeBuilder envBuilder = new EnvelopeBuilder(); envBuilder.XMin = 0; envBuilder.XMax = 0; envBuilder.YMin = 0; envBuilder.YMax = 0; var env = envBuilder.ToGeometry().Extent; var pntFeatureClass = pointFeatureLayer.GetTable() as ArcGIS.Core.Data.FeatureClass; var pntClassDefinition = pntFeatureClass.GetDefinition() as FeatureClassDefinition; var spatialReference = pntClassDefinition.GetSpatialReference(); var createOperation = new EditOperation(); createOperation.Name = "Highlight Design Features"; createOperation.SelectNewFeatures = false; if (isLineForLambda == false) //point { IPoint pnt = (IPoint)shape; var coord = new Coordinate(pnt.X,pnt.Y); var newMapPoint = MapPointBuilder.CreateMapPoint(coord, spatialReference); // queue feature creation createOperation.Create(pointFeatureLayer, newMapPoint); Common.UnionEnvelopes(envBuilder, newMapPoint); } else { IPointCollection pc = (IPointCollection)shape; var lineCoordinates = new List<Coordinate>(pc.PointCount); for (int i = 0; i < pc.PointCount; i++) { var vertex = new Coordinate(pc.get_Point(i).X, pc.get_Point(i).Y); lineCoordinates.Add(vertex); var newPolyline = PolylineBuilder.CreatePolyline(lineCoordinates, spatialReference); createOperation.Create(lineFeatureLayer, newPolyline); Common.UnionEnvelopes(envBuilder, newPolyline); } } }); return null; }
/// <summary> /// Generates route from the geocoded locations /// </summary> private async Task GetRouteAsync() { if (FromPlace == null || ToPlace == null) { return; } IsBusy = true; if (Router == null) { try { await CreateRouteTask(); } catch (Exception ex) { ErrorMessage = "Unable to load routing service. The routing functionality may not work."; StackTrace = ex.ToString(); IsBusy = false; return; } } // set the route parameters var routeParams = await Router.CreateDefaultParametersAsync(); routeParams.ReturnDirections = true; routeParams.ReturnRoutes = true; // add route stops as parameters try { routeParams.SetStops(new List <Stop>() { new Stop(FromPlace.RouteLocation), new Stop(ToPlace.RouteLocation) }); Route = await Router.SolveRouteAsync(routeParams); // Set the AOI to an area slightly larger than the route's extent var aoiBuilder = new EnvelopeBuilder(Route.Routes.FirstOrDefault()?.RouteGeometry.Extent); aoiBuilder.Expand(1.2); AreaOfInterest = new Viewpoint(aoiBuilder.ToGeometry()); // Set turn by turn directions DirectionManeuvers = Route.Routes.FirstOrDefault()?.DirectionManeuvers; } catch (ArcGISWebException e) { // This is returned when user hits the Cancel button in iOS or the back arrow in Android // It does not get caught in the SignInRenderer and needs to be handled here if (e.Message.Contains("Token Required")) { FromPlace = null; ToPlace = null; IsBusy = false; return; } ErrorMessage = "A web exception occured. Are you connected to the internet?"; StackTrace = e.ToString(); } catch (Exception ex) { //TODO: Remove workaround when iOS bug is fixed #if __IOS__ exceptionCounter++; if (ex.Message == "403 (Forbidden)" && exceptionCounter <= 3) { await GetRouteAsync(); return; } #endif ErrorMessage = "Something went wrong and the routing operation failed."; StackTrace = ex.ToString(); } exceptionCounter = 0; IsBusy = false; }
private Envelope GetCurrentEnvelop(MapView view) { Envelope newExtent = null; // Get current viewpoints extent from the MapView var currentViewpoint = view.GetCurrentViewpoint(ViewpointType.BoundingGeometry); var viewpointExtent = currentViewpoint.TargetGeometry.Extent; if (view.WrapAround) { var normalizedExtent = GeometryEngine.NormalizeCentralMeridian(viewpointExtent); if (normalizedExtent is Polygon) { var normalizedPolygon = (Polygon)normalizedExtent; if (normalizedPolygon.Parts.Count == 1) { newExtent = normalizedPolygon.Extent; } else { var newExtentBuilder = new EnvelopeBuilder(view.SpatialReference); foreach (var p in normalizedPolygon.Parts[0].GetPoints()) { if (p.X < newExtentBuilder.XMin || double.IsNaN(newExtentBuilder.XMin)) { newExtentBuilder.XMin = p.X; } if (p.Y < newExtentBuilder.YMin || double.IsNaN(newExtentBuilder.YMin)) { newExtentBuilder.YMin = p.Y; } } foreach (var p in normalizedPolygon.Parts[1].GetPoints()) { if (p.X > newExtentBuilder.XMax || double.IsNaN(newExtentBuilder.XMax)) { newExtentBuilder.XMax = p.X; } if (p.Y > newExtentBuilder.YMax || double.IsNaN(newExtentBuilder.YMax)) { newExtentBuilder.YMax = p.Y; } } newExtent = newExtentBuilder.ToGeometry(); } } else if (normalizedExtent is Envelope) { newExtent = normalizedExtent as Envelope; } } else { newExtent = viewpointExtent; } return(newExtent); }
/// <summary> /// This method must be called on the MCT /// </summary> /// <remarks>If multiple features are selected just the ObjectID of the first feature /// in the selected set is returned</remarks> /// <param name="point"></param> /// <returns>The object id of the selected feature or -1</returns> internal static Polyline SelectLineFeature(MapPoint point) { if (OnUIThread) throw new CalledOnWrongThreadException(); var pt = MapView.Active.MapToClient(point); double llx = pt.X - 5; double lly = pt.Y - 5; double urx = pt.X + 5; double ury = pt.Y + 5; EnvelopeBuilder envBuilder = new EnvelopeBuilder(MapView.Active.ClientToMap(new Point(llx, lly)), MapView.Active.ClientToMap(new Point(urx, ury))); //Just get feature layers that are line types var selection = MapView.Active.SelectFeatures(envBuilder.ToGeometry()).Where( k => k.Key.ShapeType == esriGeometryType.esriGeometryPolyline ).ToList(); Polyline selectedLine = null; if (selection.Count() > 0) { //return the first of the selected features var flayer = selection.First().Key; var oid = selection.First().Value[0]; var inspector = new Inspector(); inspector.Load(flayer, oid); selectedLine = inspector["SHAPE"] as Polyline; } return selectedLine; }
private void Initialize() { // Define the route stop locations (points) MapPoint fromPoint = new MapPoint(-112.068962, 33.638390, SpatialReferences.Wgs84); MapPoint toPoint = new MapPoint(-112.1028099, 33.7334937, SpatialReferences.Wgs84); // Create Stop objects with the points and add them to a list of stops Stop stop1 = new Stop(new MapPoint(-112.068962, 33.638390, SpatialReferences.Wgs84)); Stop stop2 = new Stop(new MapPoint(-111.994930, 33.618900, SpatialReferences.Wgs84)); Stop stop3 = new Stop(new MapPoint(-112.0021089, 33.6858299, SpatialReferences.Wgs84)); Stop stop4 = new Stop(new MapPoint(-111.9734644, 33.6348065, SpatialReferences.Wgs84)); Stop stop5 = new Stop(new MapPoint(-112.1028099, 33.7334937, SpatialReferences.Wgs84)); _routeStops = new List <Stop> { stop1, stop2, stop3, stop4, stop5 }; //// Create Stop objects with the points and add them to a list of stops //Stop stop1 = new Stop(fromPoint); //Stop stop2 = new Stop(toPoint); //_routeStops = new List<Stop> { stop1, stop2 }; // Picture marker symbols: from = car, to = checkered flag PictureMarkerSymbol carSymbol = new PictureMarkerSymbol(_carIconUri); PictureMarkerSymbol flagSymbol = new PictureMarkerSymbol(_checkedFlagIconUri); // Add a slight offset (pixels) to the picture symbols. carSymbol.OffsetX = -carSymbol.Width / 2; carSymbol.OffsetY = -carSymbol.Height / 2; flagSymbol.OffsetX = -flagSymbol.Width / 2; flagSymbol.OffsetY = -flagSymbol.Height / 2; // Set the height and width. flagSymbol.Height = 60; flagSymbol.Width = 60; carSymbol.Height = 60; carSymbol.Width = 60; // Create graphics for the stops Graphic fromGraphic = new Graphic(fromPoint, carSymbol) { ZIndex = 1 }; Graphic toGraphic = new Graphic(toPoint, flagSymbol) { ZIndex = 1 }; // Create the graphics overlay and add the stop graphics _routeGraphicsOverlay = new GraphicsOverlay(); _routeGraphicsOverlay.Graphics.Add(fromGraphic); _routeGraphicsOverlay.Graphics.Add(toGraphic); // Get an Envelope that covers the area of the stops (and a little more) Envelope routeStopsExtent = new Envelope(fromPoint, toPoint); EnvelopeBuilder envBuilder = new EnvelopeBuilder(routeStopsExtent); envBuilder.Expand(1.5); // Create a new viewpoint apply it to the map view when the spatial reference changes Viewpoint sanDiegoViewpoint = new Viewpoint(envBuilder.ToGeometry()); MyMapView.SpatialReferenceChanged += (s, e) => MyMapView.SetViewpoint(sanDiegoViewpoint); // Add a new Map and the graphics overlay to the map view MyMapView.Map = new Map(Basemap.CreateImageryWithLabelsVector()); MyMapView.GraphicsOverlays.Add(_routeGraphicsOverlay); }
private async void Initialize() { // Set paths that are relative to execution path string currentDir = Directory.GetCurrentDirectory(); int idx = currentDir.IndexOf("bin") - 1; appRootDir = currentDir.Substring(0, idx); appDataDir = appRootDir + @"\Data"; appTempDir = appRootDir + @"\temp"; // Set up files testImage = appDataDir + @"\sampleFile.tiff"; gpPackage = appDataDir + @"\CreateMapTilePackage.gpkx"; mapPackage = appDataDir + @"\emptyMapPackage.mpkx"; Debug.WriteLine(">> App Root Directory = " + appRootDir); Debug.WriteLine(">> App Data Directory = " + appDataDir); Debug.WriteLine(">> App Temp Directory = " + appTempDir); ////////////// start Q Basket set up ////////////////// // Create raster layer from a raster file (Geotiff) Debug.WriteLine("Loading raster layer from " + testImage); RasterLayer inRasterLayer = new RasterLayer(testImage); // Load Raster into Raster Layer try { await inRasterLayer.LoadAsync(); if (inRasterLayer.LoadStatus != Esri.ArcGISRuntime.LoadStatus.Loaded) { Debug.WriteLine("Error - Input Raster Layer not loaded "); } } catch (Exception ex) { string msg = "Unable to load the raster\n"; msg += "Raster file = " + testImage; msg += "Load status = " + inRasterLayer.LoadStatus.ToString(); msg += "\n\nMessage: " + ex.Message; MessageBox.Show(msg, "inRasterLayer.LoadAsync failed"); } // Create a new EnvelopeBuilder from the full extent of the raster layer. // Add a small zoom to make sure entire map is viewable EnvelopeBuilder envelopeBuilder = new EnvelopeBuilder(inRasterLayer.FullExtent); envelopeBuilder.Expand(0.75); // Create a basemap from the raster layer Basemap baseMap = new Basemap(inRasterLayer); // Create a new map using the new basemap Map newMap = new Map(baseMap); // Set the viewpoint of the map to the proper extent. newMap.InitialViewpoint = new Viewpoint(envelopeBuilder.ToGeometry().Extent); // Create a map and add it to the view MyMapView.Map = newMap; // Load new map to display basemap try { // Add map to the map view. MyMapView.Map = newMap; // Wait for the map to load. await newMap.LoadAsync(); } catch (Exception ex) { string msg = "Unable to load the Map\n"; msg += "\n\nMessage: " + ex.Message; MessageBox.Show(msg, "newMap.LoadAsync failed"); } // Wait for rendering to finish before taking the screenshot for the thumbnail await WaitForRenderCompleteAsync(MyMapView); ////////////// end Q Basket set up ////////////////// // Start the Local Server try { // LocalServer must not be running when setting the data path. if (LocalServer.Instance.Status == LocalServerStatus.Started) { await LocalServer.Instance.StopAsync(); } // Set the local data path - must be done before starting. // Avoid Windows path length limitations (260). // CreateDirectory won't overwrite if it already exists. Directory.CreateDirectory(appTempDir); LocalServer.Instance.AppDataPath = appTempDir; // Start the local server instance await LocalServer.Instance.StartAsync(); MessageBox.Show("Local Server started"); Debug.WriteLine(">> Local Server started"); // Get the URL for the localServer // localhost port is variable localServerURL = LocalServer.Instance.Url.AbsoluteUri; Debug.WriteLine("\n>> Local server url - " + localServerURL); Debug.WriteLine(">> Local server App Data Path - " + LocalServer.Instance.AppDataPath); } catch (Exception ex) { string msg = "Please ensure the local server is installed \nand configured correctly"; msg += String.Format("\nMessage: {0}", ex.Message); MessageBox.Show(msg, "Local Server failed to start"); Debug.WriteLine(msg); App.Current.Shutdown(); } // LOCAL MAP SERVICE INIT // Create and start the local map service try { _localMapService = new LocalMapService(mapPackage); } catch (Exception ex) { string msg = "Cannot create the local map service"; msg += "Map Package = " + mapPackage; msg += String.Format("\nMessage: {0}", ex.Message); MessageBox.Show(msg, "Local Map Server failed to start"); Debug.WriteLine(msg); App.Current.Shutdown(); } // RASTER WORKSPACE CREATION // Create the Raster workspace; this workspace name was chosen arbitrarily // Does workspace need to be the same directory as rasters? // setting to temp directory rasterWorkspace = new RasterWorkspace("raster_wkspc", appTempDir); Debug.WriteLine(">> raster workspace folder = " + rasterWorkspace.FolderPath); Debug.WriteLine(">> raster workspace id = " + rasterWorkspace.Id); // Create the layer source that represents the Raster on disk RasterSublayerSource source = new RasterSublayerSource(rasterWorkspace.Id, testImage); // Create a sublayer instance from the table source _rasterSublayer = new ArcGISMapImageSublayer(0, source); // Add the dynamic workspace to the map service _localMapService.SetDynamicWorkspaces(new List <DynamicWorkspace>() { rasterWorkspace }); // Register map service status chagne event handle _localMapService.StatusChanged += _localMapService_StatusChanged; // Start the map service try { await _localMapService.StartAsync(); } catch (Exception ex) { string msg = "Cannot start the local map service"; msg += "Map Package = " + mapPackage; msg += String.Format("\nMessage: {0}", ex.Message); MessageBox.Show(msg, "Local Map Server failed to start"); Debug.WriteLine(msg); App.Current.Shutdown(); } // Get the url to the local map service localMapServiceURL = _localMapService.Url.AbsoluteUri; MessageBox.Show("Local Map Service URL = " + localMapServiceURL); Debug.WriteLine("Local Map Service URL = " + localMapServiceURL); // LOCAL GEOPROCESSING SERVICE INIT // Create the geoprocessing service _localGPservice = new LocalGeoprocessingService(gpPackage, gpServiceType); // Ass GP service status chagned event handler _localGPservice.StatusChanged += GpServiceOnStatusChanged; // Try to start the service try { // Start the service await _localGPservice.StartAsync(); if (_localGPservice.Status == LocalServerStatus.Failed) { string msg = ("Geoprocessing service failed to start.\n"); MessageBox.Show(msg, "gpService.StartAsync failed"); App.Current.Shutdown(); } else if (_localGPservice.Status == LocalServerStatus.Started) { localGPserviceUrl = _localGPservice.Url.AbsoluteUri + "/CreateMapTilePackage"; string msg = ("Geoprocessing service started.\n"); msg += "\n>> GP Service URL: " + localGPserviceUrl; msg += ">> GP Service Max Records: " + _localGPservice.MaxRecords; msg += ">> GP Service Package Path: " + _localGPservice.PackagePath; msg += ">> GP Service Type: " + _localGPservice.ServiceType; MessageBox.Show(msg, "gpService.StartAsync started"); Debug.WriteLine("\n>> GP Service URL: " + localGPserviceUrl); Debug.WriteLine(">> GP Service Max Records: " + _localGPservice.MaxRecords); Debug.WriteLine(">> GP Service Package Path: " + _localGPservice.PackagePath); Debug.WriteLine(">> GP Service Type: " + _localGPservice.ServiceType); } } catch (Exception ex) { string msg = ("Geoprocessing service failed to start.\n"); msg += "\nGeoprocessing package - " + gpPackage + "\n"; msg += String.Format("\nMessage: {0}", ex.Message); MessageBox.Show(msg, "gpService.StartAsync failed"); return; } // GEOPROCESSING TASK INIT // Create the geoprocessing task from the service try { string url = _localGPservice.Url + "/CreateMapTilePackage"; _gpTask = await GeoprocessingTask.CreateAsync(new Uri(url)); } catch (Exception ex) { string msg = ("Geoprocessing task failed to start.\n"); msg += "\nlocalGPserviceUrl- " + localGPserviceUrl + "\n"; msg += String.Format("\nMessage: {0}", ex.Message); MessageBox.Show(msg, "GeoprocessingTask.CreateAsync failed"); return; } MessageBox.Show("GeoprocessingTask.CreateAsync created"); // GEOPROCESSING JOB // Create the geoprocessing parameters GeoprocessingParameters gpParams = new GeoprocessingParameters(gpExecutionType); // Add the interval parameter to the geoprocessing parameters //GeoprocessingString Input_Map = new GeoprocessingString("MyMapView.Map"); GeoprocessingString Input_Map = new GeoprocessingString("localMapServiceURL"); GeoprocessingDouble Max_LOD = new GeoprocessingDouble(10); GeoprocessingString Output_Package = new GeoprocessingString("C://Karen/Data/TilePackages/test.tpkx"); gpParams.Inputs.Add("Input_Map", Input_Map); gpParams.Inputs.Add("Max_LOD", Max_LOD); gpParams.Inputs.Add("Output_Package", Output_Package); // Create the job try { _gpJob = _gpTask.CreateJob(gpParams); } catch (Exception ex) { string msg = ("Geoprocessing job cannot be created.\n"); msg += String.Format("\nMessage: {0}", ex.Message); MessageBox.Show(msg, "_gpTask.CreateJob failed"); return; } MessageBox.Show("GeoprocessingTask.CreateJob created"); MyLoadingIndicator.Visibility = Visibility.Visible; // Update the UI when job progress changes _gpJob.ProgressChanged += (sender, args) => { Dispatcher.Invoke(() => { MyLoadingIndicator.Value = _gpJob.Progress; }); }; // Be notified when the task completes (or other change happens) _gpJob.JobChanged += GpJobOnJobChanged; // Start the job try { _gpJob.Start(); } catch (Exception ex) { string msg = ("Geoprocessing start job failed to start.\n"); msg += String.Format("\nMessage: {0}", ex.Message); MessageBox.Show(msg, "_gpjob.Start failed"); return; } MessageBox.Show("GeoprocessingTask job started"); }
private void MapView_ExtentChanged(object sender, System.EventArgs e) { Envelope newExtent = null; // Get current viewpoints extent from the MapView var currentViewpoint = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry); var viewpointExtent = currentViewpoint.TargetGeometry.Extent; if (MyMapView.WrapAround) { Geometry normalizedExtent = GeometryEngine.NormalizeCentralMeridian(viewpointExtent); if (normalizedExtent is Polygon) { var normalizedPolygon = (Polygon)normalizedExtent; if (normalizedPolygon.Parts.Count == 1) { newExtent = normalizedPolygon.Extent; } else { var newExtentBuilder = new EnvelopeBuilder(MyMapView.SpatialReference); foreach (var p in normalizedPolygon.Parts[0].GetPoints()) { if (Geometry.IsNullOrEmpty(newExtent) || p.X < newExtent.XMin || double.IsNaN(newExtent.XMin)) { newExtentBuilder.XMin = p.X; } if (Geometry.IsNullOrEmpty(newExtent) || p.Y < newExtent.YMin || double.IsNaN(newExtent.YMin)) { newExtentBuilder.YMin = p.Y; } } foreach (var p in normalizedPolygon.Parts[1].GetPoints()) { if (Geometry.IsNullOrEmpty(newExtent) || p.X > newExtent.XMax || double.IsNaN(newExtent.XMax)) { newExtentBuilder.XMax = p.X; } if (Geometry.IsNullOrEmpty(newExtent) || p.Y > newExtent.YMax || double.IsNaN(newExtent.YMax)) { newExtentBuilder.YMax = p.Y; } } newExtent = newExtentBuilder.ToGeometry(); } } else if (normalizedExtent is Envelope) { newExtent = normalizedExtent as Envelope; } } else { newExtent = viewpointExtent; } MinXNormalized.Text = newExtent.XMin.ToString("0.000"); MinYNormalized.Text = newExtent.YMin.ToString("0.000"); MaxXNormalized.Text = newExtent.XMax.ToString("0.000"); MaxYNormalized.Text = newExtent.YMax.ToString("0.000"); MinXAbsolute.Text = viewpointExtent.XMin.ToString("0.000"); MinYAbsolute.Text = viewpointExtent.YMin.ToString("0.000"); MaxXAbsolute.Text = viewpointExtent.XMax.ToString("0.000"); MaxYAbsolute.Text = viewpointExtent.YMax.ToString("0.000"); }
public static Envelope GetGraphicsEnvelope(GraphicCollection gc) { if (gc.Count == 0) return null; EnvelopeBuilder envBuilder = new EnvelopeBuilder(gc[0].Geometry.Extent); Envelope env = envBuilder.ToGeometry(); foreach (Graphic g in gc) { env.Union(g.Geometry.Extent); } return env; }
private static EditOperation CreateOperationAndBuildInitialEnvelope(ref EnvelopeBuilder envBuilder, ref ArcGIS.Core.Geometry.Envelope env) { var createOperation = new EditOperation(); createOperation.Name = "Highlight Design Features"; createOperation.SelectNewFeatures = false; if (envBuilder == null) { envBuilder = new EnvelopeBuilder(); envBuilder.XMin = 0; envBuilder.XMax = 0; envBuilder.YMin = 0; envBuilder.YMax = 0; env = envBuilder.ToGeometry().Extent; } return createOperation; }
private void lbResults_MouseDoubleClick(object sender, MouseButtonEventArgs e) { int selectedIndex = lbResults.SelectedIndex; AnalyzeViewModel avm = this.DataContext as AnalyzeViewModel; ObservableCollection<Result> results = avm.DetailResults; string geom = ""; int index = 0; int oid = 1; foreach(Result res in results) //foreach (Result res in ((ObservableCollection<Result>) this.DataContext)) { if (index == selectedIndex) { geom = res.Geometry; oid = res.OID; } index++; } //double xCoord = Convert.ToDouble(geom.Split(',')[0]); //double yCoord = Convert.ToDouble(geom.Split(',')[1]); //var coord = new ArcGIS.Core.Geometry.Coordinate(xCoord, yCoord); //EnvelopeBuilder envBuilder = new EnvelopeBuilder(); //envBuilder.XMin = xCoord - 10; //envBuilder.XMax = xCoord + 10; //envBuilder.YMin = yCoord - 10; //envBuilder.YMax = yCoord + 10; //var env = envBuilder.ToGeometry().Extent; //Map activeMap = MapView.Active.Map; //var extent = envBuilder.ToGeometry().Extent; //var expandedExtent = extent.Expand(1.2, 1.2, true); QueuedTask.Run(() => { double xCoord = Convert.ToDouble(geom.Split(',')[0]); double yCoord = Convert.ToDouble(geom.Split(',')[1]); var coord = new ArcGIS.Core.Geometry.Coordinate(xCoord, yCoord); EnvelopeBuilder envBuilder = new EnvelopeBuilder(); envBuilder.XMin = xCoord - 20; envBuilder.XMax = xCoord + 20; envBuilder.YMin = yCoord - 20; envBuilder.YMax = yCoord + 20; var env = envBuilder.ToGeometry().Extent; FeatureLayer pointFeatureLayer; FeatureLayer lineFeatureLayer; Common.GetLayers(out pointFeatureLayer, out lineFeatureLayer); var pntFeatureClass = pointFeatureLayer.GetTable() as FeatureClass; var pntClassDefinition = pntFeatureClass.GetDefinition() as FeatureClassDefinition; // store the spatial reference as its own variable var spatialReference = pntClassDefinition.GetSpatialReference(); var zoomPoint = MapPointBuilder.CreateMapPoint(coord, spatialReference); MapView.Active.ZoomTo(env); /*var createOperation = new EditOperation(); createOperation.Name = "Show Feature as Selected"; createOperation.SelectNewFeatures = true; //createOperation.Create(pointFeatureLayer, newMapPoint); Dictionary<string,object> fieldMap = new Dictionary<string,object>(); fieldMap.Add("Display","Selected"); createOperation.Modify(pointFeatureLayer, oid, fieldMap); //MapView.Active.FlashFeature(pointFeatureLayer, oid); createOperation.ExecuteAsync();*/ }); //return createOperation.ExecuteAsync(); }