public string GetSafeString(GPoint pos)
      {
         #region -- source --
         /*
         TileLayer.prototype.differenceEngine=function(s,a)
         {
             var offset=0,result="",alen=a.length,v,p;
             for(var i=0; i<alen; i++)
             {
                 v=parseInt(a.charAt(i),10);
                 if(!isNaN(v))
                 {
                     offset+=v;
                     p=s.charAt(offset%s.length);
                     result+=p
                 }             
             }
             return result
         };    
       
         TileLayer.prototype.getSafeString=function(x,y,nmd)
         {
              var arg=x.toString()+y.toString()+((3*x)+y).toString();
              if(nmd)
              {
                 arg+=nmd
              }
              return this.differenceEngine(TileLayer._substring,arg)
         };  
        */
         #endregion

         var arg = pos.X.ToString() + pos.Y.ToString() + ((3 * pos.X) + pos.Y).ToString();

         string ret = "&s=";
         int offset = 0;
         for(int i = 0; i < arg.Length; i++)
         {
            offset += int.Parse(arg[i].ToString());
            ret += SecureStr[offset % SecureStr.Length];
         }

         return ret;
      }
        string MakeTileImageUrl(GPoint pos, int zoom, string language)
        {
            // http://vec01.maps.yandex.ru/tiles?l=map&v=2.10.2&x=1494&y=650&z=11
             // http://vec03.maps.yandex.net/tiles?l=skl&v=2.26.0&x=4663&y=2610&z=13&lang=ru-RU

             return string.Format(UrlFormat, UrlServer, GetServerNum(pos, 4) + 1, Version, pos.X, pos.Y, zoom);
        }
        string MakeTileImageUrl(GPoint pos, int zoom, string language)
        {
            // http://web1.nearmap.com/maps/hl=en&x=18681&y=10415&z=15&nml=Map_&nmg=1&s=kY8lZssipLIJ7c5
             // http://web1.nearmap.com/kh/v=nm&hl=en&x=20&y=8&z=5&nml=Map_&s=55KUZ

             return string.Format(UrlFormat, GetServerNum(pos, 3), pos.X, pos.Y, zoom, GetSafeString(pos));
        }
      string MakeTileImageUrl(GPoint pos, int zoom, string language)
      {
         // http://web1.nearmap.com/maps/hl=en&x=37&y=19&z=6&nml=MapT&nmg=1&s=2KbhmZZ             
         // http://web1.nearmap.com/maps/hl=en&x=36&y=19&z=6&nml=MapT&nmg=1&s=2YKWhQi

         return string.Format(UrlFormat, GetServerNum(pos, 3), pos.X, pos.Y, zoom);
      }
Beispiel #5
0
 string MakeTileImageUrl(GPoint pos, int zoom, string language)
 {
     //http://webrd04.is.autonavi.com/appmaptile?x=5&y=2&z=3&lang=zh_cn&size=1&scale=1&style=7
     string url = string.Format(UrlFormat, pos.X, pos.Y, zoom);
     Console.WriteLine("url:" + url);
     return url;
 }
Beispiel #6
0
        string MakeTileImageUrl(GPoint pos, int zoom, string language)
        {
            //       http://www.maps.lt/cache/ikartelv/map/_alllayers/L03/R00000037/C00000053.png
             // http://www.maps.lt/arcgiscache/ikartelv/map/_alllayers/L02/R0000001c/C0000002a.png

             return string.Format(UrlFormat, zoom, pos.Y, pos.X);
        }
        string MakeTileImageUrl(GPoint pos, int zoom, string language)
        {
            //http://arcgis.maps.lt/ArcGIS/rest/services/mapslt_ortofoto_overlay/MapServer/tile/0/9/13
             //return string.Format("http://arcgis.maps.lt/ArcGIS/rest/services/mapslt_ortofoto_overlay/MapServer/tile/{0}/{1}/{2}", zoom, pos.Y, pos.X);
             //http://dc1.maps.lt/cache/mapslt_ortofoto_overlay_512/map/_alllayers/L03/R0000001d/C00000029.png

             return string.Format(UrlFormat, zoom, pos.Y, pos.X);
        }
Beispiel #8
0
 public CacheItemQueue(MapType Type, GPoint Pos, int Zoom, MemoryStream Img, CacheUsage cacheType)
 {
     this.Type = Type;
      this.Pos = Pos;
      this.Zoom = Zoom;
      this.Img = Img;
      this.CacheType = cacheType;
 }
        string MakeTileImageUrl(GPoint pos, int zoom, string language)
        {
            // http://web2.nearmap.com/maps/hl=en&x=14&y=8&z=5&nml=Vert&s=kdj00
             // http://web2.nearmap.com/maps/hl=en&x=6&y=4&z=4&nml=Vert
             // http://web2.nearmap.com/maps/hl=en&x=3&y=1&z=3&nml=Vert&s=2edd

             return string.Format(UrlFormat, GetServerNum(pos, 4), pos.X, pos.Y, zoom, GetSafeString(pos));
        }
Beispiel #10
0
 public Tile(int zoom, GPoint pos)
 {
     this.NotEmpty = true;
      this.zoom = zoom;
      this.pos = pos;
      this.overlays = null;
      this.OverlaysCount = 0;
 }
        string MakeTileImageUrl(GPoint pos, int zoom, string language)
        {
            // http://sat04.maps.yandex.ru/tiles?l=sat&v=1.18.0&x=149511&y=83513&z=18&g=Gagari
             // http://sat01.maps.yandex.net/tiles?l=sat&v=1.23.0&x=584&y=324&z=10&g=Gaga
             // http://sat03.maps.yandex.net/tiles?l=sat&v=1.33.0&x=583&y=328&z=10&lang=ru-RU

             return string.Format(UrlFormat, UrlServer, GetServerNum(pos, 4) + 1, Version, pos.X, pos.Y, zoom);
        }
Beispiel #12
0
        string MakeTileImageUrl(GPoint pos, int zoom, string language)
        {
            // http://vec01.maps.yandex.ru/tiles?l=map&v=2.10.2&x=1494&y=650&z=11
             // http://vec03.maps.yandex.net/tiles?l=map&v=2.19.5&x=579&y=326&z=10&g=Gagarin
             // http://vec02.maps.yandex.net/tiles?l=map&v=2.26.0&x=586&y=327&z=10&lang=ru-RU

             return string.Format(UrlFormat, UrlServer, GetServerNum(pos, 4) + 1, Version, pos.X, pos.Y, zoom);
        }
       string MakeTileImageUrl(GPoint pos, int zoom, string language)
       {
           string sec1 = string.Empty; // after &x=...
           string sec2 = string.Empty; // after &zoom=...
           GetSecureWords(pos, out sec1, out sec2);

           return string.Format(UrlFormat, UrlFormatServer, GetServerNum(pos, 4), UrlFormatRequest, Version, language, pos.X, sec1, pos.Y, zoom, sec2, Server);
       }
      string MakeTileImageUrl(GPoint pos, int zoom, string language)
      {
         // http://m4.mapserver.mapy.cz/army2/9_7d00000_8080000

         long xx = pos.X << (28 - zoom);
         long yy = ((((long)Math.Pow(2.0, (double)zoom)) - 1) - pos.Y) << (28 - zoom);

         return string.Format(UrlFormat, GetServerNum(pos, 3) + 1, zoom, xx, yy);
      }
Beispiel #15
0
        string MakeTileImageUrl(GPoint pos, int zoom, string language)
        {
            // ['base','ophoto','turist','army2']
             // http://m1.mapserver.mapy.cz/base-n/3_8000000_8000000

             long xx = pos.X << (28 - zoom);
             long yy = ((((long)Math.Pow(2.0, (double)zoom)) - 1) - pos.Y) << (28 - zoom);

             return string.Format(UrlFormat, GetServerNum(pos, 3) + 1, zoom, xx, yy);
        }
      string MakeTileImageUrl(GPoint pos, int zoom, string language)
      {
         // http://dc1.maps.lt/cache/mapslt_25d_vkkp/map/_alllayers/L01/R00007194/C0000a481.png
         int z = zoom;
         if(zoom >= 10)
         {
            z -= 10;
         }

         return string.Format(UrlFormat, z, pos.Y, pos.X);
      }
      string MakeTileImageUrl(GPoint pos, int zoom, string language)
      {
         string key = TileXYToQuadKey(pos.X, pos.Y, zoom);

         if(!DisableDynamicTileUrlFormat && !string.IsNullOrEmpty(UrlDynamicFormat))
         {
            return string.Format(UrlDynamicFormat, GetServerNum(pos, 4), key, language);
         }

         return string.Format(UrlFormat, GetServerNum(pos, 4), key, Version, language, ForceSessionIdOnTileAccess ? "&key=" + SessionId : string.Empty);
      }
Beispiel #18
0
 public void Fill(GPoint.PType fillType)
 {
     //Debug.Log ("filling the grid with" + fillType);
             //this method DOES NOT start at the 0,0 origin but rather at xymin and ends at xymax;
             for (float ix = xyMin.x; ix < xyMax.x; ix+=1.0f) {
                     for (float iy = xyMin.y; iy <= xyMax.y; iy+=1.0f) {
                             Vector2 pos = new Vector2 (ix, iy);
                             gPoints [(int)pos.x, (int)pos.y].UpdateType (fillType);
                     }
             }
 }
      string MakeTileImageUrl(GPoint pos, int zoom, string language)
      {
         // old stuff
         // http://www.maps.lt/ortofoto/mapslt_ortofoto_vector_512/map/_alllayers/L02/R0000001b/C00000028.jpg
         // http://arcgis.maps.lt/ArcGIS/rest/services/mapslt_ortofoto/MapServer/tile/0/9/13
         // return string.Format("http://www.maps.lt/ortofoto/mapslt_ortofoto_vector_512/map/_alllayers/L{0:00}/R{1:x8}/C{2:x8}.jpg", zoom, pos.Y, pos.X);
         // http://dc1.maps.lt/cache/mapslt_ortofoto_512/map/_alllayers/L03/R0000001c/C00000029.jpg
         // return string.Format("http://arcgis.maps.lt/ArcGIS/rest/services/mapslt_ortofoto/MapServer/tile/{0}/{1}/{2}", zoom, pos.Y, pos.X);
         // http://dc1.maps.lt/cache/mapslt_ortofoto_512/map/_alllayers/L03/R0000001d/C0000002a.jpg

         return string.Format(UrlFormat, zoom, pos.Y, pos.X);
      }
Beispiel #20
0
      string MakeTileImageUrl(GPoint pos, int zoom, string language)
      {
         var px1 = Projection.FromTileXYToPixel(pos);
         var px2 = px1;

         px1.Offset(0, Projection.TileSize.Height);
         PointLatLng p1 = Projection.FromPixelToLatLng(px1, zoom);

         px2.Offset(Projection.TileSize.Width, 0);
         PointLatLng p2 = Projection.FromPixelToLatLng(px2, zoom);

         var ret = string.Format(CultureInfo.InvariantCulture, UrlFormat, p1.Lng, p1.Lat, p2.Lng, p2.Lat, Projection.TileSize.Width, Projection.TileSize.Height);

         return ret;
      }
        string MakeTileImageUrl(GPoint pos, int zoom, string language)
        {
            zoom = zoom - 1;
            var offsetX = Math.Pow(2, zoom);
            var offsetY = offsetX - 1;

            var numX = pos.X - offsetX;
            var numY = -pos.Y + offsetY;

            zoom = zoom + 1;

            var zoomLevel = 729 - zoom;
            if (zoomLevel == 710)
            {
                zoomLevel = 792;
            }

            var blo = Math.Floor(numX / 200);
            var bla = Math.Floor(numY / 200);
            string blos, blas;
            if (blo < 0)
            {
                blos = "M" + (-blo);
            }
            else
            {
                blos = blo.ToString();
            }

            if (bla < 0)
            {
                blas = "M" + (-bla);
            }
            else
            {
                blas = bla.ToString();
            }

            var x = numX.ToString().Replace("-", "M");
            var y = numY.ToString().Replace("-", "M");


            //http://hbpic1.go2map.com/seamless/0/180/717/3/1/750_258.JPG
            string url = string.Format(UrlFormat, "1", zoomLevel, blos, blas, x, y);
            Console.WriteLine("url:" + url);
            return url;
        }
Beispiel #22
0
 public Grid(Vector2 setSize, Vector2 setPosition, GPoint.PType fillType)
 {
     xyMax = setSize + new Vector2 (1.0f, 1.0f);
             gridType = fillType;
             //bump up the size to create room for the buffer;
             SetSize (setSize + new Vector2 (2.0f, 2.0f));
             //translate
             SetPosition (setPosition);
             Debug.Log ("creating a " + setSize.x + "by" + setSize.y + " grid, filled with " + fillType);
             //Debug.Log ("actually a " + size.x + "by" + size.y + " grid");
             //create [,] of empty points
             Initialize ();
             //add a buffer
             MarkBuffer ();
             //fill the center
             Fill (gridType);
 }
Beispiel #23
0
        string MakeTileImageUrl(GPoint pos, int zoom, string language)
        {
            var f = zoom*4;
            var i = _scope[f++];
            var j = _scope[f++];
            var l = _scope[f++];
            var scope = _scope[f];
            if (pos.X >= i && pos.X <= j && pos.Y >= l && pos.Y <= scope)
            {
                pos.Y = (long) (Math.Pow(2, zoom) - 1 - pos.Y);
            }

            //http://p0.map.soso.com/maptilesv2/11/102/74/1633_1198.png
            string url = string.Format(UrlFormat, zoom, Math.Floor((decimal)(pos.X / 16)), Math.Floor((decimal)(pos.Y / 16)), pos.X, pos.Y);
            Console.WriteLine("url:" + url);
            return url;
        }
      string MakeTileImageUrl(GPoint pos, int zoom, string language)
      {
         // http://{domain}/{layerName}/{zoomLevel}/{first3LetterOfTileX}/{second3LetterOfTileX}/{third3LetterOfTileX}/{first3LetterOfTileY}/{second3LetterOfTileY}/{third3LetterOfTileXY}.png

         // http://map3.pergo.com.tr/tile/00/000/000/001/000/000/000.png   
         // That means: Zoom Level: 0 TileX: 1 TileY: 0

         // http://domain/tile/14/000/019/371/000/011/825.png
         // That means: Zoom Level: 14 TileX: 19371 TileY:11825

         // updated version
         // http://map1.pergo.com.tr/publish/tile/tile9913/06/000/000/038/000/000/039.png

         string x = pos.X.ToString(Zeros).Insert(3, Slash).Insert(7, Slash); // - 000/000/001
         string y = pos.Y.ToString(Zeros).Insert(3, Slash).Insert(7, Slash); // - 000/000/000

         return string.Format(UrlFormat, GetServerNum(pos, 3), zoom, x, y);
      }
Beispiel #25
0
        string MakeTileImageUrl(GPoint pos, int zoom, string language)
        {
            zoom = zoom - 1;
            var offsetX = Math.Pow(2, zoom);
            var offsetY = offsetX - 1;

            var numX = pos.X - offsetX;
            var numY = -pos.Y + offsetY;

            zoom = zoom + 1;
            var num = (pos.X + pos.Y)%8 + 1;
            var x = numX.ToString().Replace("-", "M");
            var y = numY.ToString().Replace("-", "M");

            //http://q3.baidu.com/it/u=x=721;y=209;z=12;v=014;type=web&fm=44
            string url = string.Format(UrlFormat, num, x, y, zoom, "014", "web", "44");
            Console.WriteLine("url:" + url);
            return url;
        }
Beispiel #26
0
        string MakeTileImageUrl(GPoint pos, int zoom, string language)
        {
            zoom = zoom - 1;
            var offsetX = Math.Pow(2, zoom);
            var offsetY = offsetX - 1;

            var numX = pos.X - offsetX;
            var numY = -pos.Y + offsetY;

            zoom = zoom + 1;
            var num = (pos.X + pos.Y)%8 + 1;
            var x = numX.ToString().Replace("-", "M");
            var y = numY.ToString().Replace("-", "M");

            //原来:http://q3.baidu.com/it/u=x=721;y=209;z=12;v=014;type=web&fm=44
            //更新:http://online1.map.bdimg.com/tile/?qt=tile&x=23144&y=6686&z=17&styles=pl
            string url = string.Format(UrlFormat, x, y, zoom);
            Console.WriteLine("url:" + url);
            return url;
        }
    GameTile[,] tiles; // = new GameTile[,];

    #endregion Fields

    #region Methods

    IEnumerator CoDestroyTiles()
    {
        NotificationCenter.DefaultCenter.PostNotification (this, "Destroy");
                yield return new WaitForSeconds (0.01f);
                for (int ix =0; ix<tiles.GetLength(0); ix++) {
                        for (int iy =0; iy <tiles.GetLength(1); iy++) {
                                //GameTile tile = ;
                                if (!tiles [ix, iy]) {
                                        GPoint gP = new GPoint (new Vector2 (ix + 1, iy + 1), GPoint.PType.TILE_DESTROYED);
                                        GameObject newTile = (GameObject)Instantiate (destroyedTile, gP.GetWorldPosition (), Quaternion.identity);
                                        newTile.name = "/x:" + gP.GetPosition ().x + "$/y:" + gP.GetPosition ().y + "$/t:" + gP.GetPType () + "$";
                                        newTile.transform.parent = transform;
                                        tiles [ix, iy] = newTile.GetComponent<GameTile> ();
                                        tiles [ix, iy].SetData ();
                                }
                        }
                }
                AStarGrid.Scan ();
                StopCoroutine ("CoDestroyTiles");
    }
    protected void Page_Load(object sender, System.EventArgs e)
    {
        WEBooksBizTalk_WS.Utilizador utilizador = (WEBooksBizTalk_WS.Utilizador)this.Session["utilizador"];

        this.Session.Add("UserMapa", null);

        if (utilizador == null || utilizador.TipoUtilizador != "Gestor")
        {
            DivUserInexistente.Attributes.Add("style", "color:Red; text-align:center; font-weight: bold; ");
            DivUserInexistente.InnerText = "Necessita de estar logado como Gestor";

            gMap.Visible = false;

            return;
        }
        gMap.Visible = true;

        WEBooksBDService servicoBD = new WEBooksBDService();

        Cliente[] listaClientes = servicoBD.MostraClientes();

        GPoint gp = new GPoint(float.Parse(listaClientes[0].Longitude), float.Parse(listaClientes[0].Latitude));

        GMarker gm;

        foreach (Cliente cli in listaClientes) {

            GPoint ponto = new GPoint( float.Parse(cli.Longitude), float.Parse(cli.Latitude) );

            gm = new GMarker(ponto, "<a href=\"./pesquisaHistoricoEncomendas.aspx?Username="******">" + cli.Username + "</a>");
            gMap.Overlays.Add(gm);
        }

           // gMap.AddControl(new GSmallMapControl());
        gMap.AddControl(new GLargeMapControl());

        gMap.AddControl(new GMapTypeControl());

        gMap.CenterAndZoom(gp, 4);
    }
Beispiel #29
0
        /// <summary>
        /// Test the gPoint.IsEqual() funciton. 
        /// Results of testing are shown in output window in VS.
        /// </summary>
        public static void TestIsEqual()
        {
            String message;
            bool result = false;
            GPoint point1 = new GPoint(40, 40, 0, new DateTimeOffset(DateTime.Now));
            GPoint point2;
            message = "Testing : GPoint.IsEqual - SamePoint without TimeTaken";
            result = point1.IsEqual(point1, false);
            System.Diagnostics.Debug.WriteLine(message + "\t\t\t " + (result == true));

            message = "Testing : GPoint.IsEqual - SamePoint WITH 0 sec to ignore";
            result = point1.IsEqual(point1, true, 0);
            System.Diagnostics.Debug.WriteLine(message + "\t\t\t " + (result == true));

            message = "Testing : GPoint.IsEqual - OtherPoint(0 sec)  WITH 3 sec to ignore";
            point2 = point1.Clone();
            result = point1.IsEqual(point2, true, 3);
            System.Diagnostics.Debug.WriteLine(message + "\t\t\t " + (result == true));

            message = "Testing : GPoint.IsEqual - OtherPoint(+3 sec)  WITH 0 sec to ignore";
            point2 = point1.Clone();
            point2.TimeTaken.AddSeconds(3);
            result = point1.IsEqual(point2, true, 0);
            System.Diagnostics.Debug.WriteLine(message + "\t\t\t " + (result == false));

            message = "Testing : GPoint.IsEqual - OtherPoint(-3 sec)  WITH 0 sec to ignore";
            point2 = point1.Clone();
            point2.TimeTaken = point2.TimeTaken.Subtract(new TimeSpan(0, 0, 3));
            result = point1.IsEqual(point2, true, 0);
            System.Diagnostics.Debug.WriteLine(message + "\t\t\t " + (result == false));

            message = "Testing : GPoint.IsEqual - OtherPoint(-3 sec)  WITH 3 sec to ignore";
            point2 = point1.Clone();
            point2.TimeTaken = point2.TimeTaken.Subtract(new TimeSpan(0, 0, 3));
            result = point1.IsEqual(point2, true, 3);
            System.Diagnostics.Debug.WriteLine(message + "\t\t\t " + (result == true));
        }
Beispiel #30
0
 public override PureImage GetTileImage(GPoint pos, int zoom)
 {
     throw new NotImplementedException();
 }
Beispiel #31
0
 string MakeTileImageUrl(GPoint pos, int zoom, string language)
 {
     return(string.Format(UrlFormat, levels[zoom], zoom, pos.X, ((2 << zoom - 1) - pos.Y - 1)));
 }
Beispiel #32
0
 /// <summary>
 /// gets tile image using implmented provider
 /// </summary>
 /// <param name="pos"></param>
 /// <param name="zoom"></param>
 /// <returns></returns>
 public abstract PureImage GetTileImage(GPoint pos, int zoom);
Beispiel #33
0
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            if (this.DesignMode)
            {
                return;
            }

            if (area.LocationMiddle.Lat == 0 && area.LocationMiddle.Lng == 0)
            {
                return;
            }

            try
            {
                base.OnPaint(e);
            }
            catch
            {
                return;
            }

            double heightscale = (step / 90.0) * 1;

            float yawradians = (float)(Math.PI * (rpy.Z * 1) / 180.0f);

            //radians = 0;

            float mouseY = (float)step / 10f;

            cameraX = center.Lng; // -Math.Sin(yawradians) * mouseY;     // multiplying by mouseY makes the
            cameraY = center.Lat; // -Math.Cos(yawradians) * mouseY;    // camera get closer/farther away with mouseY
            cameraZ = (center.Alt < srtm.getAltitude(center.Lat, center.Lng).alt)
                ? (srtm.getAltitude(center.Lat, center.Lng).alt + 1) * heightscale
                : center.Alt * heightscale; // (srtm.getAltitude(lookZ, lookX, 20) + 100) * heighscale;

            lookX = center.Lng + Math.Sin(yawradians) * mouseY;
            lookY = center.Lat + Math.Cos(yawradians) * mouseY;
            lookZ = cameraZ;

            // cameraZ += 0.04;

            GMapProvider   type = GMap.NET.MapProviders.GoogleSatelliteMapProvider.Instance;
            PureProjection prj  = type.Projection;

            int size = (int)(cameraZ * 150000);

            // in front
            PointLatLngAlt leftf = center.newpos(rpy.Z, size);
            // behind
            PointLatLngAlt rightf = center.newpos(rpy.Z, 50);
            // left : 90 allows for 180 degree viewing angle
            PointLatLngAlt left = center.newpos(rpy.Z - 90, size);
            // right
            PointLatLngAlt right = center.newpos(rpy.Z + 90, size);

            double maxlat = Math.Max(left.Lat, Math.Max(right.Lat, Math.Max(leftf.Lat, rightf.Lat)));
            double minlat = Math.Min(left.Lat, Math.Min(right.Lat, Math.Min(leftf.Lat, rightf.Lat)));

            double maxlng = Math.Max(left.Lng, Math.Max(right.Lng, Math.Max(leftf.Lng, rightf.Lng)));
            double minlng = Math.Min(left.Lng, Math.Min(right.Lng, Math.Min(leftf.Lng, rightf.Lng)));

            // if (Math.Abs(area.Lat - maxlat) < 0.001)
            {
            }
            // else
            {
                area = RectLatLng.FromLTRB(minlng, maxlat, maxlng, minlat);
            }

            GPoint topLeftPx     = prj.FromLatLngToPixel(area.LocationTopLeft, zoom);
            GPoint rightButtomPx = prj.FromLatLngToPixel(area.Bottom, area.Right, zoom);
            GPoint pxDelta       = new GPoint(rightButtomPx.X - topLeftPx.X, rightButtomPx.Y - topLeftPx.Y);

            zoom      = 21;
            pxDelta.X = 9999;

            int otherzoomlevel = 12;

            // zoom based on pixel density
            while (pxDelta.X > this.Width)
            {
                zoom--;

                // current area
                topLeftPx     = prj.FromLatLngToPixel(area.LocationTopLeft, zoom);
                rightButtomPx = prj.FromLatLngToPixel(area.Bottom, area.Right, zoom);
                pxDelta       = new GPoint(rightButtomPx.X - topLeftPx.X, rightButtomPx.Y - topLeftPx.Y);
            }

            otherzoomlevel = zoom - 4;

            //Console.WriteLine("zoom {0}", zoom);

            // update once per seconds - we only read from disk, so need to let cahce settle
            if (lastrefresh.AddSeconds(0.5) < DateTime.Now)
            {
                // get tiles - bg
                core.Provider = type;
                core.Position = LocationCenter;

                // get zoom 10
                core.Zoom = otherzoomlevel;
                core.OnMapSizeChanged(this.Width, this.Height);

                // get actual current zoom
                core.Zoom = zoom;
                core.OnMapSizeChanged(this.Width, this.Height);

                lastrefresh = DateTime.Now;
            }
            else
            {
                //return;
            }

            float screenscale = this.Width / (float)this.Height;

            if (!Context.IsCurrent)
            {
                MakeCurrent();
            }

            GL.MatrixMode(MatrixMode.Projection);

            OpenTK.Matrix4 projection = OpenTK.Matrix4.CreatePerspectiveFieldOfView((float)(120 * MathHelper.deg2rad), screenscale, 0.00001f,
                                                                                    (float)step * 20000);
            GL.LoadMatrix(ref projection);

            Matrix4 modelview = Matrix4.LookAt((float)cameraX, (float)cameraY, (float)cameraZ, (float)lookX,
                                               (float)lookY, (float)lookZ, 0, 0, 1);

            GL.MatrixMode(MatrixMode.Modelview);

            // roll
            modelview = Matrix4.Mult(modelview, Matrix4.CreateRotationZ((float)(rpy.X * MathHelper.deg2rad)));
            // pitch
            modelview = Matrix4.Mult(modelview, Matrix4.CreateRotationX((float)((rpy.Y - 15) * -MathHelper.deg2rad)));

            GL.LoadMatrix(ref modelview);

            GL.ClearColor(Color.CornflowerBlue);

            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.AccumBufferBit);

            GL.LightModel(LightModelParameter.LightModelAmbient, new float[] { 1f, 1f, 1f, 1f });

            //  GL.Disable(EnableCap.Fog);
            GL.Enable(EnableCap.Fog);
            //GL.Enable(EnableCap.Lighting);
            //GL.Enable(EnableCap.Light0);

            GL.Fog(FogParameter.FogColor, new float[] { 100 / 255.0f, 149 / 255.0f, 237 / 255.0f, 1f });
            //GL.Fog(FogParameter.FogDensity,0.1f);
            GL.Fog(FogParameter.FogMode, (int)FogMode.Linear);
            GL.Fog(FogParameter.FogStart, (float)step * 40);
            GL.Fog(FogParameter.FogEnd, (float)(step * 50));

//            GL.Enable(EnableCap.DepthTest);
            GL.DepthFunc(DepthFunction.Always);

            /*
             * GL.Begin(BeginMode.LineStrip);
             *
             * GL.Color3(Color.White);
             * GL.Vertex3(0, 0, 0);
             *
             * //GL.Color3(Color.Red);
             * GL.Vertex3(area.Bottom, 0, area.Left);
             *
             * //GL.Color3(Color.Yellow);
             * GL.Vertex3(lookX, lookY, lookZ);
             *
             * //GL.Color3(Color.Green);
             * GL.Vertex3(cameraX, cameraY, cameraZ);
             *
             * GL.End();
             */
            /*
             * GL.PointSize(10);
             * GL.Color4(Color.Yellow);
             * GL.LineWidth(5);
             *
             *
             * GL.Begin(PrimitiveType.LineStrip);
             *
             * //GL.Vertex3(new Vector3((float)center.Lng,(float)center.Lat,(float)(center.Alt * heightscale)));
             * //GL.Vertex3(new Vector3(0, 0, 0));
             * //GL.Vertex3(new Vector3((float)cameraX, (float)cameraY, (float)cameraZ));
             * //GL.Color3(Color.Green);
             * //GL.Vertex3(new Vector3((float)lookX, (float)lookY, (float)lookZ));
             *
             * GL.Vertex3(area.LocationTopLeft.Lng, area.LocationTopLeft.Lat, (float)cameraZ);
             * GL.Vertex3(area.LocationTopLeft.Lng, area.LocationRightBottom.Lat, (float)cameraZ);
             * GL.Vertex3(area.LocationRightBottom.Lng, area.LocationRightBottom.Lat, (float)cameraZ);
             * GL.Vertex3(area.LocationRightBottom.Lng, area.LocationTopLeft.Lat, (float)cameraZ);
             * GL.Vertex3(area.LocationTopLeft.Lng, area.LocationTopLeft.Lat, (float)cameraZ);
             *
             * GL.End();
             */
            GL.Finish();

            GL.PointSize((float)(step * 1));
            GL.Color3(Color.Blue);
            GL.Begin(PrimitiveType.Points);
            GL.Vertex3(new Vector3((float)center.Lng, (float)center.Lat, (float)cameraZ));
            GL.End();


            //GL.ClampColor(ClampColorTarget.ClampReadColor, ClampColorMode.True);

            /*
             * GL.Enable(EnableCap.Blend);
             * GL.DepthMask(false);
             * GL.BlendFunc(BlendingFactorSrc.Zero, BlendingFactorDest.Src1Color);
             * GL.DepthMask(true);
             * GL.Disable(EnableCap.Blend);
             */
            // textureid.Clear();

            // get level 10 tiles
            List <GPoint> tileArea1 = prj.GetAreaTileList(area, otherzoomlevel, 1);

            // get type list at new zoom level
            List <GPoint> tileArea2 = prj.GetAreaTileList(area, zoom, 2);

            List <GPoint> tileArea = new List <GPoint>();

            tileArea.AddRange(tileArea1);
            tileArea.AddRange(tileArea2);

            // get tiles & combine into one
            foreach (var p in tileArea)
            {
                int localzoom = zoom;

                core.tileDrawingListLock.AcquireReaderLock();
                core.Matrix.EnterReadLock();
                try
                {
                    if (tileArea1.Contains(p))
                    {
                        localzoom = otherzoomlevel;
                    }

                    topLeftPx = prj.FromLatLngToPixel(area.LocationTopLeft, localzoom);

                    GMap.NET.Internals.Tile t = core.Matrix.GetTileWithNoLock(localzoom, p);

                    if (t.NotEmpty)
                    {
                        foreach (GMapImage img in t.Overlays)
                        {
                            if (!textureid.ContainsKey(p))
                            {
                                generateTexture(p, (Bitmap)img.Img);
                            }
                        }
                    }
                    else
                    {
                    }
                }
                finally
                {
                    core.Matrix.LeaveReadLock();
                    core.tileDrawingListLock.ReleaseReaderLock();
                }

                //GMapImage tile = ((PureImageCache)Maps.MyImageCache.Instance).GetImageFromCache(type.DbId, p, zoom) as GMapImage;

                //if (tile != null && !textureid.ContainsKey(p))
                {
                    //  generateTexture(p, (Bitmap)tile.Img);
                }

                if (textureid.ContainsKey(p))
                {
                    int texture = textureid[p];

                    GL.Enable(EnableCap.Texture2D);
                    GL.BindTexture(TextureTarget.Texture2D, texture);
                }
                else
                {
                    //Console.WriteLine("Missing tile");
                    continue;
                }

                long x = p.X * prj.TileSize.Width - topLeftPx.X;
                long y = p.Y * prj.TileSize.Width - topLeftPx.Y;

                long xr = p.X * prj.TileSize.Width;
                long yr = p.Y * prj.TileSize.Width;

                long x2 = (p.X + 1) * prj.TileSize.Width;
                long y2 = (p.Y + 1) * prj.TileSize.Width;


                GL.LineWidth(0);
                GL.Color3(Color.White);

                // generate terrain
                GL.Begin(PrimitiveType.TriangleStrip);

                var latlng = prj.FromPixelToLatLng(xr, yr, localzoom);

                double heightl = srtm.getAltitude(latlng.Lat, latlng.Lng).alt;
                if (localzoom == 10)
                {
                    heightl = 0;
                }

                //xr - topLeftPx.X, yr - topLeftPx.Y
                GL.TexCoord2(0, 0);
                GL.Vertex3(latlng.Lng, latlng.Lat, heightl * heightscale);


                // next down
                latlng = prj.FromPixelToLatLng(xr, y2, localzoom);

                heightl = srtm.getAltitude(latlng.Lat, latlng.Lng).alt;
                if (localzoom == 10)
                {
                    heightl = 0;
                }

                GL.TexCoord2(0, 1);
                GL.Vertex3(latlng.Lng, latlng.Lat, heightl * heightscale);


                // next right
                latlng = prj.FromPixelToLatLng(x2, yr, localzoom);

                heightl = srtm.getAltitude(latlng.Lat, latlng.Lng).alt;
                if (localzoom == 10)
                {
                    heightl = 0;
                }

                GL.TexCoord2(1, 0);
                GL.Vertex3(latlng.Lng, latlng.Lat, heightl * heightscale);


                // next right down
                latlng = prj.FromPixelToLatLng(x2, y2, localzoom);

                heightl = srtm.getAltitude(latlng.Lat, latlng.Lng).alt;
                if (localzoom == 10)
                {
                    heightl = 0;
                }

                GL.TexCoord2(1, 1);
                GL.Vertex3(latlng.Lng, latlng.Lat, heightl * heightscale);

                GL.End();
            }

            GL.Flush();

            try
            {
                this.SwapBuffers();


                //Context.MakeCurrent(null);
            }
            catch
            {
            }

            //this.Invalidate();

            return;
        }
Beispiel #34
0
 public override PureImage GetTileImage(GPoint pos, int zoom)
 {
     return(null);
 }
Beispiel #35
0
 /// <summary>
 /// Converts a GPoint type object to a Point type one
 /// </summary>
 /// <param name="p">GPoint type object</param>
 /// <returns></returns>
 public Point ConvertGPointToPoint(GPoint p)
 {
     return(new Point((int)p.X, (int)p.Y));
 }
 string MakeTileImageUrl(GPoint pos, int zoom, string language)
 {
     return(string.Format(UrlFormat, GetServerNum(pos, 3) + 1, zoom, pos.X, pos.Y));
 }
Beispiel #37
0
 string MakeTileImageUrl(GPoint pos, int zoom, string language)
 {
     return(string.Format(UrlFormat, ServerLetters[GetServerNum(pos, 3)], Key, StyleID, (DoubleResolution ? DoubleResolutionString : string.Empty), zoom, pos.X, pos.Y));
 }
        public override PureImage GetTileImage(GPoint pos, int zoom)
        {
            string url = this.MakeTileImageUrl(pos, zoom, GMapProvider.LanguageStr);

            return(base.GetTileImageUsingHttp(url));
        }
        public override PureImage GetTileImage(GPoint pos, int zoom)
        {
            string url = string.Format(ArcGISMapProviderBase.UrlFormat, new object[] { "ChinaOnlineStreetGray", zoom, pos.Y, pos.X });

            return(base.GetTileImageUsingHttp(url));
        }
Beispiel #40
0
        string MakeTileImageUrl(GPoint pos, int zoom, string language)
        {
            // http://c.maptile.maps.svc.ovi.com/maptiler/v2/maptile/newest/hybrid.day/12/2316/1277/256/png8

            return(string.Format(UrlFormat, UrlServerLetters[GetServerNum(pos, 4)], zoom, pos.X, pos.Y));
        }
        public override PureImage GetTileImage(GPoint pos, int zoom)
        {
            string url = MakeTileImageUrl(pos, zoom, LanguageStr);

             return GetTileImageUsingHttp(url);
        }
        /// <summary>
        /// 获取要素信息
        /// </summary>
        /// <returns></returns>
        private CAppendFeature GetMapFeatureInfo(SFclsGeomType geoType)
        {
            CAppendFeature fInfo = new CAppendFeature();
            SFeature       sf    = new SFeature();

            sf.AttValue = new string[m_attStruct.FldNumber];
            for (int i = 0; i < m_attStruct.FldNumber; i++)
            {
                sf.AttValue[i] = m_textBoxArr[i].Text;
                switch (this.m_attStruct.FldType[i])
                {
                case "double":
                case "integer":
                case "long":
                case "short":
                    if (!CommFun.IsNumber(sf.AttValue[i]))
                    {
                        MessageBox.Show("字段【Fld_" + this.m_attStruct.FldName[i] + "】输入的数据格式不正确。请重新输入!", "提示", MessageBoxButton.OK);
                        return(null);
                    }
                    break;
                }
            }
            SFeatureGeometry sfGeo = null;
            SFclsGeomType    curFGeoType;

            if (m_targetGeo != null)
            {
                sfGeo = m_targetGeo as SFeatureGeometry;
                if (sfGeo == null) //add feature
                {
                    sfGeo = new SFeatureGeometry();
                    switch ((m_targetGeo as IWebGeometry).GetGeomType())
                    {
                    case WebGeomType.Point:
                        sf.ftype = SFclsGeomType.Pnt;
                        GPoint pnt = new GPoint();
                        pnt.Dot       = m_targetGeo as Dot_2D;
                        sfGeo.PntGeom = new GPoint[] { pnt };
                        break;

                    case WebGeomType.Line:
                        sf.ftype = SFclsGeomType.Lin;
                        GLine line = new GLine();
                        line.Line     = m_targetGeo as AnyLine;
                        sfGeo.LinGeom = new GLine[] { line };
                        break;

                    case WebGeomType.Polygon:
                        sf.ftype = SFclsGeomType.Reg;
                        GRegion polygon = new GRegion();
                        AnyLine circle  = new AnyLine();
                        circle.Arcs         = new Arc[1];
                        circle.Arcs[0]      = new Arc();
                        circle.Arcs[0].Dots = (m_targetGeo as ZDIMS.BaseLib.Polygon).Dots;
                        polygon.Rings       = new AnyLine[] { circle };
                        sfGeo.RegGeom       = new GRegion[] { polygon };
                        break;

                    default:
                        sfGeo = null;
                        break;
                    }
                }
            }
            curFGeoType = geoType;
            if (this.m_featureStyle == null)
            {
                this.m_featureStyle = new WebGraphicsInfo();
            }
            this.m_style.Update();
            switch (curFGeoType)
            {
            case SFclsGeomType.Pnt:
                this.m_featureStyle.InfoType = GInfoType.PntInfo;
                PointStyle newPntStyle = this.m_style as PointStyle;
                this.m_featureStyle.PntInfo = new CPointInfo();
                if (newPntStyle.patternAngle.Text == "")
                {
                    this.m_featureStyle.PntInfo.Angle = 0.0;
                }
                else
                {
                    this.m_featureStyle.PntInfo.Angle = Convert.ToDouble(newPntStyle.patternAngle.Text);
                }
                if (newPntStyle.patternColor._TextBoxInput.Text.Split(':')[0] == "")
                {
                    this.m_featureStyle.PntInfo.Color = 0;
                }
                else
                {
                    this.m_featureStyle.PntInfo.Color = Convert.ToInt32(newPntStyle.patternColor._TextBoxInput.Text.Split(':')[0]);
                }
                if (newPntStyle.patternHeight.Text == "")
                {
                    this.m_featureStyle.PntInfo.SymHeight = 0.0;
                }
                else
                {
                    this.m_featureStyle.PntInfo.SymHeight = Convert.ToDouble(newPntStyle.patternHeight.Text);
                }
                if (newPntStyle.patternID._TextBoxInput.Text.Split(':')[0] == "")
                {
                    this.m_featureStyle.PntInfo.SymID = 0;
                }
                else
                {
                    this.m_featureStyle.PntInfo.SymID = Convert.ToInt32(newPntStyle.patternID._TextBoxInput.Text.Split(':')[0]);
                }
                if (newPntStyle.patternWidth.Text == "")
                {
                    this.m_featureStyle.PntInfo.SymWidth = 0.0;
                }
                else
                {
                    this.m_featureStyle.PntInfo.SymWidth = Convert.ToDouble(newPntStyle.patternWidth.Text);
                }
                break;

            case SFclsGeomType.Lin:
                this.m_featureStyle.InfoType = GInfoType.LinInfo;
                LineStyle newLineStyle = this.m_style as LineStyle;
                this.m_featureStyle.LinInfo = new CLineInfo();
                if (newLineStyle.color._TextBoxInput.Text.Split(':')[0] == "")
                {
                    this.m_featureStyle.LinInfo.Color = 0;
                }
                else
                {
                    this.m_featureStyle.LinInfo.Color = Convert.ToInt32(newLineStyle.color._TextBoxInput.Text.Split(':')[0]);
                }
                if (newLineStyle.patternID._TextBoxInput.Text.Split(':')[0] == "")
                {
                    this.m_featureStyle.LinInfo.LinStyleID = 0;
                }
                else
                {
                    this.m_featureStyle.LinInfo.LinStyleID = Convert.ToInt32(newLineStyle.patternID._TextBoxInput.Text.Split(':')[0]);
                }
                if (newLineStyle.patternID2._TextBoxInput.Text.Split(':')[0] == "")
                {
                    this.m_featureStyle.LinInfo.LinStyleID2 = 0;
                }
                else
                {
                    this.m_featureStyle.LinInfo.LinStyleID2 = Convert.ToInt32(newLineStyle.patternID2._TextBoxInput.Text.Split(':')[0]);
                }
                if (newLineStyle.penWidth.Text == "")
                {
                    this.m_featureStyle.LinInfo.LinWidth = 0.0;
                }
                else
                {
                    this.m_featureStyle.LinInfo.LinWidth = Convert.ToDouble(newLineStyle.penWidth.Text);
                }
                if (newLineStyle.lineScaleX.Text == "")
                {
                    this.m_featureStyle.LinInfo.Xscale = 0.0;
                }
                else
                {
                    this.m_featureStyle.LinInfo.Xscale = Convert.ToDouble(newLineStyle.lineScaleX.Text);
                }
                if (newLineStyle.lineScaleY.Text == "")
                {
                    this.m_featureStyle.LinInfo.Yscale = 0.0;
                }
                else
                {
                    this.m_featureStyle.LinInfo.Yscale = Convert.ToDouble(newLineStyle.lineScaleY.Text);
                }
                break;

            case SFclsGeomType.Reg:
                this.m_featureStyle.InfoType = GInfoType.RegInfo;
                PolygonStyle newRegStyle = this.m_style as PolygonStyle;
                this.m_featureStyle.RegInfo = new CRegionInfo();
                if (newRegStyle.fillcolor._TextBoxInput.Text.Split(':')[0] == "")
                {
                    this.m_featureStyle.RegInfo.FillColor = 0;
                }
                else
                {
                    this.m_featureStyle.RegInfo.FillColor = Convert.ToInt32(newRegStyle.fillcolor._TextBoxInput.Text.Split(':')[0]);
                }
                if (newRegStyle.patternColor._TextBoxInput.Text.Split(':')[0] == "")
                {
                    this.m_featureStyle.RegInfo.PatColor = 0;
                }
                else
                {
                    this.m_featureStyle.RegInfo.PatColor = Convert.ToInt32(newRegStyle.patternColor._TextBoxInput.Text.Split(':')[0]);
                }
                if (newRegStyle.patternHeight.Text == "")
                {
                    this.m_featureStyle.RegInfo.PatHeight = 0.0;
                }
                else
                {
                    this.m_featureStyle.RegInfo.PatHeight = Convert.ToDouble(newRegStyle.patternHeight.Text);
                }
                if (newRegStyle.patternID._TextBoxInput.Text.Split(':')[0] == "")
                {
                    this.m_featureStyle.RegInfo.PatID = 0;
                }
                else
                {
                    this.m_featureStyle.RegInfo.PatID = Convert.ToInt32(newRegStyle.patternID._TextBoxInput.Text.Split(':')[0]);
                }
                if (newRegStyle.patternPenWidth.Text == "")
                {
                    this.m_featureStyle.RegInfo.OutPenWidth = 0.0;
                }
                else
                {
                    this.m_featureStyle.RegInfo.OutPenWidth = Convert.ToDouble(newRegStyle.patternPenWidth.Text);
                }
                if (newRegStyle.patternWidth.Text == "")
                {
                    this.m_featureStyle.RegInfo.PatWidth = 0.0;
                }
                else
                {
                    this.m_featureStyle.RegInfo.PatWidth = Convert.ToDouble(newRegStyle.patternWidth.Text);
                }
                break;
            }
            sf.fGeom         = sfGeo;
            sf.FID           = m_featureID;
            fInfo.GInfo      = this.m_featureStyle;
            fInfo.FSet       = sf;
            fInfo.GdbIndex   = ActiveLayerObj.ActiveGdbIndex;
            fInfo.LayerIndex = ActiveLayerObj.ActiveLayerIndex;
            return(fInfo);
        }
Beispiel #43
0
        string MakeTileImageUrl(GPoint pos, int zoom, string language)
        {
            // http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/0/0/0jpg

            return(string.Format(UrlFormat, zoom, pos.Y, pos.X));
        }
Beispiel #44
0
        string MakeTileImageUrl(GPoint pos, int zoom, string language)
        {
            // http://server.arcgisonline.com/ArcGIS/rest/services/NGS_Topo_US_2D/MapServer/tile/4/3/15

            return(string.Format(UrlFormat, zoom, pos.Y, pos.X));
        }
        void getImage()
        {
            GMapProvider   type = GMap.NET.MapProviders.GoogleSatelliteMapProvider.Instance;
            PureProjection prj  = type.Projection;

            //GMap.NET.GMaps.Instance.GetImageFrom();

            DateTime startimage = DateTime.Now;

            if (!area.IsEmpty)
            {
                try
                {
                    //string bigImage = zoom + "-" + type + "-vilnius.png";

                    //Console.WriteLine("Preparing: " + bigImage);
                    //Console.WriteLine("Zoom: " + zoom);
                    //Console.WriteLine("Type: " + type.ToString());
                    //Console.WriteLine("Area: " + area);

                    var types = type;// GMaps.Instance.GetAllLayersOfType(type);

                    // max zoom level
                    zoom = 20;

                    GPoint topLeftPx     = prj.FromLatLngToPixel(area.LocationTopLeft, zoom);
                    GPoint rightButtomPx = prj.FromLatLngToPixel(area.Bottom, area.Right, zoom);
                    GPoint pxDelta       = new GPoint(rightButtomPx.X - topLeftPx.X, rightButtomPx.Y - topLeftPx.Y);

                    // zoom based on pixel density
                    while (pxDelta.X > 2000)
                    {
                        zoom--;

                        // current area
                        topLeftPx     = prj.FromLatLngToPixel(area.LocationTopLeft, zoom);
                        rightButtomPx = prj.FromLatLngToPixel(area.Bottom, area.Right, zoom);
                        pxDelta       = new GPoint(rightButtomPx.X - topLeftPx.X, rightButtomPx.Y - topLeftPx.Y);
                    }

                    // get tiles - bg
                    core.Provider = type;
                    core.Position = LocationCenter;
                    core.Zoom     = zoom;

                    // get type list at new zoom level
                    List <GPoint> tileArea = prj.GetAreaTileList(area, zoom, 0);

                    //this.Invalidate();

                    Console.WriteLine((startimage - DateTime.Now).TotalMilliseconds);

                    int padding = 0;
                    {
                        using (Bitmap bmpDestination = new Bitmap((int)pxDelta.X + padding * 2, (int)pxDelta.Y + padding * 2))
                        {
                            Console.WriteLine((startimage - DateTime.Now).TotalMilliseconds);
                            using (Graphics gfx = Graphics.FromImage(bmpDestination))
                            {
                                Console.WriteLine((startimage - DateTime.Now).TotalMilliseconds);
                                gfx.CompositingMode    = System.Drawing.Drawing2D.CompositingMode.SourceOver;
                                gfx.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighSpeed;
                                gfx.SmoothingMode      = System.Drawing.Drawing2D.SmoothingMode.HighSpeed;

                                // get tiles & combine into one
                                foreach (var p in tileArea)
                                {
                                    Console.WriteLine("Downloading[" + p + "]: " + tileArea.IndexOf(p) + " of " + tileArea.Count);

                                    foreach (var tp in type.Overlays)
                                    {
                                        Exception ex;

                                        Console.WriteLine((startimage - DateTime.Now).TotalMilliseconds);
                                        GMapImage tile = ((PureImageCache)Maps.MyImageCache.Instance).GetImageFromCache(type.DbId, p, zoom) as GMapImage;

                                        //GMapImage tile = GMaps.Instance.GetImageFrom(tp, p, zoom, out ex) as GMapImage;
                                        //GMapImage tile = type.GetTileImage(p, zoom) as GMapImage;
                                        //tile.Img.Save(zoom + "-" + p.X + "-" + p.Y + ".bmp");

                                        if (tile != null)
                                        {
                                            using (tile)
                                            {
                                                long x = p.X * prj.TileSize.Width - topLeftPx.X + padding;
                                                long y = p.Y * prj.TileSize.Width - topLeftPx.Y + padding;
                                                {
                                                    Console.WriteLine((startimage - DateTime.Now).TotalMilliseconds);
                                                    gfx.DrawImage(tile.Img, x, y, prj.TileSize.Width, prj.TileSize.Height);
                                                    Console.WriteLine((startimage - DateTime.Now).TotalMilliseconds);
                                                }
                                            }
                                        }
                                        else
                                        {
                                        }
                                    }
                                }
                            }

                            Console.WriteLine((startimage - DateTime.Now).TotalMilliseconds);
                            _terrain = new Bitmap(bmpDestination, 1024 * 2, 1024 * 2);

                            // _terrain.Save(zoom +"-map.bmp");


                            GL.BindTexture(TextureTarget.Texture2D, texture);

                            BitmapData data = _terrain.LockBits(new System.Drawing.Rectangle(0, 0, _terrain.Width, _terrain.Height),
                                                                ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

                            //Console.WriteLine("w {0} h {1}",data.Width, data.Height);

                            GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, data.Width, data.Height, 0,
                                          OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0);

                            _terrain.UnlockBits(data);

                            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
                            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
                        }
                    }
                }
                catch (Exception ex) { Console.WriteLine(ex); }
            }
        }
Beispiel #46
0
        static Bitmap GetMap(RectLatLng area)
        {
            GMapProvider   type = GMap.NET.MapProviders.GoogleSatelliteMapProvider.Instance;
            PureProjection prj  = type.Projection;

            int zoom = 16;

            GPoint topLeftPx     = prj.FromLatLngToPixel(area.LocationTopLeft, zoom);
            GPoint rightButtomPx = prj.FromLatLngToPixel(area.Bottom, area.Right, zoom);
            GPoint pxDelta       = new GPoint(rightButtomPx.X - topLeftPx.X, rightButtomPx.Y - topLeftPx.Y);

            // zoom based on pixel density
            while (pxDelta.X > 2000)
            {
                zoom--;

                // current area
                topLeftPx     = prj.FromLatLngToPixel(area.LocationTopLeft, zoom);
                rightButtomPx = prj.FromLatLngToPixel(area.Bottom, area.Right, zoom);
                pxDelta       = new GPoint(rightButtomPx.X - topLeftPx.X, rightButtomPx.Y - topLeftPx.Y);
            }

            // get type list at new zoom level
            List <GPoint> tileArea = prj.GetAreaTileList(area, zoom, 0);

            int padding = 10;

            Bitmap bmpDestination = new Bitmap((int)pxDelta.X + padding * 2, (int)pxDelta.Y + padding * 2);

            {
                using (Graphics gfx = Graphics.FromImage(bmpDestination))
                {
                    gfx.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver;

                    // get tiles & combine into one
                    foreach (var p in tileArea)
                    {
                        Console.WriteLine("Downloading[" + p + "]: " + tileArea.IndexOf(p) + " of " + tileArea.Count);

                        foreach (var tp in type.Overlays)
                        {
                            Exception ex;
                            GMapImage tile = GMaps.Instance.GetImageFrom(tp, p, zoom, out ex) as GMapImage;

                            if (tile != null)
                            {
                                using (tile)
                                {
                                    long x = p.X * prj.TileSize.Width - topLeftPx.X + padding;
                                    long y = p.Y * prj.TileSize.Width - topLeftPx.Y + padding;
                                    {
                                        gfx.DrawImage(tile.Img, x, y, prj.TileSize.Width, prj.TileSize.Height);
                                    }
                                }
                            }
                        }
                    }
                }

                return(bmpDestination);
            }
        }
Beispiel #47
0
        bool PureImageCache.PutImageToCache(byte[] tile, int type, GPoint pos, int zoom)
        {
            bool ret = true;

            if (_created)
            {
                try
                {
                    using (var cn = new SQLiteConnection())
                    {
                        cn.ConnectionString = _connectionString;
                        cn.Open();
                        {
                            using (DbTransaction tr = cn.BeginTransaction())
                            {
                                try
                                {
                                    using (DbCommand cmd = cn.CreateCommand())
                                    {
                                        cmd.Transaction = tr;
                                        cmd.CommandText = singleSqlInsert;

                                        cmd.Parameters.Add(new SQLiteParameter("@p1", pos.X));
                                        cmd.Parameters.Add(new SQLiteParameter("@p2", pos.Y));
                                        cmd.Parameters.Add(new SQLiteParameter("@p3", zoom));
                                        cmd.Parameters.Add(new SQLiteParameter("@p4", type));
                                        cmd.Parameters.Add(new SQLiteParameter("@p5", DateTime.Now));

                                        cmd.ExecuteNonQuery();
                                    }

                                    using (DbCommand cmd = cn.CreateCommand())
                                    {
                                        cmd.Transaction = tr;

                                        cmd.CommandText = singleSqlInsertLast;
                                        cmd.Parameters.Add(new SQLiteParameter("@p1", tile));

                                        cmd.ExecuteNonQuery();
                                    }

                                    tr.Commit();
                                }
                                catch (Exception ex)
                                {
#if MONO
                                    Console.WriteLine("PutImageToCache: " + ex.ToString());
#endif
                                    Debug.WriteLine("PutImageToCache: " + ex.ToString());

                                    tr.Rollback();
                                    ret = false;
                                }
                            }
                        }
                        cn.Close();
                    }

                    if (Interlocked.Increment(ref _preAllocationPing) % 22 == 0)
                    {
                        CheckPreAllocation();
                    }
                }
                catch (Exception ex)
                {
#if MONO
                    Console.WriteLine("PutImageToCache: " + ex.ToString());
#endif
                    Debug.WriteLine("PutImageToCache: " + ex.ToString());
                    ret = false;
                }
            }

            return(ret);
        }
Beispiel #48
0
 public new static int GetServerNum(GPoint pos, int max)
 {
     // var hostNum=((opts.nodes!==0)?((tileCoords.x&2)%opts.nodes):0)+opts.nodeStart;
     return((int)(pos.X & 2) % max);
 }
Beispiel #49
0
 protected static int GetServerNum(GPoint pos, int max)
 {
     return((int)(pos.X + 2 * pos.Y) % max);
 }
Beispiel #50
0
        string MakeTileImageUrl(GPoint pos, int zoom, string language)
        {
            string key = TileXYToQuadKey(pos.X, pos.Y, zoom);

            return(string.Format(UrlFormat, GetServerNum(pos, 4), key, Version, language, (!string.IsNullOrEmpty(ClientKey) ? "&key=" + ClientKey : string.Empty)));
        }
        void imageGenWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                ImageGenArgs  args     = (ImageGenArgs)e.Argument;
                RectLatLng    area     = args.Area;
                int           zoom     = args.Zoom;
                List <GPoint> tileArea = this.provider.Projection.GetAreaTileList(area, zoom, 0);
                string        bigImage = zoom + "-" + Guid.NewGuid().ToString() + ".jpg";

                // current area
                GPoint topLeftPx     = this.provider.Projection.FromLatLngToPixel(area.LocationTopLeft, zoom);
                GPoint rightButtomPx = this.provider.Projection.FromLatLngToPixel(area.Bottom, area.Right, zoom);
                GPoint pxDelta       = new GPoint(rightButtomPx.X - topLeftPx.X, rightButtomPx.Y - topLeftPx.Y);

                using (Bitmap bmpDestination = new Bitmap((int)(pxDelta.X), (int)(pxDelta.Y)))
                {
                    using (Graphics gfx = Graphics.FromImage(bmpDestination))
                    {
                        gfx.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver;

                        // get tiles & combine into one
                        int all        = tileArea.Count;
                        int retryCount = 0;
                        for (int i = 0; i < all; ++i)
                        {
                            GPoint pos = tileArea[i];
                            if (CacheTiles(zoom, pos, provider, gfx, topLeftPx))
                            {
                                retryCount = 0;
                            }
                            else
                            {
                                if (++retryCount <= retry)
                                {
                                    i--;
                                    continue;
                                }
                                else
                                {
                                    retryCount = 0;
                                }
                            }
                        }
                    }

                    #region draw bounds & coordinates & scale
                    //System.Drawing.Rectangle rect = new System.Drawing.Rectangle();
                    //{
                    //    rect.Location = new System.Drawing.Point(padding, padding);
                    //    rect.Size = new System.Drawing.Size((int)pxDelta.X, (int)pxDelta.Y);
                    //}
                    //using (Font f = new Font(FontFamily.GenericSansSerif, 9, FontStyle.Bold))
                    //using (Graphics gfx = Graphics.FromImage(bmpDestination))
                    //{
                    //// draw bounds & coordinates
                    //using (Pen p = new Pen(Brushes.Red, 3))
                    //{
                    //    p.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot;

                    //    gfx.DrawRectangle(p, rect);

                    //    string topleft = area.LocationTopLeft.ToString();
                    //    SizeF s = gfx.MeasureString(topleft, f);

                    //    gfx.DrawString(topleft, f, p.Brush, rect.X + s.Height / 2, rect.Y + s.Height / 2);

                    //    string rightBottom = new PointLatLng(area.Bottom, area.Right).ToString();
                    //    SizeF s2 = gfx.MeasureString(rightBottom, f);

                    //    gfx.DrawString(rightBottom, f, p.Brush, rect.Right - s2.Width - s2.Height / 2, rect.Bottom - s2.Height - s2.Height / 2);
                    //}

                    //// draw scale
                    //using (Pen p = new Pen(Brushes.Blue, 1))
                    //{
                    //    double rez = mapControl.MapProvider.Projection.GetGroundResolution(zoom, area.Bottom);
                    //    int px100 = (int)(100.0 / rez); // 100 meters
                    //    int px1000 = (int)(1000.0 / rez); // 1km

                    //    gfx.DrawRectangle(p, rect.X + 10, rect.Bottom - 20, px1000, 10);
                    //    gfx.DrawRectangle(p, rect.X + 10, rect.Bottom - 20, px100, 10);

                    //    string leftBottom = "scale: 100m | 1Km";
                    //    SizeF s = gfx.MeasureString(leftBottom, f);
                    //    gfx.DrawString(leftBottom, f, p.Brush, rect.X + 10, rect.Bottom - s.Height - 20);
                    //}
                    //}

                    #endregion

                    bmpDestination.Save(bigImage, System.Drawing.Imaging.ImageFormat.Png);
                }
            }
            catch (Exception ex)
            {
                log.Warn(ex.Message);
                MessageBox.Show("拼接图生成错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #52
0
        PureImage PureImageCache.GetImageFromCache(int type, GPoint pos, int zoom)
        {
            PureImage ret = null;

            try
            {
                using (var cn = new SQLiteConnection())
                {
                    cn.ConnectionString = _connectionString;
                    cn.Open();
                    {
                        if (!string.IsNullOrEmpty(_attachSqlQuery))
                        {
                            using (DbCommand com = cn.CreateCommand())
                            {
                                com.CommandText = _attachSqlQuery;
                                int x = com.ExecuteNonQuery();
                                //Debug.WriteLine("Attach: " + x);
                            }
                        }

                        using (DbCommand com = cn.CreateCommand())
                        {
                            com.CommandText = string.Format(_finnalSqlSelect, pos.X, pos.Y, zoom, type);

                            using (var rd = com.ExecuteReader(System.Data.CommandBehavior.SequentialAccess))
                            {
                                if (rd.Read())
                                {
                                    long length = rd.GetBytes(0, 0, null, 0, 0);
                                    var  tile   = new byte[length];
                                    rd.GetBytes(0, 0, tile, 0, tile.Length);
                                    {
                                        if (GMapProvider.TileImageProxy != null)
                                        {
                                            ret = GMapProvider.TileImageProxy.FromArray(tile);
                                        }
                                    }
                                }

                                rd.Close();
                            }
                        }

                        if (!string.IsNullOrEmpty(_detachSqlQuery))
                        {
                            using (DbCommand com = cn.CreateCommand())
                            {
                                com.CommandText = _detachSqlQuery;
                                int x = com.ExecuteNonQuery();
                                //Debug.WriteLine("Detach: " + x);
                            }
                        }
                    }
                    cn.Close();
                }
            }
            catch (Exception ex)
            {
#if MONO
                Console.WriteLine("GetImageFromCache: " + ex.ToString());
#endif
                Debug.WriteLine("GetImageFromCache: " + ex.ToString());
                ret = null;
            }

            return(ret);
        }
 private bool CacheTiles(int zoom, GPoint p, GMapProvider provider, Graphics gfx, GPoint topLeftPx)
 {
     foreach (var pr in provider.Overlays)
     {
         Exception ex;
         GMapImage tile = GMaps.Instance.GetImageFrom(pr, p, zoom, out ex) as GMapImage;
         if (tile != null)
         {
             using (tile)
             {
                 long x = p.X * this.provider.Projection.TileSize.Width - topLeftPx.X;
                 long y = p.Y * this.provider.Projection.TileSize.Width - topLeftPx.Y;
                 gfx.DrawImage(tile.Img, x, y, this.provider.Projection.TileSize.Width, this.provider.Projection.TileSize.Height);
             }
         }
         else
         {
             return(false);
         }
     }
     return(true);
 }
Beispiel #54
0
        bool PureImageCache.PutImageToCache(MemoryStream tile, MapType type, GPoint pos, int zoom)
        {
            bool ret = true;

            if (Created)
            {
                try
                {
                    using (SQLiteConnection cn = new SQLiteConnection())
                    {
                        cn.ConnectionString = ConnectionString;
                        cn.Open();
                        {
                            using (DbTransaction tr = cn.BeginTransaction())
                            {
                                try
                                {
                                    using (DbCommand cmd = cn.CreateCommand())
                                    {
                                        cmd.Transaction = tr;
                                        cmd.CommandText = singleSqlInsert;

                                        cmd.Parameters.Add(new SQLiteParameter("@p1", pos.X));
                                        cmd.Parameters.Add(new SQLiteParameter("@p2", pos.Y));
                                        cmd.Parameters.Add(new SQLiteParameter("@p3", zoom));
                                        cmd.Parameters.Add(new SQLiteParameter("@p4", (int)type));
                                        cmd.Parameters.Add(new SQLiteParameter("@p5", DateTime.Now));

                                        cmd.ExecuteNonQuery();
                                    }

                                    using (DbCommand cmd = cn.CreateCommand())
                                    {
                                        cmd.Transaction = tr;

                                        cmd.CommandText = singleSqlInsertLast;
                                        cmd.Parameters.Add(new SQLiteParameter("@p1", tile.GetBuffer()));

                                        cmd.ExecuteNonQuery();
                                    }
                                    tr.Commit();
                                }
                                catch (Exception ex)
                                {
#if MONO
                                    Console.WriteLine("PutImageToCache: " + ex.ToString());
#endif
                                    Debug.WriteLine("PutImageToCache: " + ex.ToString());

                                    tr.Rollback();
                                    ret = false;
                                }
                            }
                        }
                        cn.Close();
                    }
                }
                catch (Exception ex)
                {
#if MONO
                    Console.WriteLine("PutImageToCache: " + ex.ToString());
#endif
                    Debug.WriteLine("PutImageToCache: " + ex.ToString());
                    ret = false;
                }
            }
            return(ret);
        }
Beispiel #55
0
        string MakeTileImageUrl(GPoint pos, int zoom, string language)
        {
            char letter = ServerLetters[GMapProvider.GetServerNum(pos, 3)];

            return(string.Format(UrlFormat, letter, zoom, pos.X, pos.Y));
        }
        string MakeTileImageUrl(GPoint pos, int zoom, string language)
        {
            char letter = ServerLetters[GetServerNum(pos, 3)];

            return(string.Format(MapUrlFormat, zoom, pos.X, pos.Y, letter));
        }
 string MakeTileImageUrl(GPoint pos, int zoom, string language)
 {
     return(string.Format(UrlFormat, zoom, pos.Y, pos.X));
 }
Beispiel #58
0
        public override PureImage GetTileImage(GPoint pos, int zoom)
        {
            string url = MakeTileImageUrl(pos, zoom, LanguageStr);

            return(GetTileImageUsingHttp(url));
        }
Beispiel #59
0
        PureImage PureImageCache.GetImageFromCache(MapType type, GPoint pos, int zoom)
        {
            PureImage ret = null;

            try
            {
                using (SQLiteConnection cn = new SQLiteConnection())
                {
                    cn.ConnectionString = ConnectionString;
                    cn.Open();
                    {
                        if (!string.IsNullOrEmpty(attachSqlQuery))
                        {
                            using (DbCommand com = cn.CreateCommand())
                            {
                                com.CommandText = attachSqlQuery;
                                int x = com.ExecuteNonQuery();
                                //Debug.WriteLine("Attach: " + x);
                            }
                        }

                        using (DbCommand com = cn.CreateCommand())
                        {
                            com.CommandText = string.Format(finnalSqlSelect, pos.X, pos.Y, zoom, (int)type);

                            using (DbDataReader rd = com.ExecuteReader(System.Data.CommandBehavior.SequentialAccess))
                            {
                                if (rd.Read())
                                {
                                    long   length = rd.GetBytes(0, 0, null, 0, 0);
                                    byte[] tile   = new byte[length];
                                    rd.GetBytes(0, 0, tile, 0, tile.Length);
                                    {
                                        if (GMaps.Instance.ImageProxy != null)
                                        {
                                            MemoryStream stm = new MemoryStream(tile, 0, tile.Length, false, true);

                                            ret = GMaps.Instance.ImageProxy.FromStream(stm);
                                            if (ret != null)
                                            {
                                                ret.Data = stm;
                                            }
                                        }
                                    }
                                    tile = null;
                                }
                                rd.Close();
                            }
                        }

                        if (!string.IsNullOrEmpty(detachSqlQuery))
                        {
                            using (DbCommand com = cn.CreateCommand())
                            {
                                com.CommandText = detachSqlQuery;
                                int x = com.ExecuteNonQuery();
                                //Debug.WriteLine("Detach: " + x);
                            }
                        }
                    }
                    cn.Close();
                }
            }
            catch (Exception ex)
            {
#if MONO
                Console.WriteLine("GetImageFromCache: " + ex.ToString());
#endif
                Debug.WriteLine("GetImageFromCache: " + ex.ToString());
                ret = null;
            }

            return(ret);
        }
Beispiel #60
0
        private void BUT_geinjection_Click(object sender, EventArgs e)
        {
            var MainMap = new GMapControl();

            MainMap.MapProvider = GoogleSatelliteMapProvider.Instance;

            MainMap.CacheLocation = Path.GetDirectoryName(Application.ExecutablePath) + "/gmapcache/";

            var fbd = new FolderBrowserDialog();

            try
            {
                fbd.SelectedPath = @"C:\Users\hog\Documents\albany 2011\New folder";
            }
            catch
            {
            }

            if (fbd.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            if (fbd.SelectedPath != "")
            {
                var files  = Directory.GetFiles(fbd.SelectedPath, "*.jpg", SearchOption.AllDirectories);
                var files1 = Directory.GetFiles(fbd.SelectedPath, "*.png", SearchOption.AllDirectories);

                var origlength = files.Length;
                Array.Resize(ref files, origlength + files1.Length);
                Array.Copy(files1, 0, files, origlength, files1.Length);

                foreach (var file in files)
                {
                    log.Info(DateTime.Now.Millisecond + " Doing " + file);
                    var reg = new Regex(@"Z([0-9]+)\\([0-9]+)\\([0-9]+)");

                    var mat = reg.Match(file);

                    if (mat.Success == false)
                    {
                        continue;
                    }

                    var temp = 1 << int.Parse(mat.Groups[1].Value);

                    var pnt = new GPoint(int.Parse(mat.Groups[3].Value), int.Parse(mat.Groups[2].Value));

                    BUT_geinjection.Text = file;
                    BUT_geinjection.Refresh();

                    //MainMap.Projection.

                    var tile = new MemoryStream();

                    var Img = Image.FromFile(file);
                    Img.Save(tile, ImageFormat.Jpeg);

                    tile.Seek(0, SeekOrigin.Begin);
                    log.Info(pnt.X + " " + pnt.Y);

                    Application.DoEvents();

                    GMaps.Instance.PrimaryCache.PutImageToCache(tile.ToArray(), Custom.Instance.DbId, pnt,
                                                                int.Parse(mat.Groups[1].Value));

                    // Application.DoEvents();
                }
            }
        }