Exemple #1
0
 void Update()
 {
     if (UIControl.CreatTerrain)
     {
         if (latlongLT.lati < latlongRB.lati || latlongLT.longti > latlongRB.longti)
         {
             Debug.Log("非法输入");//illegal input
             UIControl.CreatTerrain = false;
         }
         else
         {
             int zoom = 19;
             for (zoom = 19; zoom >= 12; --zoom)
             {
                 Mappixel LT = HarvenSin.latlongToPixel(latlongLT, zoom);
                 Mappixel RB = HarvenSin.latlongToPixel(latlongRB, zoom);
                 double   x  = RB.y - LT.y;
                 double   y  = RB.x - LT.x;
                 if (x <= 8192 && y <= 8192)
                 {
                     StartCoroutine(CreateTerrainZoom(zoom));
                     UIControl.CreatTerrain = false;
                     break;
                 }
             }
             Debug.Log(zoom);
             if (zoom == 11)
             {
                 Debug.Log("选择区域过大");//oversize
             }
         }
     }
 }
Exemple #2
0
        public static IEnumerator GetImageFormUrl(Latlong latlong, int tilex, int tiley, double zoom)
        {
            Mappixel startMapP = HarvenSin.latlongToPixel(latlong, zoom);

            startMapP.x += 256;
            startMapP.y += 256;
            Texture2D Img = new Texture2D(tilex * 512, tiley * 512);

            WWW[] www = new WWW[16 * 16];
            for (int i = 0; i < tilex; ++i)
            {
                for (int j = 0; j < tiley; ++j)
                {
                    Mappixel mpTmp = new Mappixel(startMapP.x + 512 * i, startMapP.y + 512 * j);
                    Latlong  ll    = HarvenSin.pixelToLatlong(mpTmp, zoom);
                    string   url   = "http://dev.virtualearth.net/REST/v1/Imagery/Map/Aerial/" + ll.lati + "," + ll.longti + "/" + zoom + "?&mapSize=512,544&key=" + bingKey;
                    //string url = "http://dev.virtualearth.net/REST/v1/Imagery/Map/Road/47.619048,-122.35384/15?mapSize=500,500&pp=47.620495,-122.34931;21;AA&pp=47.619385,-122.351485;;AB&pp=47.616295,-122.3556;22&key=BingMapsKey"+bingKey;
                    //Debug.Log(url);
                    www[i * 16 + j] = new WWW(url);
                }
                for (int j = 0; j < 16; j++)
                {
                    yield return(www[i * 16 + j]);

                    Color[] color = www[i * 16 + j].texture.GetPixels(0, 16, 512, 512);
                    Img.SetPixels(i * 512, 512 * (tiley - 1 - j), 512, 512, color);
                    www[i * 16 + j].Dispose();
                    Debug.Log(i + " " + j);
                }
            }
            Img.Apply();
            imageCombined = Img;
        }