Beispiel #1
0
        public static int GetContainedCount(List <Esri.ArcGISRuntime.Geometry.Geometry> countableGeometries, Esri.ArcGISRuntime.Geometry.Geometry containingPolygon, int bufferInMeters = 0)
        {
            var count = 0;

            if (countableGeometries == null)
            {
                return(count);
            }

            var polyCorrected = GeometryEngine.RemoveZAndM(containingPolygon);

            polyCorrected = Esri.ArcGISRuntime.Geometry.Geometry.FromJson(polyCorrected.ToJson());

            polyCorrected = GeometryEngine.Buffer(polyCorrected, bufferInMeters);

            foreach (var geom in countableGeometries)
            {
                if (polyCorrected.SpatialReference != geom.SpatialReference)
                {
                    polyCorrected = GeometryEngine.Project(polyCorrected, geom.SpatialReference);
                }

                var geomCorrected = GeometryEngine.RemoveZAndM(geom);
                geomCorrected = Esri.ArcGISRuntime.Geometry.Geometry.FromJson(geomCorrected.ToJson());

                var isContained = Esri.ArcGISRuntime.Geometry.GeometryEngine.Contains(polyCorrected, geomCorrected);
                count += isContained ? 1 : 0;
            }

            return(count);
        }