ESRI.ArcGIS.Client.Toolkit.DataSources.KmlLayer.IsInRegion C# (CSharp) Method

IsInRegion() private method

private IsInRegion ( Map map, Envelope region ) : bool
map Map
region Envelope
return bool
        private bool IsInRegion(Map map, Envelope region)
        {
            if (region == null)
                return true; // region not defined --> we can load the layer without waiting for map extent

            if (map == null)
                return false;

            Envelope extent = map.Extent;
            if (extent == null || extent.SpatialReference == null)
                return false;

            // KML LODS are based on the diagonal size
            double regionSize = Math.Sqrt(region.Width * region.Width + region.Height * region.Height);

            // Test that current map extent intersects the KML region
            if (!region.Intersects(extent))
                return false;

            // Test the LOD level
            double lod = regionSize / map.Resolution;

            return !(lod < RegionInfo.MinLodPixels || (lod > RegionInfo.MaxLodPixels && RegionInfo.MaxLodPixels != -1)); // Keep ! to take care of NaN
        }