public Collection <Feature> GetEditingFeaturesInterseting(BaseShape baseShape)
        {
            BaseShape searchArea = baseShape;

            if (baseShape.GetWellKnownType() == WellKnownType.Point)
            {
                PointShape worldCoordinate  = (PointShape)baseShape;
                double     searchTorlerence = 15 * MapArguments.CurrentResolution;
                searchArea = new RectangleShape(worldCoordinate.X - searchTorlerence,
                                                worldCoordinate.Y + searchTorlerence, worldCoordinate.X + searchTorlerence,
                                                worldCoordinate.Y - searchTorlerence);
            }

            Collection <Feature> features = new Collection <Feature>();

            lock (EditShapesLayer)
            {
                if (!EditShapesLayer.IsOpen)
                {
                    EditShapesLayer.Open();
                }
                var intersectingFeatures = EditShapesLayer.QueryTools.GetFeaturesIntersecting(searchArea, EditShapesLayer.GetDistinctColumnNames());
                foreach (var feature in intersectingFeatures)
                {
                    features.Add(feature);
                }
            }

            return(features);
        }
        protected override void AddInputShapeCore(BaseShape shape)
        {
            WellKnownType type = shape.GetWellKnownType();

            if (type == WellKnownType.Line || type == WellKnownType.Multiline)
            {
                FirstInputFeatureLayer.InternalFeatures.Add(shape.GetFeature());
            }
            else if (type == WellKnownType.Polygon || type == WellKnownType.Multipolygon)
            {
                SecondInputFeatureLayer.InternalFeatures.Add(shape.GetFeature());
            }
        }
        protected override void AddInputShapeCore(BaseShape shape)
        {
            WellKnownType type = shape.GetWellKnownType();

            if (type == WellKnownType.Point || type == WellKnownType.Multipoint)
            {
                FirstInputFeatureLayer.InternalFeatures.Add(shape.GetFeature());
            }
            else if (type == WellKnownType.Polygon || type == WellKnownType.Multipolygon)
            {
                SecondInputFeatureLayer.InternalFeatures.Add(shape.GetFeature());
            }
            else
            {
                throw new Exception("The input shape is wrong");
            }
        }
예제 #4
0
        private static IEnumerable <PointShape> CollectPoints(BaseShape shape)
        {
            WellKnownType wktype = shape.GetWellKnownType();

            if (wktype == WellKnownType.Point)
            {
                yield return((PointShape)shape);
            }
            else if (wktype == WellKnownType.Multipoint)
            {
                foreach (var point in ((MultipointShape)shape).Points)
                {
                    yield return(point);
                }
            }
            else if (wktype == WellKnownType.Line)
            {
                foreach (var point in CollectPoints((LineShape)shape))
                {
                    yield return(point);
                }
            }
            else if (wktype == WellKnownType.Multiline)
            {
                foreach (var point in CollectPoints((MultilineShape)shape))
                {
                    yield return(point);
                }
            }
            else if (wktype == WellKnownType.Polygon)
            {
                foreach (var point in CollectPoints((PolygonShape)shape))
                {
                    yield return(point);
                }
            }
            else if (wktype == WellKnownType.Multipolygon)
            {
                foreach (var point in CollectPoints((MultipolygonShape)shape))
                {
                    yield return(point);
                }
            }
        }
        private Collection <Feature> GetTargetFeaturesInterseting(BaseShape baseShape)
        {
            BaseShape searchArea = baseShape;

            if (baseShape.GetWellKnownType() == WellKnownType.Point)
            {
                PointShape worldCoordinate  = (PointShape)baseShape;
                double     searchTorlerence = 15 * MapArguments.CurrentResolution;
                searchArea = new RectangleShape(worldCoordinate.X - searchTorlerence,
                                                worldCoordinate.Y + searchTorlerence, worldCoordinate.X + searchTorlerence,
                                                worldCoordinate.Y - searchTorlerence);
            }

            Collection <Feature> features = new Collection <Feature>();

            lock (EditTargetLayer)
            {
                if (!EditTargetLayer.IsOpen)
                {
                    EditTargetLayer.Open();
                }

                //var excludeFeatures = new Collection<string>();
                //foreach (var item in editTargetLayer.FeatureIdsToExclude)
                //{
                //    excludeFeatures.Add(item);
                //}

                editTargetLayer.FeatureIdsToExclude.Clear();
                foreach (var item in newFeatureIds)
                {
                    editTargetLayer.FeatureIdsToExclude.Add(item);
                }

                EditTargetLayer.SafeProcess(() =>
                {
                    var intersectingFeatures = EditTargetLayer.QueryTools.GetFeaturesIntersecting(searchArea, EditTargetLayer.GetDistinctColumnNames());
                    foreach (var feature in intersectingFeatures)
                    {
                        try
                        {
                            features.Add(feature);
                        }
                        catch
                        {
                            features.Add(SqlTypesGeometryHelper.MakeValid(feature));
                        }
                    }
                });
            }

            foreach (var item in editShapesLayer.InternalFeatures)
            {
                if (item.GetShape().Intersects(searchArea) && !features.Any(f => f.GetWellKnownText() == item.GetWellKnownText()))
                {
                    features.Add(item);
                }
            }

            foreach (var item in editCandidatesLayer.InternalFeatures)
            {
                if (item.GetShape().Intersects(searchArea) && !features.Any(f => f.GetWellKnownText() == item.GetWellKnownText()))
                {
                    features.Add(item);
                }
            }

            return(features);
        }
예제 #6
0
        /// <summary>
        /// Get elevation data using the ElevationCloudClient and update the UI
        /// </summary>
        private async Task PerformElevationQuery(BaseShape queryShape)
        {
            // Get feature layers from the MapView
            LayerOverlay         elevationPointsOverlay = (LayerOverlay)mapView.Overlays["Elevation Features Overlay"];
            InMemoryFeatureLayer drawnShapesLayer       = (InMemoryFeatureLayer)elevationPointsOverlay.Layers["Drawn Shape Layer"];
            InMemoryFeatureLayer elevationPointsLayer   = (InMemoryFeatureLayer)elevationPointsOverlay.Layers["Elevation Points Layer"];

            // Clear the existing shapes from the map
            elevationPointsLayer.Open();
            elevationPointsLayer.Clear();
            elevationPointsLayer.Close();
            drawnShapesLayer.Open();
            drawnShapesLayer.Clear();
            drawnShapesLayer.Close();

            // Add the drawn shape to the map
            drawnShapesLayer.InternalFeatures.Add(new Feature(queryShape));

            // Set options from the UI and run the query using the ElevationCloudClient
            Collection <CloudElevationPointResult> elevationPoints = new Collection <CloudElevationPointResult>();
            int projectionInSrid = 3857;

            // Show a loading graphic to let users know the request is running
            loadingIndicator.IsRunning = true;
            loadingLayout.IsVisible    = true;

            // The point interval distance determines how many elevation points are retrieved for line and area queries
            int pointIntervalDistance = (int)intervalDistance.Value;

            switch (queryShape.GetWellKnownType())
            {
            case WellKnownType.Point:
                PointShape drawnPoint = (PointShape)queryShape;
                double     elevation  = await elevationCloudClient.GetElevationOfPointAsync(drawnPoint.X, drawnPoint.Y, projectionInSrid);

                // The API for getting the elevation of a single point returns a double, so we manually create a CloudElevationPointResult to use as a data source for the Elevations list
                elevationPoints.Add(new CloudElevationPointResult(elevation, drawnPoint));

                // Update the UI with the average, highest, and lowest elevations
                txtAverageElevation.Text = $"Average Elevation: {elevation:0.00} feet";
                txtHighestElevation.Text = $"Highest Elevation: {elevation:0.00} feet";
                txtLowestElevation.Text  = $"Lowest Elevation: {elevation:0.00} feet";
                break;

            case WellKnownType.Line:
                LineShape drawnLine = (LineShape)queryShape;
                var       result    = await elevationCloudClient.GetElevationOfLineAsync(drawnLine, projectionInSrid, pointIntervalDistance, DistanceUnit.Meter, DistanceUnit.Feet);

                elevationPoints = result.ElevationPoints;

                // Update the UI with the average, highest, and lowest elevations
                txtAverageElevation.Text = $"Average Elevation: {result.AverageElevation:0.00} feet";
                txtHighestElevation.Text = $"Highest Elevation: {result.HighestElevationPoint.Elevation:0.00} feet";
                txtLowestElevation.Text  = $"Lowest Elevation: {result.LowestElevationPoint.Elevation:0.00} feet";
                break;

            case WellKnownType.Polygon:
                PolygonShape drawnPolygon = (PolygonShape)queryShape;
                result = await elevationCloudClient.GetElevationOfAreaAsync(drawnPolygon, projectionInSrid, pointIntervalDistance, DistanceUnit.Meter, DistanceUnit.Feet);

                elevationPoints = result.ElevationPoints;

                // Update the UI with the average, highest, and lowest elevations
                txtAverageElevation.Text = $"Average Elevation: {result.AverageElevation:0.00} feet";
                txtHighestElevation.Text = $"Highest Elevation: {result.HighestElevationPoint.Elevation:0.00} feet";
                txtLowestElevation.Text  = $"Lowest Elevation: {result.LowestElevationPoint.Elevation:0.00} feet";
                break;

            default:
                break;
            }

            // Add the elevation result points to the map and list box
            foreach (CloudElevationPointResult elevationPoint in elevationPoints)
            {
                elevationPointsLayer.InternalFeatures.Add(new Feature(elevationPoint.Point));
            }
            lsbElevations.ItemsSource = elevationPoints;

            // Hide the loading graphic
            loadingIndicator.IsRunning = false;
            loadingLayout.IsVisible    = false;

            // Set the map extent to the elevation query feature
            drawnShapesLayer.Open();
            mapView.CenterAt(drawnShapesLayer.GetBoundingBox().GetCenterPoint());
            drawnShapesLayer.Close();
            mapView.Refresh();
        }