Пример #1
0
        public override Point toPixelLocationPrint(GeoCoord loc, ITile tile)
        {
            int xx = 0;
            int yy = 0;

            if(tile != null)
            {
                // the idea here is to simplify conversion for tiles around 180, when camera operates
                // on coordinates above 180 and below -180

                int offsetX = 0;
                int offsetY = 0;
                Point offset;

                if(!(offset=tile.getOffset()).IsEmpty)
                {
                    offsetX = offset.X;
                    offsetY = offset.Y;
                }

                GeoCoord tileTopLeft = tile.getTopLeft();
                GeoCoord tileTopLeftN = tileTopLeft.Clone();
                tileTopLeftN.Normalize();
                GeoCoord locN = loc.Clone();
                locN.Normalize();
                double dOffsetLng = locN.Lng - tileTopLeftN.Lng;
                double dOffsetLat = locN.Lat - tileTopLeftN.Lat;

                xx = (int)Math.Round((tileTopLeft.Lng + dOffsetLng - m_coverageTopLeftPrint.Lng) / xScalePrint) + offsetX;
                yy = (int)Math.Round((tileTopLeft.Lat + dOffsetLat - m_coverageTopLeftPrint.Lat) / yScalePrint) + offsetY;
            }
            else
            {
                // express location longitude and latitude in terms of camera coordinates:
                double dOffsetLng = loc.Lng - m_location.Lng;
                while(dOffsetLng >= 180.0d)
                {
                    dOffsetLng -= 360.0d;
                }
                while(dOffsetLng <= -180.0d)
                {
                    dOffsetLng += 360.0d;
                }

                if(TileSetTerra.This.hasRenderedTiles && TileSetTerra.This.insideCurrentZone(loc))
                {
                    Point screenPt = TileSetTerra.This.toScreenPoint(loc, true);
                    screenPt.Offset(m_pictureManager.OffsetXPrint, m_pictureManager.OffsetYPrint);
                    return screenPt;
                }
                else
                {
                    xx = (int)Math.Round(dOffsetLng / xScalePrint + pictureWidthPrint / 2.0d);
                    yy = (int)Math.Round((loc.Lat - m_location.Lat) / yScalePrint + pictureHeightPrint / 2.0d);
                }
            }
            //LibSys.StatusBar.Trace("toPixelLocation(" + loc + ")  x=" + xx + " y=" + yy);

            Point ret =  new Point(xx, yy);
            ret.Offset(m_pictureManager.OffsetXPrint, m_pictureManager.OffsetYPrint);
            return ret;
        }
Пример #2
0
        public override Point toPixelLocation(GeoCoord loc, ITile tile)
        {
            int xx = 0;
            int yy = 0;

            if(tile != null)
            {
                // the idea here is to simplify conversion for tiles around 180, when camera operates
                // on coordinates above 180 and below -180

                int offsetX = 0;
                int offsetY = 0;
                Point offset;

                if(!(offset=tile.getOffset()).IsEmpty)
                {
                    offsetX = offset.X;
                    offsetY = offset.Y;
                }

                GeoCoord tileTopLeft = tile.getTopLeft();
                GeoCoord tileTopLeftN = tileTopLeft.Clone();
                tileTopLeftN.Normalize();
                GeoCoord locN = loc.Clone();
                locN.Normalize();
                double dOffsetLng = locN.Lng - tileTopLeftN.Lng;
                double dOffsetLat = locN.Lat - tileTopLeftN.Lat;

                xx = (int)Math.Round((tileTopLeft.Lng + dOffsetLng - m_coverageTopLeft.Lng) / xScale) + offsetX;
                yy = (int)Math.Round((tileTopLeft.Lat + dOffsetLat - m_coverageTopLeft.Lat) / yScale) + offsetY;

                return new Point(xx, yy);
            }
            else
            {
                // express location longitude and latitude in terms of camera coordinates:
                double dOffsetLng = loc.Lng - m_location.Lng;
                while(dOffsetLng >= 180.0d)
                {
                    dOffsetLng -= 360.0d;
                }
                while(dOffsetLng <= -180.0d)
                {
                    dOffsetLng += 360.0d;
                }

                double dOffsetLat = loc.Lat - m_location.Lat;

                if(TileSetTerra.This.hasRenderedTiles && !TileSetTerra.This.RetilingSpecial && TileSetTerra.This.insideCurrentZone(loc) && insideScreenRectangle(loc))
                {
                    Point screenPt = TileSetTerra.This.toScreenPoint(loc, false);
                    return screenPt;
                }
                else
                {
                    xx = (int)Math.Round(dOffsetLng / xScale + pictureWidth / 2.0d);
                    yy = (int)Math.Round((loc.Lat - m_location.Lat) / yScale + pictureHeight / 2.0d);
                    return new Point(xx, yy);
                }
            }
        }