示例#1
0
        private async void BtnCountFeaturesClick(object sender, RoutedEventArgs e)
        {
            try
            {
                // Get the current visible extent.
                Geometry currentExtent = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry).TargetGeometry;

                // Create the query parameters.
                QueryParameters queryCityCount = new QueryParameters
                {
                    Geometry = currentExtent,
                    // Specify the interpretation of the Geometry query parameters.
                    SpatialRelationship = SpatialRelationship.Intersects
                };

                // Get the count of matching features.
                long count = await _featureTable.QueryFeatureCountAsync(queryCityCount);

                // Update the UI.
                ResultsTextbox.Text = $"{count} features in extent";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error");
            }
        }
        private async void BtnCountFeatures_Click(object sender, EventArgs e)
        {
            try
            {
                // Get the current visible extent.
                Geometry currentExtent = _myMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry).TargetGeometry;

                // Create the query parameters.
                QueryParameters queryCityCount = new QueryParameters
                {
                    Geometry = currentExtent,
                    // Specify the interpretation of the Geometry query parameters.
                    SpatialRelationship = SpatialRelationship.Intersects
                };

                // Get the count of matching features.
                long count = await _featureTable.QueryFeatureCountAsync(queryCityCount);

                // Update the UI.
                _myResultsLabel.Text = $"{count} features in extent";
            }
            catch (NullReferenceException exception)
            {
                // Sample wasn't ready.
                System.Diagnostics.Debug.WriteLine(exception);
            }
            catch (Exception)
            {
                // Uncaught exception in async void will crash application.
            }
        }
示例#3
0
        private async Task FindServiceAreas()
        {
            try
            {
                // Create the service area task.
                _serviceAreaTask = await ServiceAreaTask.CreateAsync(new Uri(NetworkAnalysisUrl));

                // Create the default parameters for the service.
                ServiceAreaParameters serviceAreaParameters = await _serviceAreaTask.CreateDefaultParametersAsync();

                // Configure the service area parameters.
                serviceAreaParameters.PolygonDetail  = ServiceAreaPolygonDetail.High;
                serviceAreaParameters.ReturnPolygons = true;
                serviceAreaParameters.DefaultImpedanceCutoffs.Clear();
                serviceAreaParameters.DefaultImpedanceCutoffs.Add(0);
                serviceAreaParameters.DefaultImpedanceCutoffs.Add(3);
                serviceAreaParameters.DefaultImpedanceCutoffs.Add(5);

                // A query that finds all of the relevant facilities from the facilities feature service.
                QueryParameters facilityQueryParameters = new QueryParameters();
                facilityQueryParameters.WhereClause = "1=1";

                // Provide the feature service and the query as parameters to the service area task.
                serviceAreaParameters.SetFacilities(_facilitiesTable, facilityQueryParameters);

                // Perform the service area analysis.
                ServiceAreaResult result = await _serviceAreaTask.SolveServiceAreaAsync(serviceAreaParameters);

                // Count the features in the facilities layer.
                long facilityCount = await _facilitiesTable.QueryFeatureCountAsync(facilityQueryParameters);

                // Get the service area for each facility.
                for (int facilityIndex = 0; facilityIndex < facilityCount; facilityIndex++)
                {
                    // Get each area polygon from the result for that facility.
                    List <ServiceAreaPolygon> areaPolygons = result.GetResultPolygons(facilityIndex).ToList();

                    // Add each service area polygon to the graphics overlay.
                    for (int polygonIndex = 0; polygonIndex < areaPolygons.Count; polygonIndex++)
                    {
                        // Get the polygon from the result.
                        Polygon resultingPolygon = areaPolygons[polygonIndex].Geometry;

                        // Choose a symbol for the polygon.
                        SimpleFillSymbol selectedSymbol = _fillSymbols[polygonIndex % _fillSymbols.Count];

                        // Create and add the graphic.
                        _resultOverlay.Graphics.Add(new Graphic(resultingPolygon, selectedSymbol));
                    }
                }

                // Zoom to the extent of the results.
                await _myMapView.SetViewpointGeometryAsync(_resultOverlay.Extent, 50);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
                ShowMessage("Error", "Couldn't complete service area analysis.");
            }
        }
示例#4
0
        private async void CountFeatures_Click(object sender, EventArgs e)
        {
            // Get the current visible extent.
            Geometry currentExtent = _myMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry).TargetGeometry;

            // Create the query parameters.
            QueryParameters queryCityCount = new QueryParameters
            {
                Geometry = currentExtent,
                // Specify the interpretation of the Geometry query parameters.
                SpatialRelationship = SpatialRelationship.Intersects
            };

            try
            {
                // Get the count of matching features.
                long count = await _featureTable.QueryFeatureCountAsync(queryCityCount);

                // Update the UI.
                _resultLabel.Text = $"{count} features in extent";
            }
            catch (Exception ex)
            {
                new UIAlertView("Error", ex.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show();
            }
        }
示例#5
0
        public static async Task <List <object> > GetAttributes(string url, string whereClause = "", string[] fieldNames = null)
        {
            if (fieldNames == null)
            {
                return(null);
            }

            var attributes = new List <object>();
            var table      = new ServiceFeatureTable(new Uri(url));
            await table.LoadAsync();

            if (table.GeometryType != Esri.ArcGISRuntime.Geometry.GeometryType.Polygon)
            {
                return(null);
            }

            var queryParams = new QueryParameters();

            queryParams.WhereClause = whereClause;
            var count = await table.QueryFeatureCountAsync(queryParams);

            var queryFeatureResults = await table.QueryFeaturesAsync(queryParams);

            var resultingFeature = queryFeatureResults.FirstOrDefault();

            foreach (var fieldName in fieldNames)
            {
                attributes.Add(resultingFeature.GetAttributeValue(fieldName));
            }

            return(attributes);
        }
示例#6
0
        public static async Task <List <Esri.ArcGISRuntime.Geometry.Geometry> > GetGeometries(string url, string whereClause = "objectid > 0")
        {
            var geometries = new List <Esri.ArcGISRuntime.Geometry.Geometry>();

            try
            {
                var table = new ServiceFeatureTable(new Uri(url));
                await table.LoadAsync();

                var queryParams = new QueryParameters();
                queryParams.WhereClause = whereClause;
                var count = await table.QueryFeatureCountAsync(queryParams);

                var queryFeatureResults = await table.QueryFeaturesAsync(queryParams);

                foreach (var result in queryFeatureResults)
                {
                    geometries.Add(result.Geometry);
                }
            }
            catch (Exception)
            {
            }

            return(geometries);
        }
        private async void BtnCountFeatures_Click(object sender, EventArgs e)
        {
            // Get the current visible extent.
            Geometry currentExtent = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry).TargetGeometry;

            // Create the query parameters.
            QueryParameters queryCityCount = new QueryParameters
            {
                Geometry = currentExtent,
                // Specify the interpretation of the Geometry query parameters.
                SpatialRelationship = SpatialRelationship.Intersects
            };

            try
            {
                // Get the count of matching features.
                long count = await _featureTable.QueryFeatureCountAsync(queryCityCount);

                // Update the UI.
                txtResults.Text = $"{count} features in extent";
            }
            catch (Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert("Error", ex.ToString(), "OK");
            }
        }
示例#8
0
        private async void BtnCountFeatures_Click(object sender, EventArgs e)
        {
            // Create the query parameters
            QueryParameters queryCityCount = new QueryParameters
            {
                // Get the current view extent and use that as a query parameters
                Geometry = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry).TargetGeometry,
                // Specify the interpretation of the Geometry query parameters
                SpatialRelationship = SpatialRelationship.Intersects
            };

            // Get the count of matching features
            long count = await _myFeatureTable.QueryFeatureCountAsync(queryCityCount);

            // Update the UI
            txtResults.Text = $"{count} features in extent";
        }
        private async void BtnCountFeatures_Click(object sender, EventArgs e)
        {
            // Get the current visible extent.
            Geometry currentExtent = _myMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry).TargetGeometry;

            // Create the query parameters.
            QueryParameters queryCityCount = new QueryParameters
            {
                Geometry = currentExtent,
                // Specify the interpretation of the Geometry query parameters.
                SpatialRelationship = SpatialRelationship.Intersects
            };

            // Get the count of matching features.
            long count = await _featureTable.QueryFeatureCountAsync(queryCityCount);

            // Update the UI.
            _resultsLabel.Text = $"{count} features in extent";
        }
示例#10
0
        public static async Task <object> GetAttribute(string url, string whereClause = "", string fieldName = "")
        {
            var table = new ServiceFeatureTable(new Uri(url));
            await table.LoadAsync();

            if (table.GeometryType != Esri.ArcGISRuntime.Geometry.GeometryType.Polygon)
            {
                return(null);
            }

            var queryParams = new QueryParameters();

            queryParams.WhereClause = whereClause;
            var count = await table.QueryFeatureCountAsync(queryParams);

            var queryFeatureResults = await table.QueryFeaturesAsync(queryParams);

            var resultingFeature = queryFeatureResults.FirstOrDefault();

            return(resultingFeature.GetAttributeValue(fieldName));
        }