internal static LatLonZoom DefaultReferenceMapPosition(SourceMap sourceMap, MapTileSourceFactory mapTileSourceFactory, ViewControlIfc viewControl, DefaultReferenceView drv) { if (sourceMap.ReadyToLock()) { try { ViewerControlIfc sMViewerControl = viewControl.GetSMViewerControl(); MapRectangle bounds = sMViewerControl.GetBounds(); WarpedMapTileSource warpedMapTileSource = mapTileSourceFactory.CreateWarpedSource(sourceMap); IPointTransformer sourceToDestLatLonTransformer = warpedMapTileSource.GetSourceToDestLatLonTransformer(); MapRectangle mapRectangle = bounds.Transform(sourceToDestLatLonTransformer); mapRectangle = mapRectangle.ClipTo(new MapRectangle(-180.0, -360.0, 180.0, 360.0)); return(viewControl.GetVEViewerControl().GetCoordinateSystem() .GetBestViewContaining(mapRectangle, sMViewerControl.Size)); } catch (CorrespondencesAreSingularException) { } catch (InsufficientCorrespondencesException) { } } if (drv != null && drv.present) { return(drv.llz); } return(viewControl.GetVEViewerControl().GetCoordinateSystem().GetDefaultView()); }
public MapRectangle GetUserBoundingBox(MapTileSourceFactory mapTileSourceFactory) { WarpedMapTileSource warpedMapTileSource = null; try { warpedMapTileSource = mapTileSourceFactory.CreateWarpedSource(this); } catch (InsufficientCorrespondencesException) { } if (warpedMapTileSource == null) { return(null); } Present present = warpedMapTileSource.GetUserBounds(null, FutureFeatures.Cached).Realize("SourceMap.AutoSelectMaxZoom"); if (!(present is BoundsPresent)) { return(null); } BoundsPresent boundsPresent = (BoundsPresent)present; MapRectangle boundingBox = boundsPresent.GetRenderRegion().GetBoundingBox(); return(boundingBox.ClipTo(CoordinateSystemUtilities.GetRangeAsMapRectangle(MercatorCoordinateSystem.theInstance))); }