public void zoom(int zoomFactor) { if (this.baseLayer != null) { this.center().setPosition(CoordinateSystemUtilities.GetZoomedView(this.GetCoordinateSystem(), this.center().llz, zoomFactor)); } }
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))); }
internal LatLonZoom GetDefaultView(Layer layer, Size assumedDisplaySize, MapTileSourceFactory mapTileSourceFactory, out bool allBoundsValid) { MapRectangle mapRectangle = null; allBoundsValid = true; foreach (SourceMap current in layer) { if (!AccumulateBoundingBox(current, mapTileSourceFactory, ref mapRectangle)) { allBoundsValid = false; } } LatLonZoom bestViewContaining; if (mapRectangle == null) { bestViewContaining = MercatorCoordinateSystem.theInstance.GetDefaultView(); } else { bestViewContaining = MercatorCoordinateSystem.theInstance.GetBestViewContaining(mapRectangle, assumedDisplaySize); } return(CoordinateSystemUtilities.ConstrainLLZ(MercatorCoordinateSystem.theInstance, bestViewContaining)); }
protected override void OnMouseDoubleClick(MouseEventArgs e) { if (this.baseLayer != null) { Point point = this.ScreenCenter(); Point offsetInPixels = new Point(point.X - e.Location.X, point.Y - e.Location.Y); this.center().setPosition(CoordinateSystemUtilities.GetZoomedView(this.GetCoordinateSystem(), this.GetCoordinateSystem().GetTranslationInLatLon(this.center().llz, offsetInPixels), 1)); } base.OnMouseDoubleClick(e); }
private void UpdateState(State state) { if (state.Equals(lastState)) { return; } TracedScreenPoint[] path = GetUserRegion() .GetPath(CoordinateSystemUtilities.GetBounds(csi, state.center, state.size), state.center.zoom, csi); List <TracedScreenPoint> list = new List <TracedScreenPoint>(); int length = path.GetLength(0); for (int i = 0; i < length; i++) { D.Assert(path[i].originalIndex >= 0); int num = (i + length - 1) % length; if (!(path[num].pointf == path[i].pointf)) { list.Add(path[i]); } } list.ToArray(); int count = list.Count; List <ClickableThing> list2 = new List <ClickableThing>(); List <ClickableThing> list3 = new List <ClickableThing>(); for (int j = 0; j < count; j++) { ClickableThing clickableThing = new ClickableThing(); list2.Add(clickableThing); clickableThing.vertexLocation = list[j]; clickableThing.path = new GraphicsPath(); clickableThing.path.AddEllipse(list[j].pointf.X - 4f, list[j].pointf.Y - 4f, 8f, 8f); clickableThing.clickedWhich = ClickableThing.ClickedWhich.Vertex; clickableThing.pointIndex = j; ClickableThing clickableThing2 = new ClickableThing(); list3.Add(clickableThing2); clickableThing2.vertexLocation = list[j]; clickableThing2.path = new GraphicsPath(); clickableThing2.path.AddLine(list[j].pointf, list[(j + 1) % count].pointf); clickableThing2.path.Widen(new Pen(Color.Black, 4f)); clickableThing2.clickedWhich = ClickableThing.ClickedWhich.Segment; clickableThing2.pointIndex = j; } list2.AddRange(list3); clickableThings = list2.ToArray(); lastState = new State(state); }
public static double DistanceInMeters(LatLon p1, LatLon p2) { double num = CoordinateSystemUtilities.DegreesToRadians(p1.lon); double num2 = CoordinateSystemUtilities.DegreesToRadians(p1.lat); double num3 = CoordinateSystemUtilities.DegreesToRadians(p2.lon); double num4 = CoordinateSystemUtilities.DegreesToRadians(p2.lat); double num5 = num3 - num; double num6 = num4 - num2; double d = Math.Pow(Math.Sin(num6 / 2.0), 2.0) + Math.Cos(num2) * Math.Cos(num4) * Math.Pow(Math.Sin(num5 / 2.0), 2.0); double num7 = 2.0 * Math.Asin(Math.Min(1.0, Math.Sqrt(d))); return(6378137.0 * num7); }
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(); }
public MapRectangle GetBounds() { return(CoordinateSystemUtilities.GetBounds(this.baseLayer.GetDefaultCoordinateSystem(), this.center().llz, base.Size)); }