Exemplo n.º 1
0
        private void AdjustFrameBufferMatrix(MapPosition mapPositionFrameBuffer, Dimension mapViewDimension, double scaleFactor, LatLong pivot)
        {
            MapPosition mapViewPosition = this.model.mapViewPosition.MapPosition;

            long mapSize = MercatorProjection.GetMapSize(mapPositionFrameBuffer.ZoomLevel, model.displayModel.TileSize);

            Point pointFrameBuffer = MercatorProjection.GetPixel(mapPositionFrameBuffer.LatLong, mapSize);
            Point pointMapPosition = MercatorProjection.GetPixel(mapViewPosition.LatLong, mapSize);

            double diffX = pointFrameBuffer.X - pointMapPosition.X;
            double diffY = pointFrameBuffer.Y - pointMapPosition.Y;
            // we need to compute the pivot distance from the map center
            // as we will need to find the pivot point for the
            // frame buffer (which generally has not the same size as the
            // map view).
            double pivotDistanceX = 0d;
            double pivotDistanceY = 0d;

            if (pivot != null)
            {
                Point pivotXY = MercatorProjection.GetPixel(pivot, mapSize);
                pivotDistanceX = pivotXY.X - pointFrameBuffer.X;
                pivotDistanceY = pivotXY.Y - pointFrameBuffer.Y;
            }

            float currentScaleFactor = (float)(scaleFactor / Math.Pow(2, mapPositionFrameBuffer.ZoomLevel));

            this.frameBuffer.AdjustMatrix((float)diffX, (float)diffY, currentScaleFactor, mapViewDimension, (float)pivotDistanceX, (float)pivotDistanceY);
        }
Exemplo n.º 2
0
 /// <summary>
 /// The pivot point is the point the map zooms around. If the map zooms around its center null is returned, otherwise
 /// the zoom-specific x/y pixel coordinates for the MercatorProjection (note: not the x/y coordinates for the map
 /// view or the frame buffer, the MapViewPosition knows nothing about them).
 /// </summary>
 /// <param name="zoomLevel"> the zoomlevel to compute the x/y coordinates for </param>
 /// <returns> the x/y coordinates of the map pivot point if set or null otherwise. </returns>
 public virtual Point GetPivotXY(sbyte zoomLevel)
 {
     lock (this)
     {
         if (this.pivot != null)
         {
             return(MercatorProjection.GetPixel(this.pivot, MercatorProjection.GetMapSize(zoomLevel, displayModel.TileSize)));
         }
         return(null);
     }
 }