Esempio n. 1
0
        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());
        }
Esempio n. 2
0
        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)));
        }
Esempio n. 3
0
        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;
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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();
        }