Esempio n. 1
0
        public RCRange getRCRangeFromMercator(int level, int row1, int col1)
        {
            int PIC_SIZE           = 256;
            BdCoodOffsetProvider p = BdCoodOffsetProvider.getInstance();

            System.Drawing.Point new_leftTop, new_leftBottom, new_rightTop, new_rightBottom;

            //calc pixel offset of left bottom point in the tile
            new_leftTop = getNewPixelOffsetOfLeftTop(level, row1, col1);

            new_rightBottom   = getNewPixelOffsetOfLeftTop(level, row1 + 1, col1 + 1);
            new_rightBottom.X = new_rightBottom.X - 1;
            new_rightBottom.Y = new_rightBottom.Y + 1;

            new_leftBottom   = getNewPixelOffsetOfLeftTop(level, row1 + 1, col1);
            new_leftBottom.X = new_leftBottom.X;
            new_leftBottom.Y = new_leftBottom.Y + 1;

            new_rightTop   = getNewPixelOffsetOfLeftTop(level, row1, col1 + 1);
            new_rightTop.X = new_rightTop.X - 1;
            new_rightTop.Y = new_rightTop.Y;

            int maxY = new_leftTop.Y > new_rightTop.Y ? new_leftTop.Y + 5 : new_rightTop.Y + 5;
            int minY = new_rightBottom.Y < new_leftBottom.Y ? new_rightBottom.Y - 5 : new_leftBottom.Y - 5;
            int maxX = new_rightBottom.X > new_rightTop.X ? new_rightBottom.X + 5 : new_rightTop.X + 5;
            int minX = new_leftTop.X < new_leftBottom.X ? new_leftTop.X - 5 : new_leftBottom.X - 5;

            return(new RCRange()
            {
                MaxCol = maxX / PIC_SIZE, MaxRow = maxY / PIC_SIZE, MinCol = minX / PIC_SIZE, MinRow = minY / PIC_SIZE
            });
        }
Esempio n. 2
0
 public static BdCoodOffsetProvider getInstance()
 {
     if (inst == null)
     {
         inst = new BdCoodOffsetProvider();
     }
     return(inst);
 }
Esempio n. 3
0
        public System.Drawing.Point getNewPixelOffsetOfLeftTop(int level, int row1, int col1)
        {
            BdCoodOffsetProvider p = BdCoodOffsetProvider.getInstance();

            System.Drawing.Point org_leftBottom = getMetersFromRowCol(row1, col1, level);
            LatLng lpt        = MetersToLatLon(org_leftBottom);
            LatLng testPoint  = p.doAdjust(lpt, level);
            LatLng meters     = BdCoodOffsetProvider.BaiduGPS2BaiduMercator(new LatLng(testPoint.latitude, testPoint.longitude));
            double resolution = GetResolutionForLevel(level);

            System.Drawing.Point new_leftBottom = new System.Drawing.Point((int)(meters.longitude / resolution), (int)(meters.latitude / resolution));
            return(new_leftBottom);
        }
Esempio n. 4
0
        public RCRange getBaiduRCRangeFromGPS(Envelope area, int level)
        {
            int    PIC_SIZE        = 256;
            double resolution      = GetResolutionForLevel(level);
            BdCoodOffsetProvider p = BdCoodOffsetProvider.getInstance();
            LatLng leftTopLpt      = new LatLng(area.YMax, area.XMin);
            LatLng testPoint       = p.doAdjust(leftTopLpt, level);
            LatLng meters          = BdCoodOffsetProvider.BaiduGPS2BaiduMercator(new LatLng(testPoint.latitude, testPoint.longitude));

            System.Drawing.Point new_leftTop = new System.Drawing.Point((int)(meters.longitude / resolution), (int)(meters.latitude / resolution));

            LatLng rightBottomLpt = new LatLng(area.YMin, area.XMax);

            testPoint = p.doAdjust(rightBottomLpt, level);
            meters    = BdCoodOffsetProvider.BaiduGPS2BaiduMercator(new LatLng(testPoint.latitude, testPoint.longitude));
            System.Drawing.Point new_rightBottom = new System.Drawing.Point((int)(meters.longitude / resolution), (int)(meters.latitude / resolution));

            return(new RCRange()
            {
                MaxCol = (new_rightBottom.X + 5) / PIC_SIZE, MaxRow = (new_leftTop.Y + 5) / PIC_SIZE, MinCol = (new_leftTop.X - 5) / PIC_SIZE, MinRow = (new_rightBottom.Y - 5) / PIC_SIZE
            });
        }
Esempio n. 5
0
 private BdCoodOffsetProvider()
 {
     baiduSchema = BaiDuMapManager.inst.getBaiDuSchema();
     inst        = this;
 }