Exemple #1
0
        private IEnumerable <Feature> ShatterTwoFeatures(ref Feature feature1, Feature feature2)
        {
            Collection <Feature> resultFeatures = new Collection <Feature>();
            var columns = GetColumnValues(feature1, feature2);

            // var diff1 = feature1.GetDifference(feature2);
            feature1 = SqlTypesGeometryHelper.MakeValid(feature1);
            feature2 = SqlTypesGeometryHelper.MakeValid(feature2);
            var diff1 = SqlTypesGeometryHelper.GetDifference(feature1, feature2);
            //var diff2 = feature2.GetDifference(feature1);
            var diff2 = SqlTypesGeometryHelper.GetDifference(feature2, feature1);
            //var inter = feature1.GetIntersection(feature2);
            var inter = SqlTypesGeometryHelper.GetIntersection(feature1, feature2);

            feature1 = diff1;
            if (inter != null)
            {
                inter = new Feature(inter.GetWellKnownBinary(), inter.Id, columns);
                AddValidFeature(resultFeatures, inter);
            }

            if (diff2 != null)
            {
                AddValidFeature(resultFeatures, diff2);
            }

            return(resultFeatures);
        }
        public static Collection <Feature> GetFeaturesIntersecting(this QueryTools queryTools, BaseShape targetShape, IEnumerable <string> returningColumnNames, bool useSqlType)
        {
            Collection <Feature> returnFeatures = null;

            if (useSqlType)
            {
                returnFeatures = new Collection <Feature>();
                RectangleShape       boundingBox         = targetShape.GetBoundingBox();
                Collection <Feature> allPossibleFeatures = queryTools.GetFeaturesInsideBoundingBox(boundingBox, returningColumnNames);
                foreach (Feature feature in allPossibleFeatures)
                {
                    BaseShape sourceShape = feature.GetShape();
                    sourceShape = SqlTypesGeometryHelper.MakeValid(sourceShape);
                    targetShape = SqlTypesGeometryHelper.MakeValid(targetShape);
                    bool intersects = SqlTypesGeometryHelper.Intersects(sourceShape, targetShape);
                    if (intersects)
                    {
                        returnFeatures.Add(feature);
                    }
                }
            }
            else
            {
                returnFeatures = queryTools.GetFeaturesIntersecting(targetShape, returningColumnNames);
            }
            return(returnFeatures);
        }
        protected virtual Feature CreateHighlightFeatureCore(Feature sourceFeature, FeatureLayer sourceFeatureLayer)
        {
            string newFeatureId = CreateHighlightFeatureId(sourceFeature, sourceFeatureLayer);

            try
            {
                sourceFeature = SqlTypesGeometryHelper.MakeValid(sourceFeature);
            }
            catch { }

            Feature newFeature = new Feature(sourceFeature.GetWellKnownBinary(), newFeatureId, sourceFeature.ColumnValues);

            //LINK:
            //foreach (var item in sourceFeature.LinkColumnValues)
            //{
            //    newFeature.LinkColumnValues.Add(item.Key, item.Value);
            //}
            newFeature.Tag = sourceFeature.Tag;
            return(newFeature);
        }
Exemple #4
0
        public static Feature UnionAreaFeatures(IEnumerable <Feature> features)
        {
            Collection <Feature> tempFeatuers = new Collection <Feature>();

            foreach (var item in features)
            {
                if (!SqlTypesGeometryHelper.IsValid(item))
                {
                    tempFeatuers.Add(SqlTypesGeometryHelper.MakeValid(item));
                }
                else
                {
                    tempFeatuers.Add(item);
                }
            }

            var unionresult = AreaBaseShape.Union(tempFeatuers);

            return(new Feature(unionresult));
        }
        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);
        }