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); } var present = warpedMapTileSource.GetUserBounds(null, FutureFeatures.Cached) .Realize("SourceMap.AutoSelectMaxZoom"); if (!(present is BoundsPresent)) { return(null); } var boundsPresent = (BoundsPresent)present; var boundingBox = boundsPresent.GetRenderRegion().GetBoundingBox(); return(boundingBox.ClipTo( CoordinateSystemUtilities.GetRangeAsMapRectangle(MercatorCoordinateSystem.theInstance))); }
private void SetupLockedView() { WarpedMapTileSource warpedMapTileSource = this.mapTileSourceFactory.CreateWarpedSource(this.sourceMap); this.viewControl.GetSMViewerControl().ClearLayers(); this.viewControl.GetSMViewerControl().SetBaseLayer(warpedMapTileSource); this.viewControl.GetUIPositionManager().switchSlaved(); this.viewControl.setDisplayedRegistration(new RegistrationControlRecord(warpedMapTileSource.ComputeWarpedRegistration(), this.sourceMap)); this.mapsLocked = true; }
internal bool AccumulateBoundingBox(SourceMap sourceMap, MapTileSourceFactory mapTileSourceFactory, ref MapRectangle boundingBox) { bool result; try { WarpedMapTileSource warpedMapTileSource = mapTileSourceFactory.CreateWarpedSource(sourceMap); BoundsPresent boundsPresent = (BoundsPresent)warpedMapTileSource.GetUserBounds(null, FutureFeatures.Cached).Realize("CrunchedFile.AccumulateBoundingBox"); boundsPresent.GetRenderRegion().AccumulateBoundingBox(ref boundingBox); result = true; } catch (InsufficientCorrespondencesException) { result = false; } return(result); }
public void UnlockMaps() { if (!this.mapsLocked) { throw new Exception("uh oh. trying to unlock maps that are already unlocked!"); } this.SetupUnlockedView(); ViewerControlIfc sMViewerControl = this.viewControl.GetSMViewerControl(); MapRectangle bounds = this.viewControl.GetVEViewerControl().GetBounds(); WarpedMapTileSource warpedMapTileSource = this.mapTileSourceFactory.CreateWarpedSource(this.sourceMap); IPointTransformer destLatLonToSourceTransformer = warpedMapTileSource.GetDestLatLonToSourceTransformer(); MapRectangle newBounds = bounds.Transform(destLatLonToSourceTransformer); LatLonZoom latLonZoom = sMViewerControl.GetCoordinateSystem().GetBestViewContaining(newBounds, sMViewerControl.Size); latLonZoom = CoordinateSystemUtilities.ConstrainLLZ(ContinuousCoordinateSystem.theInstance, latLonZoom); this.viewControl.GetUIPositionManager().GetSMPos().setPosition(latLonZoom); this.viewControl.GetUIPositionManager().PositionUpdated(); }