X-Git-Url: https://git.street.me.uk/andy/viking.git/blobdiff_plain/124ed81472bba381054f5c2502e1ba6ff9f1abcf..a29212b08440e5a50314a40f33f343942fcbcc51:/src/google-map-type.gob diff --git a/src/google-map-type.gob b/src/google-map-type.gob index a5cff338..33f9059e 100644 --- a/src/google-map-type.gob +++ b/src/google-map-type.gob @@ -38,10 +38,14 @@ typedef enum { TYPE_GOOGLE_NUM } GoogleType; +const gchar *google_version_number(MapCoord *mapcoord, GoogleType google_type); + %} %{ +static DownloadOptions google_options = { "http://maps.google.com/", 0, a_check_map_file }; + /* 1 << (x) is like a 2**(x) */ #define GZ(x) ((1<scale); + dest->mode = VIK_COORD_LATLON; + dest->east_west = ((src->x+0.5) / GZ(17) * socalled_mpp * 360) - 180; + dest->north_south = DEMERCLAT(180 - ((src->y+0.5) / GZ(17) * socalled_mpp * 360)); +} static gchar *parse_version_number(gchar *text) { @@ -76,7 +87,7 @@ static gchar *parse_version_number(gchar *text) return vers = g_strndup(s, i); } -static const gchar *google_version_number(MapCoord *mapcoord, GoogleType google_type) +const gchar *google_version_number(MapCoord *mapcoord, GoogleType google_type) { static gboolean first = TRUE; static char *vers[] = { "w2.80", "w2t.80", "30", "w2p.81"}; @@ -188,6 +199,35 @@ failed: class Google:Map:Type from Vik:Map:Type { private GoogleType type; + init (self) { + /* initialize the object here */ + VIK_MAP_TYPE(self)->tilesize_x = 256; + VIK_MAP_TYPE(self)->tilesize_y = 256; + VIK_MAP_TYPE(self)->drawmode = VIK_VIEWPORT_DRAWMODE_MERCATOR; + } + + public GObject * + new_with_id (guint8 id, GoogleType type) { + GoogleMapType *ret = GET_NEW; + VIK_MAP_TYPE(ret)->uniq_id = id; + ret->_priv->type = type; + return G_OBJECT (ret); + } + + virtual gchar * + get_uri( self, MapCoord *src ) + { + const gchar *verstr = google_version_number(src, GOOGLE_MAP_TYPE(self)->_priv->type); + gchar *uri = g_strdup_printf ( "/mt?n=404&v=%s&x=%d&y=%d&zoom=%d", verstr, src->x, src->y, src->scale ); + return uri; + } + + virtual gchar * + get_hostname( self ) + { + return g_strdup("mt.google.com"); + } + override (Vik:Map:Type) gboolean coord_to_mapcoord ( Vik:Map:Type *self, const VikCoord *src, gdouble xzoom, gdouble yzoom, MapCoord *dest ) { @@ -219,7 +259,12 @@ class Google:Map:Type from Vik:Map:Type { override (Vik:Map:Type) int download ( Vik:Map:Type *self, MapCoord *src, const gchar *dest_fn ) { - const gchar *vers_str = google_version_number(src, GOOGLE_MAP_TYPE(self)->_priv->type); - return(real_google_download ( src, dest_fn, vers_str )); + int res; + gchar *uri = google_map_type_get_uri(GOOGLE_MAP_TYPE(self), src); + gchar *host = google_map_type_get_hostname(GOOGLE_MAP_TYPE(self)); + res = a_http_download_get_url ( host, uri, dest_fn, &google_options ); + g_free ( uri ); + g_free ( host ); + return res; } } \ No newline at end of file