Example #1
0
		internal Present Render(MapRectangle mapRect, Size size, bool useDocumentTransparency, bool exactColors)
		{
			Monitor.Enter(this);
			Present result;
			try
			{
				RectangleD rectangleD = new RectangleD(mapRect.lon0 * (double)this.boundingBox.Width - 0.5, -mapRect.lat1 * (double)this.boundingBox.Height + (double)this.actualBoundingBox.Height - 0.5, (mapRect.lon1 - mapRect.lon0) * (double)this.boundingBox.Width + (double)this.hackRectangleAdjust, (mapRect.lat1 - mapRect.lat0) * (double)this.boundingBox.Height + (double)this.hackRectangleAdjust);
				RectangleD rectangleD2 = new RectangleD(0.0, 0.0, (double)size.Width, (double)size.Height);
				this.Reclip(this.actualBoundingBox, ref rectangleD, ref rectangleD2);
				D.Say(10, string.Format("Rendering {0} from {1}", mapRect, rectangleD));
				GDIBigLockedImage gDIBigLockedImage = new GDIBigLockedImage(size, "GDIVerb");
				if (exactColors)
				{
					gDIBigLockedImage.SetInterpolationMode(InterpolationMode.NearestNeighbor);
				}
				else
				{
					gDIBigLockedImage.SetInterpolationMode(InterpolationMode.HighQualityBicubic);
				}
				gDIBigLockedImage.DrawImageOntoThis(this.loadedImage, rectangleD2.ToRectangleF(), rectangleD.ToRectangleF());
				result = new ImageRef(new ImageRefCounted(gDIBigLockedImage));
			}
			finally
			{
				Monitor.Exit(this);
			}
			return result;
		}
Example #2
0
        internal Present Render(MapRectangle mapRect, Size size, bool useDocumentTransparency, bool exactColors)
        {
            RectangleF rectangleF = new RectangleF((float)mapRect.lon0, (float)mapRect.lat0, (float)(mapRect.lon1 - mapRect.lon0), (float)(mapRect.lat1 - mapRect.lat0));
            double     num        = (double)this.actualBoundingBox.Width / (double)this.boundingBox.Width;
            double     num2       = (double)this.actualBoundingBox.Height / (double)this.boundingBox.Height;
            Size       pagesize   = new Size((int)Math.Round((double)size.Width / (double)rectangleF.Width * num), (int)Math.Round((double)size.Height / (double)rectangleF.Height * num2));
            Point      topleft    = new Point((int)Math.Round((double)(-(double)pagesize.Width) / num * mapRect.lon0), (int)Math.Round((double)(-(double)pagesize.Height) / num2 * (num2 - mapRect.lat1)));

            if (pagesize.Width > 262144 || pagesize.Width <= 0 || pagesize.Height > 262144 || pagesize.Height <= 0)
            {
                return(new PresentFailureCode("Zoomed beyond FoxIt limits"));
            }
            IFoxitViewer obj;

            Monitor.Enter(obj = this.foxitViewer);
            GDIBigLockedImage image;

            try
            {
                image = this.foxitViewer.Render(size, topleft, pagesize, useDocumentTransparency);
            }
            finally
            {
                Monitor.Exit(obj);
            }
            return(new ImageRef(new ImageRefCounted(image)));
        }
Example #3
0
        /// <summary> Event handler for a change of the map viewport. Renders a ball for each of the earthquake
        /// clusters in the current map display section. </summary>
        private void UpdateBalls()
        {
            Children.Clear();

            MapRectangle rect     = MapView.FinalEnvelope;
            var          clusters = clusterer.GetClusters(rect.West, rect.South, rect.East, rect.North, (int)MapView.FinalZoom + 1);

            foreach (var cluster in clusters)
            {
                var toolTip = "";
                var point   = new Point(cluster.CentroidX, cluster.CentroidY);

                if (cluster.Tags.Count <= 25)
                {
                    toolTip = cluster.Tags.Aggregate(toolTip, (current, post) => current + (post.Title + " " + post.Location.Y + " / " + post.Location.X + "\n"));
                    toolTip = toolTip.Substring(0, toolTip.Length - 1);
                }
                else
                {
                    toolTip = cluster.Tags.Count + " objects.";
                }

                renderBall(toolTip, point, cluster.Tags.Count);
            }
        }
        public TileDisplayDescriptorArray GetTileArrayDescriptor(LatLonZoom center, Size windowSize)
        {
            TileDisplayDescriptorArray tileDisplayDescriptorArray = new TileDisplayDescriptorArray();
            MapRectangle mapWindow = this.GetMapWindow(center, windowSize);

            tileDisplayDescriptorArray.topLeftTile = this.GetTileContainingLatLonZoom(new LatLonZoom(mapWindow.GetNW(), center.zoom));
            TileAddress tileContainingLatLonZoom = this.GetTileContainingLatLonZoom(new LatLonZoom(mapWindow.GetSE(), center.zoom));

            tileDisplayDescriptorArray.tileCountX = tileContainingLatLonZoom.TileX - tileDisplayDescriptorArray.topLeftTile.TileX + 1;
            tileDisplayDescriptorArray.tileCountY = tileContainingLatLonZoom.TileY - tileDisplayDescriptorArray.topLeftTile.TileY + 1;
            int x    = this.GetTranslationInPixels(center, this.GetLatLonOfTileNW(tileDisplayDescriptorArray.topLeftTile)).X;
            int x2   = this.GetTranslationInPixels(center, this.GetLatLonOfTileNW(new TileAddress(tileDisplayDescriptorArray.topLeftTile.TileX + tileDisplayDescriptorArray.tileCountX, tileDisplayDescriptorArray.topLeftTile.TileY, tileDisplayDescriptorArray.topLeftTile.ZoomLevel))).X;
            int num  = x2 - x;
            int num2 = windowSize.Width + 512;

            if (num > num2)
            {
                D.Sayf(0, "break", new object[0]);
            }
            tileDisplayDescriptorArray.layout   = this.addressLayout;
            tileDisplayDescriptorArray.tileSize = this.GetTileSize();
            Point64 point = this.LatLongZoomToPixel(new LatLonZoom(mapWindow.GetNW(), center.zoom));

            tileDisplayDescriptorArray.topLeftTileOffset = new Point64((long)tileDisplayDescriptorArray.topLeftTile.TileX * 256L - point.X, (long)tileDisplayDescriptorArray.topLeftTile.TileY * 256L - point.Y).ToPoint();
            tileDisplayDescriptorArray.topLeftTile.TileX = VEAddressLayout.WrapLongitude(tileDisplayDescriptorArray.topLeftTile.TileX, tileDisplayDescriptorArray.topLeftTile.ZoomLevel);
            return(tileDisplayDescriptorArray);
        }
Example #5
0
        public Present Evaluate(Present[] paramList)
        {
            D.Assert(paramList.Length == 3);
            for (int i = 0; i < paramList.Length; i++)
            {
                Present present = paramList[i];
                if (present is PresentFailureCode)
                {
                    return(present);
                }
            }
            if (!(paramList[0] is ImageRef))
            {
                return(paramList[0]);
            }
            ImageRef          imageRef          = (ImageRef)paramList[0];
            TileAddress       tileAddress       = (TileAddress)paramList[1];
            BoundsPresent     boundsPresent     = (BoundsPresent)paramList[2];
            MapRectangle      mapWindow         = CoordinateSystemUtilities.TileAddressToMapRectangle(this.coordinateSystem, tileAddress);
            Region            clipRegion        = boundsPresent.GetRenderRegion().GetClipRegion(mapWindow, tileAddress.ZoomLevel, this.coordinateSystem);
            GDIBigLockedImage gDIBigLockedImage = new GDIBigLockedImage(imageRef.image.Size, "UserClipperVerb");

            gDIBigLockedImage.SetClip(clipRegion);
            gDIBigLockedImage.DrawImageOntoThis(imageRef.image, new RectangleF(0f, 0f, (float)gDIBigLockedImage.Size.Width, (float)gDIBigLockedImage.Size.Height), new RectangleF(0f, 0f, (float)imageRef.image.Size.Width, (float)imageRef.image.Size.Height));
            ImageRef result = new ImageRef(new ImageRefCounted(gDIBigLockedImage));

            boundsPresent.Dispose();
            imageRef.Dispose();
            return(result);
        }
Example #6
0
        public static MapShape CreateUserShape(ShapeData data)
        {
            var shape = new MapRectangle()
            {
                Width    = data.Width,
                Height   = data.Height,
                Location = new Location(data.Latitude, data.Longitude)
            };

            var user = data.Tag as entities.User;

            if (user != null)
            {
                var propertySet = new ExtendedPropertySet();
                propertySet.RegisterProperty("Placemark.Name", "Name", typeof(string), string.Empty); // KML file defines Placemark.Name, we create a same property too.
                var extendedData = new ExtendedData(propertySet);
                extendedData.SetValue("Placemark.Name", user.UserName);

                shape.ExtendedData = extendedData;
                shape.Tag          = user;
            }

            //set CaptionTemplate
            shape.CaptionTemplate = Application.Current.FindResource("ShapeCaptionTemplate") as DataTemplate; //In the template, we use ExtendedData["Placemark.Name"] as caption

            return(shape);
        }
Example #7
0
        public Present Evaluate(Present[] paramList)
        {
            D.Assert(paramList.Length == 2);
            MapRectangle value        = ((MapRectangleParameter)paramList[0]).value;
            Size         value2       = ((SizeParameter)paramList[1]).value;
            MapRectangle mapRectangle = value.Transform(imageTransformer.getDestLatLonToSourceTransformer())
                                        .GrowFraction(0.05);
            Present present = warpedBoundsFuture.Realize("WarpImageVerb.Evaluate-bounds");

            if (present is BoundsPresent)
            {
                MapRectangle boundingBox = ((BoundsPresent)present).GetRenderRegion().GetBoundingBox();
                if (!boundingBox.intersects(value))
                {
                    return(new BeyondImageBounds());
                }
            }

            Present present2 = sourceMapSupplier.Curry(new ParamDict(new object[]
            {
                TermName.ImageBounds, new MapRectangleParameter(mapRectangle)
            })).Realize("WarpImageVerb.Evaluate");

            if (present2 is PresentFailureCode)
            {
                return(present2);
            }

            ImageRef          imageRef          = (ImageRef)present2;
            GDIBigLockedImage gDIBigLockedImage = new GDIBigLockedImage(value2, "WarpImageVerb");

            imageTransformer.doTransformImage(imageRef.image, mapRectangle, gDIBigLockedImage, value);
            imageRef.Dispose();
            return(new ImageRef(new ImageRefCounted(gDIBigLockedImage)));
        }
Example #8
0
        public Present Evaluate(Present[] paramList)
        {
            MapRectangle mapRectangle = null;
            int          i            = 0;

            while (i < paramList.Length)
            {
                Present present = paramList[i];
                Present result;
                if (present is PresentFailureCode)
                {
                    result = new PresentFailureCode((PresentFailureCode)present, "CompositeBoundsVerb");
                }
                else
                {
                    if (present is BoundsPresent)
                    {
                        ((BoundsPresent)present).GetRenderRegion().AccumulateBoundingBox(ref mapRectangle);
                        i++;
                        continue;
                    }
                    result = new PresentFailureCode(new Exception("Unexpected result of child computation in CompositeBoundsVerb"));
                }
                return(result);
            }
            if (mapRectangle == null)
            {
                return(new PresentFailureCode("No valid sourcemaps in input."));
            }
            RenderRegion renderRegion = new RenderRegion(mapRectangle, new DirtyEvent());

            return(new BoundsPresent(renderRegion));
        }
Example #9
0
        private void HandleMarker(IMapMarker marker)
        {
            if (!_markerTextures.ContainsKey(marker.TextureIdentifier))
            {
                using (var str = marker.GetImage())
                {
                    _markerTextures.Add(marker.TextureIdentifier, Texture2D.FromStream(_device, str));
                }
            }

            if (!marker.Visible)
            {
                return;
            }

            var vp = _map.LatLonToViewPoint(marker.Position);

            vp -= marker.Offset;

            var rect = new MapRectangle((int)Math.Round(vp.X), (int)Math.Round(vp.Y), marker.Size.Width, marker.Size.Height);

            // Check if a part of the thing is drawn at all...
            if (rect.X < -(rect.Width) ||
                rect.Y < -(rect.Height) ||
                rect.X > ViewBounds.X + ViewBounds.Width ||
                rect.Y > ViewBounds.Y + ViewBounds.Height)
            {
                return;
            }

            var srcRect  = _map.GetSourceRectangle(rect);
            var destRect = _map.GetDestRectangle(rect);

            _sBatch.Draw(_markerTextures[marker.TextureIdentifier], destRect.ToRectangle(), srcRect.ToRectangle(), Color.White);
        }
        public LatLonZoom GetBestViewContaining(MapRectangle newBounds, Size size)
        {
            LatLon center = newBounds.GetCenter();
            int    zoom   = (int)(exactZoom(size.Height / (newBounds.lat1 - newBounds.lat0)) + 0.99);

            return(new LatLonZoom(center.lat, center.lon, zoom));
        }
Example #11
0
        internal Present Render(MapRectangle mapRect, Size size, bool useDocumentTransparency, bool exactColors)
        {
            Monitor.Enter(this);
            Present result;

            try
            {
                RectangleD rectangleD  = new RectangleD(mapRect.lon0 * (double)this.boundingBox.Width - 0.5, -mapRect.lat1 * (double)this.boundingBox.Height + (double)this.actualBoundingBox.Height - 0.5, (mapRect.lon1 - mapRect.lon0) * (double)this.boundingBox.Width + (double)this.hackRectangleAdjust, (mapRect.lat1 - mapRect.lat0) * (double)this.boundingBox.Height + (double)this.hackRectangleAdjust);
                RectangleD rectangleD2 = new RectangleD(0.0, 0.0, (double)size.Width, (double)size.Height);
                this.Reclip(this.actualBoundingBox, ref rectangleD, ref rectangleD2);
                D.Say(10, string.Format("Rendering {0} from {1}", mapRect, rectangleD));
                GDIBigLockedImage gDIBigLockedImage = new GDIBigLockedImage(size, "GDIVerb");
                if (exactColors)
                {
                    gDIBigLockedImage.SetInterpolationMode(InterpolationMode.NearestNeighbor);
                }
                else
                {
                    gDIBigLockedImage.SetInterpolationMode(InterpolationMode.HighQualityBicubic);
                }
                gDIBigLockedImage.DrawImageOntoThis(this.loadedImage, rectangleD2.ToRectangleF(), rectangleD.ToRectangleF());
                result = new ImageRef(new ImageRefCounted(gDIBigLockedImage));
            }
            finally
            {
                Monitor.Exit(this);
            }
            return(result);
        }
		private RectangleF SelectSubRectangle(MapRectangle bounds, MapRectangle region, Size size)
		{
			float num = (float)((region.lon0 - bounds.lon0) / bounds.LonExtent * (double)size.Width);
			float num2 = (float)((double)size.Height - (region.lat0 - bounds.lat0) / bounds.LatExtent * (double)size.Height);
			float num3 = (float)((region.lon1 - bounds.lon0) / bounds.LonExtent * (double)size.Width);
			float num4 = (float)((double)size.Height - (region.lat1 - bounds.lat0) / bounds.LatExtent * (double)size.Height);
			return new RectangleF(num, num4, num3 - num, num2 - num4);
		}
        private RectangleF SelectSubRectangle(MapRectangle bounds, MapRectangle region, Size size)
        {
            float num  = (float)((region.lon0 - bounds.lon0) / bounds.LonExtent * (double)size.Width);
            float num2 = (float)((double)size.Height - (region.lat0 - bounds.lat0) / bounds.LatExtent * (double)size.Height);
            float num3 = (float)((region.lon1 - bounds.lon0) / bounds.LonExtent * (double)size.Width);
            float num4 = (float)((double)size.Height - (region.lat1 - bounds.lat0) / bounds.LatExtent * (double)size.Height);

            return(new RectangleF(num, num4, num3 - num, num2 - num4));
        }
Example #14
0
        public static Point GetLocation(UIElement element)
        {
            var result = (Point)element.GetValue(LocationProperty);

            if (!result.IsValidGeoCoordinate() && element is MapPolylineBase mapPolyline)
            {
                result = new MapRectangle(mapPolyline.Points).Center;
            }
            return(result);
        }
Example #15
0
    private void findCorners()
    {
        mapRectangle = new MapRectangle();

        MyPoint SW_Mercator = new MyPoint(centerMercator.x - widthMercatorX / 2.0f, centerMercator.y - heightMercatorY / 2.0f);

        MyPoint NE_Mercator     = new MyPoint(centerMercator.x + widthMercatorX / 2.0f, centerMercator.y + heightMercatorY / 2.0f);
        MyPoint mapCenterMeters = new MyPoint(gameObject.transform.position.x, gameObject.transform.position.z);

        mapRectangle.setCorners(SW_Mercator, NE_Mercator, mapCenterMeters);
    }
        protected override void InitializeItem(MapItem item, object obj)
        {
            base.InitializeItem(item, obj);
            MapRectangle rect = item as MapRectangle;

            if (rect != null)
            {
                rect.Width  = 1000;
                rect.Height = 1000;
            }
        }
		internal override void doTransformImage(GDIBigLockedImage sourceImage, MapRectangle sourceBounds, GDIBigLockedImage destImage, MapRectangle destBounds)
		{
			MapRectangle inr = new MapRectangle(-0.5, -0.5, (double)destImage.Height - 0.5, (double)destImage.Width - 0.5);
			MapRectangle outr = MapRectangle.MapRectangleIgnoreOrder(MercatorCoordinateSystem.LatLonToMercator(destBounds.GetNW()), MercatorCoordinateSystem.LatLonToMercator(destBounds.GetSE()));
			JamaMatrix matrix = PolynomialImageTransformer.FindAffineMatrix(inr, outr);
			MapRectangle outr2 = new MapRectangle(-0.5, -0.5, (double)sourceImage.Height - 0.5, (double)sourceImage.Width - 0.5);
			JamaMatrix matrix2 = PolynomialImageTransformer.FindAffineMatrix(sourceBounds, outr2);
			FastImageWarper.doWarp(destImage, sourceImage, new IPointTransformer[]
			{
				new Affine2DPointTransformer(matrix),
				this.destMercatorToSourceTransformer,
				new Affine2DPointTransformer(matrix2)
			}, this.interpolationMode);
		}
        internal override void doTransformImage(GDIBigLockedImage sourceImage, MapRectangle sourceBounds, GDIBigLockedImage destImage, MapRectangle destBounds)
        {
            MapRectangle inr     = new MapRectangle(-0.5, -0.5, (double)destImage.Height - 0.5, (double)destImage.Width - 0.5);
            MapRectangle outr    = MapRectangle.MapRectangleIgnoreOrder(MercatorCoordinateSystem.LatLonToMercator(destBounds.GetNW()), MercatorCoordinateSystem.LatLonToMercator(destBounds.GetSE()));
            JamaMatrix   matrix  = PolynomialImageTransformer.FindAffineMatrix(inr, outr);
            MapRectangle outr2   = new MapRectangle(-0.5, -0.5, (double)sourceImage.Height - 0.5, (double)sourceImage.Width - 0.5);
            JamaMatrix   matrix2 = PolynomialImageTransformer.FindAffineMatrix(sourceBounds, outr2);

            FastImageWarper.doWarp(destImage, sourceImage, new IPointTransformer[]
            {
                new Affine2DPointTransformer(matrix),
                this.destMercatorToSourceTransformer,
                new Affine2DPointTransformer(matrix2)
            }, this.interpolationMode);
        }
Example #19
0
        /// <summary>
        /// Creates the MapView JavaScript object; this must be called before any other methods.
        /// </summary>
        /// <param name="areaRectangle">area rectangle to be used for map view</param>
        /// <param name="initialZoomLevel">initial zoom level, in 2D zoom level steps</param>
        public void Create(MapRectangle areaRectangle, int initialZoomLevel)
        {
            string initialRectangle = string.Format(
                "{{latitude:{0}, longitude:{1}}}, {{latitude:{2}, longitude:{3}}}",
                areaRectangle.NorthWest.Latitude.ToString(CultureInfo.InvariantCulture),
                areaRectangle.NorthWest.Longitude.ToString(CultureInfo.InvariantCulture),
                areaRectangle.SouthEast.Latitude.ToString(CultureInfo.InvariantCulture),
                areaRectangle.SouthEast.Longitude.ToString(CultureInfo.InvariantCulture));

            string js = string.Format(
                "map = new MapView({{id: 'mapElement', initialRectangle: [{0}], initialZoomLevel: {1}}});",
                initialRectangle,
                initialZoomLevel);

            this.RunJavaScript(js);
        }
		private static JamaMatrix CornersToVectorMatrix(MapRectangle rect)
		{
			JamaMatrix jamaMatrix = new JamaMatrix(3, 4);
			jamaMatrix.SetElement(0, 0, rect.lon0);
			jamaMatrix.SetElement(0, 1, rect.lon0);
			jamaMatrix.SetElement(0, 2, rect.lon1);
			jamaMatrix.SetElement(0, 3, rect.lon1);
			jamaMatrix.SetElement(1, 0, rect.lat0);
			jamaMatrix.SetElement(1, 1, rect.lat1);
			jamaMatrix.SetElement(1, 2, rect.lat0);
			jamaMatrix.SetElement(1, 3, rect.lat1);
			jamaMatrix.SetElement(2, 0, 1.0);
			jamaMatrix.SetElement(2, 1, 1.0);
			jamaMatrix.SetElement(2, 2, 1.0);
			jamaMatrix.SetElement(2, 3, 1.0);
			return jamaMatrix;
		}
Example #21
0
        /// <summary>
        /// Initialises a new instance of the MapControl class.
        /// Sets OpenStreetMap_Original and Disc Caching as the default Map and caching providers.
        /// Sets MinZoom of the default Map Proider as the Zoom and (0,0) as the position.
        /// </summary>
        /// <param name="batch">The SpriteBatch to use for drawing.</param>
        /// <param name="device">The graphicsDevice to draw the map on.</param>
        /// <param name="bounds">The bounds rectangle on the viewport at which the map shall be drawn.</param>
        public MapControl(SpriteBatch batch, GraphicsDevice device, MapRectangle bounds)
        {
            _sBatch = batch;
            _device = device;
            _map    = new TiledMapProvider(OsmProvider.GetInstance(), new DiscTileCaching("cache"));

            _map.Zoom     = _map.Provider.MinZoom;
            _map.Position = new MapPointLatLon(0, 0);

            _map.ViewBounds = bounds;


            // Somewhere in your LoadContent() method:
            // Set the pixel texture.
            _pixel = new Texture2D(_device, 1, 1, false, SurfaceFormat.Color);
            _pixel.SetData(new[] { Color.White });
        }
Example #22
0
        public TileDisplayDescriptorArray GetTileArrayDescriptor(LatLonZoom center, Size windowSize)
        {
            TileDisplayDescriptorArray tileDisplayDescriptorArray = new TileDisplayDescriptorArray();
            MapRectangle unclippedMapWindow = this.GetUnclippedMapWindow(center, windowSize);

            tileDisplayDescriptorArray.topLeftTile = this.GetTileContainingLatLonZoom(new LatLonZoom(unclippedMapWindow.GetNW(), center.zoom));
            TileAddress tileContainingLatLonZoom = this.GetTileContainingLatLonZoom(new LatLonZoom(unclippedMapWindow.GetSE(), center.zoom));

            tileDisplayDescriptorArray.tileCountX = tileContainingLatLonZoom.TileX - tileDisplayDescriptorArray.topLeftTile.TileX + 1;
            tileDisplayDescriptorArray.tileCountY = -(tileContainingLatLonZoom.TileY - tileDisplayDescriptorArray.topLeftTile.TileY) + 1;
            Point64 point = new Point64(this.degreesToPixels(unclippedMapWindow.GetNW().lon, center.zoom), this.degreesToPixels(unclippedMapWindow.GetNW().lat, center.zoom));

            tileDisplayDescriptorArray.topLeftTileOffset = new Point((int)((long)(tileDisplayDescriptorArray.topLeftTile.TileX * 512) - point.X), (int)(point.Y - (long)((tileDisplayDescriptorArray.topLeftTile.TileY + 1) * 512)));
            tileDisplayDescriptorArray.layout            = this.addressLayout;
            tileDisplayDescriptorArray.tileSize          = this.GetTileSize();
            return(tileDisplayDescriptorArray);
        }
Example #23
0
        public LatLonZoom GetBestViewContaining(MapRectangle newBounds, Size size)
        {
            LatLon center = newBounds.GetCenter();
            int    i;

            for (i = this.ZoomRange.max; i >= this.ZoomRange.min; i--)
            {
                LatLonZoom p      = new LatLonZoom(newBounds.lat0, newBounds.lon0, i);
                LatLonZoom p2     = new LatLonZoom(newBounds.lat1, newBounds.lon1, i);
                Point64    point  = this.LatLongZoomToPixel(p);
                Point64    point2 = this.LatLongZoomToPixel(p2);
                if (point.Y - point2.Y < (long)size.Height)
                {
                    break;
                }
            }
            return(new LatLonZoom(center.lat, center.lon, i));
        }
        private static JamaMatrix CornersToVectorMatrix(MapRectangle rect)
        {
            JamaMatrix jamaMatrix = new JamaMatrix(3, 4);

            jamaMatrix.SetElement(0, 0, rect.lon0);
            jamaMatrix.SetElement(0, 1, rect.lon0);
            jamaMatrix.SetElement(0, 2, rect.lon1);
            jamaMatrix.SetElement(0, 3, rect.lon1);
            jamaMatrix.SetElement(1, 0, rect.lat0);
            jamaMatrix.SetElement(1, 1, rect.lat1);
            jamaMatrix.SetElement(1, 2, rect.lat0);
            jamaMatrix.SetElement(1, 3, rect.lat1);
            jamaMatrix.SetElement(2, 0, 1.0);
            jamaMatrix.SetElement(2, 1, 1.0);
            jamaMatrix.SetElement(2, 2, 1.0);
            jamaMatrix.SetElement(2, 3, 1.0);
            return(jamaMatrix);
        }
Example #25
0
        public SCMap AddRectangle(double[] location, double width, double height, RectangleOptions options = null)
        {
            options ??= new RectangleOptions();

            var mapItem = new MapRectangle();

            if (location == null || location.Length != 2)
            {
                throw new Exception("Location must be double array with 2 elements.");
            }

            mapItem.Location = CreateCoordPoint(location[0], location[1]);

            mapItem.Height = height;
            mapItem.Width  = width;

            options.ConfigureMapItem(this, mapItem);

            return(this);
        }
Example #26
0
        public RenderBounds MakeRenderBounds(MapRectangle imageBounds)
        {
            RenderBounds renderBounds = new RenderBounds();

            renderBounds.MinZoom       = this.ZoomRange.min;
            renderBounds.MaxZoom       = this.ZoomRange.max;
            renderBounds.TileSize      = this.GetTileSize();
            renderBounds.imageBounds   = imageBounds;
            renderBounds.tileRectangle = new TileRectangle[renderBounds.MaxZoom + 1];
            for (int i = renderBounds.MinZoom; i <= renderBounds.MaxZoom; i++)
            {
                renderBounds.tileRectangle[i]      = new TileRectangle();
                renderBounds.tileRectangle[i].zoom = i;
                LatLonZoom llz = new LatLonZoom(imageBounds.GetNW().lat, imageBounds.GetNW().lon, i);
                renderBounds.tileRectangle[i].TopLeft = this.GetTileContainingLatLonZoom(llz);
                llz = new LatLonZoom(imageBounds.GetSE().lat, imageBounds.GetSE().lon, i);
                renderBounds.tileRectangle[i].BottomRight = this.GetTileContainingLatLonZoom(llz);
                renderBounds.tileRectangle[i].StrideX     = 1;
                renderBounds.tileRectangle[i].StrideY     = 1;
            }
            return(renderBounds);
        }
Example #27
0
        /// <summary>
        /// Gets the part of the viewport a tile will be rendered to.
        /// The input is a rectangle from a viewport at (0, 0, width, height). This rectangle
        /// is transformed to a rectangle within (viewX, viewY, width, height). Rectangled at the border of the viewport are
        /// clipped.
        /// </summary>
        /// <param name="origRect">A rectangle of the viewport as described above.</param>
        /// <returns>The part of the ViewBounds where the tile will be rendered to.</returns>
        public MapRectangle GetDestRectangle(MapRectangle origRect)
        {
            MapRectangle newRect = new MapRectangle();

            if (origRect.X < 0)
            {
                newRect.X     = ViewBounds.X;
                newRect.Width = origRect.Width + origRect.X; // + - = -!
            }
            else if (origRect.X + origRect.Width >= ViewBounds.Width)
            {
                newRect.X     = ViewBounds.X + origRect.X;
                newRect.Width = ViewBounds.Width - origRect.X;
            }
            else
            {
                newRect.X     = ViewBounds.X + origRect.X;
                newRect.Width = origRect.Width;
            }

            if (origRect.Y < 0)
            {
                newRect.Y      = ViewBounds.Y;
                newRect.Height = origRect.Height + origRect.Y; // + - = -!
            }
            else if (origRect.Y + origRect.Height > ViewBounds.Height)
            {
                newRect.Y      = ViewBounds.Y + origRect.Y;
                newRect.Height = ViewBounds.Height - origRect.Y;
            }
            else
            {
                newRect.Y      = ViewBounds.Y + origRect.Y;
                newRect.Height = origRect.Height;
            }

            return(newRect);
        }
Example #28
0
        /// <summary>
        /// Returns the rectangle of a tile that will be rendered within the given rectangle.
        /// The rectangle passed is assumed in a viewport of (0, 0, Width, Height), even if the "real" viewport is at a different
        /// location. The rectangle returned will be the portion of the tile that is taken to render the specific tile.
        /// </summary>
        /// <param name="srcRect">The rectangle of the viewport as described above.</param>
        /// <returns>The rectangle describing the portion of the tile being rendered.</returns>
        public MapRectangle GetSourceRectangle(MapRectangle srcRect)
        {
            MapRectangle newRect = new MapRectangle();

            if (srcRect.X < 0)
            {
                newRect.X     = -srcRect.X;                // since offset is negative, this gets positive
                newRect.Width = srcRect.Width + srcRect.X; // + - = -!
            }
            else if (srcRect.X + srcRect.Width >= ViewBounds.Width)
            {
                newRect.X     = 0;
                newRect.Width = ViewBounds.Width - srcRect.X;
            }
            else
            {
                newRect.X     = 0;
                newRect.Width = srcRect.Width;
            }

            if (srcRect.Y < 0)
            {
                newRect.Y      = -srcRect.Y;                 // since offset is negative, this gets positive
                newRect.Height = srcRect.Height + srcRect.Y; // + - = -!
            }
            else if (srcRect.Y + srcRect.Height >= ViewBounds.Height)
            {
                newRect.Y      = 0;
                newRect.Height = ViewBounds.Height - srcRect.Y;
            }
            else
            {
                newRect.Y      = 0;
                newRect.Height = srcRect.Height;
            }

            return(newRect);
        }
Example #29
0
        /// <summary> Get the map parameters object for the current viewport. </summary>
        /// <returns> The map parameters instance. </returns>
        private MapParam GetMapParam()
        {
            MapRectangle rect     = MapView.FinalEnvelope;
            var          mapParam = new MapParam(rect.West, rect.South, rect.East, rect.North, MapView.ActualWidth, MapView.ActualHeight);

            if (mapParam.Width == 0 || mapParam.Height == 0)
            {
                return(mapParam);
            }

            // clip the rectangle to the maximum rectangle
            if (mapParam.Left < EnvMinX || mapParam.Right > EnvMaxX || mapParam.Top < EnvMinY || mapParam.Bottom > EnvMaxY)
            {
                double leftClipped   = Math.Max(EnvMinX, mapParam.Left);
                double rightClipped  = Math.Min(EnvMaxX, mapParam.Right);
                double topClipped    = Math.Max(EnvMinY, mapParam.Top);
                double bottomClipped = Math.Min(EnvMaxY, mapParam.Bottom);

                double widthClipped  = mapParam.Width * (rightClipped - leftClipped) / (mapParam.Right - mapParam.Left);
                double heightClipped = mapParam.Height * (bottomClipped - topClipped) / (mapParam.Bottom - mapParam.Top);

                mapParam = new MapParam(leftClipped, topClipped, rightClipped, bottomClipped, widthClipped, heightClipped);
            }

            // resize if > MaxSize
            if (mapParam.Width <= MaxRequestSize.Width && mapParam.Height <= MaxRequestSize.Height)
            {
                return(mapParam);
            }

            double ratio = Math.Min(MaxRequestSize.Height / mapParam.Height, MaxRequestSize.Width / mapParam.Width);

            mapParam.Width  *= ratio;
            mapParam.Height *= ratio;

            return(mapParam);
        }
		internal Present Render(MapRectangle mapRect, Size size, bool useDocumentTransparency, bool exactColors)
		{
			RectangleF rectangleF = new RectangleF((float)mapRect.lon0, (float)mapRect.lat0, (float)(mapRect.lon1 - mapRect.lon0), (float)(mapRect.lat1 - mapRect.lat0));
			double num = (double)this.actualBoundingBox.Width / (double)this.boundingBox.Width;
			double num2 = (double)this.actualBoundingBox.Height / (double)this.boundingBox.Height;
			Size pagesize = new Size((int)Math.Round((double)size.Width / (double)rectangleF.Width * num), (int)Math.Round((double)size.Height / (double)rectangleF.Height * num2));
			Point topleft = new Point((int)Math.Round((double)(-(double)pagesize.Width) / num * mapRect.lon0), (int)Math.Round((double)(-(double)pagesize.Height) / num2 * (num2 - mapRect.lat1)));
			if (pagesize.Width > 262144 || pagesize.Width <= 0 || pagesize.Height > 262144 || pagesize.Height <= 0)
			{
				return new PresentFailureCode("Zoomed beyond FoxIt limits");
			}
			IFoxitViewer obj;
			Monitor.Enter(obj = this.foxitViewer);
			GDIBigLockedImage image;
			try
			{
				image = this.foxitViewer.Render(size, topleft, pagesize, useDocumentTransparency);
			}
			finally
			{
				Monitor.Exit(obj);
			}
			return new ImageRef(new ImageRefCounted(image));
		}
Example #31
0
        public List <TileDrawInfo> GetDrawTiles()
        {
            List <TileDrawInfo> info = new List <TileDrawInfo>();

            // 1. Get center point MapCoordinates
            MapVector centerMapVector = LatLonToMapPoint(Position);

            // 2. Calculate offset from center point to topleft point in map coordinates
            int topLeftXOffset = (int)((ViewBounds.Width / 2.0) / CoordinateScale);
            int topLeftYOffset = (int)((ViewBounds.Height / 2.0) / CoordinateScale);

            // 3. Calculate the top left point in map coordinates
            MapVector topLeftMapVector = new MapVector()
            {
                // real a mod b:
                // a mod b = (a % b + b) % b
                // https://de.wikipedia.org/wiki/Division_mit_Rest#Modulo

                X = (((centerMapVector.X - topLeftXOffset) % MapCoordinatesWidth) + MapCoordinatesWidth) % MapCoordinatesWidth,
                Y = (((centerMapVector.Y - topLeftYOffset) % MapCoordinatesHeight) + MapCoordinatesHeight) % MapCoordinatesHeight
            };

            // 4. Calculate Tile X/Y directly from Map Coordiantes
            MapVector tileCoord = new MapVector()
            {
                X = (int)Math.Floor(topLeftMapVector.X / (Provider.TileSize / CoordinateScale)),
                Y = (int)Math.Floor(topLeftMapVector.Y / (Provider.TileSize / CoordinateScale))
            };

            // 5. Calculate the Top-Left point of the top-left tile
            //PointXY tileMapVector = LatLonToMapPoint(Provider.GetPointForTile(Zoom, tileCoord));

            MapVector tileMapVector = new MapVector()
            {
                X = (int)(tileCoord.X * (Provider.TileSize / CoordinateScale)),
                Y = (int)(tileCoord.Y * (Provider.TileSize / CoordinateScale))
            };

            // 6. Get the offset of the top-left-point of the top-left-tile to the top-left point of the map
            // So we know if it is outside of the viewable port.
            MapVector offset = (tileMapVector - topLeftMapVector) * CoordinateScale;

            // 7. Create a rectangle for the top-left tile
            MapRectangle imgRect = new MapRectangle(offset.X, offset.Y, Provider.TileSize, Provider.TileSize);

            // 8. The top-left tile
            TileDescriptor descriptor = new TileDescriptor(Zoom, tileCoord);

            // 9. Now iterate over all viewable tiles and add them to the list
            // Handling the source and destination rectangles is done by special functions.

            int currentTileY = descriptor.Tile.Y;
            int currentTileX = descriptor.Tile.X;
            int currentRectY = imgRect.Y;
            int currentRectX = imgRect.X;

            int tileCount = Provider.GetTileCount(Zoom);

            while (currentRectX < ViewBounds.Width)
            {
                while (currentRectY < ViewBounds.Height)
                {
                    TileDescriptor desc = new TileDescriptor(descriptor.Zoom, currentTileX, currentTileY);

                    // 10. Create rectangle of the "full" tile, might lap over the borders of the viewport, i.e.
                    // having negative offsets here.
                    MapRectangle cRect = new MapRectangle(currentRectX, currentRectY, Provider.TileSize, Provider.TileSize);

                    // 11. Get the part of the tile that is being rendered.
                    MapRectangle tileSrcRect = GetSourceRectangle(cRect);

                    // 12. Get the position and the size in the viewport where the tile will be rendered.
                    MapRectangle viewDstRect = GetDestRectangle(cRect);

                    TileDrawInfo i = new TileDrawInfo();
                    i.Tile                 = new TileDescriptor(Zoom, currentTileX, currentTileY);
                    i.SourceRectangle      = tileSrcRect;
                    i.DestinationRectangle = viewDstRect;

                    info.Add(i);

                    currentRectY += Provider.TileSize;
                    currentTileY  = (currentTileY + 1) % tileCount;
                }

                currentRectY = imgRect.Y;
                currentTileY = descriptor.Tile.Y;

                currentTileX  = (currentTileX + 1) % tileCount;
                currentRectX += Provider.TileSize;
            }

            return(info);
        }
Example #32
0
		internal abstract void doTransformImage(GDIBigLockedImage sourceImage, MapRectangle sourceBounds, GDIBigLockedImage destImage, MapRectangle destBounds);
		internal override void doTransformImage(GDIBigLockedImage sourceImage, MapRectangle sourceBounds, GDIBigLockedImage destImage, MapRectangle destBounds)
		{
		}
		internal Present Render(MapRectangle mapRect, System.Drawing.Size size, bool useDocumentTransparency, bool exactColors)
		{
			Monitor.Enter(this);
			Present result;
			try
			{
				RectangleD rectangleD = new RectangleD(mapRect.lon0 * (double)this.boundingBox.Width - 0.5, -mapRect.lat1 * (double)this.boundingBox.Height + (double)this.actualBoundingBox.Height - 0.5, (mapRect.lon1 - mapRect.lon0) * (double)this.boundingBox.Width + (double)this.hackRectangleAdjust, (mapRect.lat1 - mapRect.lat0) * (double)this.boundingBox.Height + (double)this.hackRectangleAdjust);
				RectangleD rectangleD2 = rectangleD.Grow(2.0);
				RectangleD r = new RectangleD((double)this.actualBoundingBox.X, (double)this.actualBoundingBox.Y, (double)this.actualBoundingBox.Width, (double)this.actualBoundingBox.Height);
				RectangleD dest = new RectangleD(0.0, 0.0, (double)size.Width, (double)size.Height);
				ScaleAndTranslate scaleAndTranslate = new ScaleAndTranslate(rectangleD, dest);
				RectangleD rectangleD3 = rectangleD2.Intersect(r).Round();
				RectangleD rectangleD4 = scaleAndTranslate.Apply(rectangleD.Intersect(r));
				RectangleD rectangleD5 = scaleAndTranslate.Apply(rectangleD3);
				ScaleAndTranslate scaleAndTranslate2 = new ScaleAndTranslate(-rectangleD5.X, -rectangleD5.Y);
				RectangleD rectangleD6 = scaleAndTranslate2.Apply(rectangleD4);
				GDIBigLockedImage gDIBigLockedImage = new GDIBigLockedImage(size, "WPFVerb");
				GDIBigLockedImage image = gDIBigLockedImage;
				if (!rectangleD3.IntIsEmpty() && !rectangleD6.IntIsEmpty())
				{
					try
					{
						GDIBigLockedImage obj;
						Monitor.Enter(obj = gDIBigLockedImage);
						try
						{
							Bitmap bitmap = (Bitmap)gDIBigLockedImage.IPromiseIAmHoldingGDISLockSoPleaseGiveMeTheImage();
							BitmapSource source = new CroppedBitmap(this.primarySource, rectangleD3.ToInt32Rect());
							BitmapSource source2 = new TransformedBitmap(source, scaleAndTranslate.ToScaleTransform());
							BitmapSource bitmapSource = new CroppedBitmap(source2, rectangleD6.ToInt32Rect());
							Int32Rect int32Rect = rectangleD4.ToInt32Rect();
							BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, size.Width, size.Height), ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
							try
							{
								IntPtr buffer = new IntPtr(bitmapData.Scan0.ToInt32() + int32Rect.Y * bitmapData.Stride + int32Rect.X * 4);
								bitmapSource.CopyPixels(new Int32Rect(0, 0, bitmapSource.PixelWidth, bitmapSource.PixelHeight), buffer, bitmapData.Stride * bitmapData.Height, bitmapData.Stride);
							}
							finally
							{
								bitmap.UnlockBits(bitmapData);
							}
						}
						finally
						{
							Monitor.Exit(obj);
						}
					}
					catch (Exception ex)
					{
						if (BigDebugKnob.theKnob.debugFeaturesEnabled)
						{
							this.LabelThisImage(gDIBigLockedImage, ex.ToString());
						}
					}
					if (useDocumentTransparency)
					{
						image = gDIBigLockedImage;
					}
					else
					{
						GDIBigLockedImage gDIBigLockedImage2 = new GDIBigLockedImage(size, "WPFVerb-untransparent");
						GDIBigLockedImage obj2;
						Monitor.Enter(obj2 = gDIBigLockedImage2);
						try
						{
							Graphics graphics = gDIBigLockedImage2.IPromiseIAmHoldingGDISLockSoPleaseGiveMeTheGraphics();
							graphics.FillRectangle(new SolidBrush(System.Drawing.Color.White), 0, 0, size.Width, size.Height);
							graphics.DrawImage(gDIBigLockedImage.IPromiseIAmHoldingGDISLockSoPleaseGiveMeTheImage(), 0, 0);
							graphics.Dispose();
							image = gDIBigLockedImage2;
							gDIBigLockedImage.Dispose();
						}
						finally
						{
							Monitor.Exit(obj2);
						}
					}
				}
				result = new ImageRef(new ImageRefCounted(image));
			}
			finally
			{
				Monitor.Exit(this);
			}
			return result;
		}
		public LatLonZoom GetBestViewContaining(MapRectangle newBounds, Size size)
		{
			LatLon center = newBounds.GetCenter();
			int zoom = (int)(this.exactZoom((double)size.Height / (newBounds.lat1 - newBounds.lat0)) + 0.99);
			return new LatLonZoom(center.lat, center.lon, zoom);
		}
 internal override void doTransformImage(GDIBigLockedImage sourceImage, MapRectangle sourceBounds, GDIBigLockedImage destImage, MapRectangle destBounds)
 {
 }
		private static JamaMatrix FindAffineMatrix(MapRectangle inr, MapRectangle outr)
		{
			JamaMatrix gm = PolynomialImageTransformer.CornersToVectorMatrix(inr);
			return PolynomialImageTransformer.CornersToVectorMatrix(outr).times(PolynomialImageTransformer.PseudoInverseBySVD(gm));
		}
Example #38
0
        internal Present Render(MapRectangle mapRect, System.Drawing.Size size, bool useDocumentTransparency,
                                bool exactColors)
        {
            Monitor.Enter(this);
            Present result;

            try
            {
                RectangleD rectangleD = new RectangleD(mapRect.lon0 * boundingBox.Width - 0.5,
                                                       -mapRect.lat1 * boundingBox.Height + actualBoundingBox.Height - 0.5,
                                                       (mapRect.lon1 - mapRect.lon0) * boundingBox.Width + hackRectangleAdjust,
                                                       (mapRect.lat1 - mapRect.lat0) * boundingBox.Height + hackRectangleAdjust);
                RectangleD rectangleD2 = rectangleD.Grow(2.0);
                RectangleD r           = new RectangleD(actualBoundingBox.X,
                                                        actualBoundingBox.Y,
                                                        actualBoundingBox.Width,
                                                        actualBoundingBox.Height);
                RectangleD        dest = new RectangleD(0.0, 0.0, size.Width, size.Height);
                ScaleAndTranslate scaleAndTranslate  = new ScaleAndTranslate(rectangleD, dest);
                RectangleD        rectangleD3        = rectangleD2.Intersect(r).Round();
                RectangleD        rectangleD4        = scaleAndTranslate.Apply(rectangleD.Intersect(r));
                RectangleD        rectangleD5        = scaleAndTranslate.Apply(rectangleD3);
                ScaleAndTranslate scaleAndTranslate2 = new ScaleAndTranslate(-rectangleD5.X, -rectangleD5.Y);
                RectangleD        rectangleD6        = scaleAndTranslate2.Apply(rectangleD4);
                GDIBigLockedImage gDIBigLockedImage  = new GDIBigLockedImage(size, "WPFVerb");
                GDIBigLockedImage image = gDIBigLockedImage;
                if (!rectangleD3.IntIsEmpty() && !rectangleD6.IntIsEmpty())
                {
                    try
                    {
                        GDIBigLockedImage obj;
                        Monitor.Enter(obj = gDIBigLockedImage);
                        try
                        {
                            Bitmap bitmap =
                                (Bitmap)gDIBigLockedImage.IPromiseIAmHoldingGDISLockSoPleaseGiveMeTheImage();
                            BitmapSource source       = new CroppedBitmap(primarySource, rectangleD3.ToInt32Rect());
                            BitmapSource source2      = new TransformedBitmap(source, scaleAndTranslate.ToScaleTransform());
                            BitmapSource bitmapSource = new CroppedBitmap(source2, rectangleD6.ToInt32Rect());
                            Int32Rect    int32Rect    = rectangleD4.ToInt32Rect();
                            BitmapData   bitmapData   = bitmap.LockBits(new Rectangle(0, 0, size.Width, size.Height),
                                                                        ImageLockMode.WriteOnly,
                                                                        System.Drawing.Imaging.PixelFormat.Format32bppArgb);
                            try
                            {
                                IntPtr buffer = new IntPtr(bitmapData.Scan0.ToInt32() +
                                                           int32Rect.Y * bitmapData.Stride + int32Rect.X * 4);
                                bitmapSource.CopyPixels(
                                    new Int32Rect(0, 0, bitmapSource.PixelWidth, bitmapSource.PixelHeight),
                                    buffer,
                                    bitmapData.Stride * bitmapData.Height,
                                    bitmapData.Stride);
                            }
                            finally
                            {
                                bitmap.UnlockBits(bitmapData);
                            }
                        }
                        finally
                        {
                            Monitor.Exit(obj);
                        }
                    }
                    catch (Exception ex)
                    {
                        if (BigDebugKnob.theKnob.debugFeaturesEnabled)
                        {
                            LabelThisImage(gDIBigLockedImage, ex.ToString());
                        }
                    }

                    if (useDocumentTransparency)
                    {
                        image = gDIBigLockedImage;
                    }
                    else
                    {
                        GDIBigLockedImage gDIBigLockedImage2 = new GDIBigLockedImage(size, "WPFVerb-untransparent");
                        GDIBigLockedImage obj2;
                        Monitor.Enter(obj2 = gDIBigLockedImage2);
                        try
                        {
                            Graphics graphics =
                                gDIBigLockedImage2.IPromiseIAmHoldingGDISLockSoPleaseGiveMeTheGraphics();
                            graphics.FillRectangle(new SolidBrush(System.Drawing.Color.White),
                                                   0,
                                                   0,
                                                   size.Width,
                                                   size.Height);
                            graphics.DrawImage(gDIBigLockedImage.IPromiseIAmHoldingGDISLockSoPleaseGiveMeTheImage(),
                                               0,
                                               0);
                            graphics.Dispose();
                            image = gDIBigLockedImage2;
                            gDIBigLockedImage.Dispose();
                        }
                        finally
                        {
                            Monitor.Exit(obj2);
                        }
                    }
                }

                result = new ImageRef(new ImageRefCounted(image));
            }
            finally
            {
                Monitor.Exit(this);
            }

            return(result);
        }
		public LatLonZoom GetBestViewContaining(MapRectangle newBounds, Size size)
		{
			LatLon center = newBounds.GetCenter();
			int i;
			for (i = this.ZoomRange.max; i >= this.ZoomRange.min; i--)
			{
				LatLonZoom p = new LatLonZoom(newBounds.lat0, newBounds.lon0, i);
				LatLonZoom p2 = new LatLonZoom(newBounds.lat1, newBounds.lon1, i);
				Point64 point = this.LatLongZoomToPixel(p);
				Point64 point2 = this.LatLongZoomToPixel(p2);
				if (point.Y - point2.Y < (long)size.Height)
				{
					break;
				}
			}
			return new LatLonZoom(center.lat, center.lon, i);
		}
        private static JamaMatrix FindAffineMatrix(MapRectangle inr, MapRectangle outr)
        {
            JamaMatrix gm = PolynomialImageTransformer.CornersToVectorMatrix(inr);

            return(PolynomialImageTransformer.CornersToVectorMatrix(outr).times(PolynomialImageTransformer.PseudoInverseBySVD(gm)));
        }
Example #41
0
 internal abstract void doTransformImage(GDIBigLockedImage sourceImage, MapRectangle sourceBounds,
                                         GDIBigLockedImage destImage, MapRectangle destBounds);
		public RenderBounds MakeRenderBounds(MapRectangle imageBounds)
		{
			RenderBounds renderBounds = new RenderBounds();
			renderBounds.MinZoom = this.ZoomRange.min;
			renderBounds.MaxZoom = this.ZoomRange.max;
			renderBounds.TileSize = this.GetTileSize();
			renderBounds.imageBounds = imageBounds;
			renderBounds.tileRectangle = new TileRectangle[renderBounds.MaxZoom + 1];
			for (int i = renderBounds.MinZoom; i <= renderBounds.MaxZoom; i++)
			{
				renderBounds.tileRectangle[i] = new TileRectangle();
				renderBounds.tileRectangle[i].zoom = i;
				LatLonZoom llz = new LatLonZoom(imageBounds.GetNW().lat, imageBounds.GetNW().lon, i);
				renderBounds.tileRectangle[i].TopLeft = this.GetTileContainingLatLonZoom(llz);
				llz = new LatLonZoom(imageBounds.GetSE().lat, imageBounds.GetSE().lon, i);
				renderBounds.tileRectangle[i].BottomRight = this.GetTileContainingLatLonZoom(llz);
				renderBounds.tileRectangle[i].StrideX = 1;
				renderBounds.tileRectangle[i].StrideY = 1;
			}
			return renderBounds;
		}