2 #include <vikwmscmapsource.h>
3 #include <vikslippymapsource.h>
5 void test_coord_to_mapcoord(VikMapSource
*source
, gdouble lat
, gdouble lon
, gdouble zoom
)
9 vikCoord
.mode
= VIK_COORD_LATLON
;
10 vikCoord
.east_west
= lon
;
11 vikCoord
.north_south
= lat
;
12 printf("%s: %f %f %f => ", g_type_name(G_OBJECT_TYPE(source
)), vikCoord
.east_west
, vikCoord
.north_south
, zoom
);
13 vik_map_source_coord_to_mapcoord (source
, &vikCoord
, zoom
, zoom
, &mapCoord
);
14 printf("x=%d y=%d\n", mapCoord
.x
, mapCoord
.y
);
17 void test_mapcoord_to_center_coord (VikMapSource
*source
, int x
, int y
, int scale
)
23 mapCoord
.scale
= scale
;
24 printf("%s: %d %d %d => ", g_type_name(G_OBJECT_TYPE(source
)), mapCoord
.x
, mapCoord
.y
, scale
);
25 vik_map_source_mapcoord_to_center_coord (source
, &mapCoord
, &vikCoord
);
26 printf("lon=%f lat=%f\n", vikCoord
.east_west
, vikCoord
.north_south
);
29 int main(int argc
, char *argv
[])
31 #if ! GLIB_CHECK_VERSION (2, 36, 0)
35 VikMapSource
*spotmaps4osm_wmsc_type
=
36 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_WMSC_MAP_SOURCE
,
38 "label", "Spotmaps (WMS-C)",
39 "hostname", "spotmaps.youmapps.org",
40 "url", "/spotmaps4osm/?LAYERS=spotmaps4osm&SERVICE=SPOTMAPS4OSM&SRS=EPSG:4326&bbox=%s,%s,%s,%s&width=256&height=256",
43 VikMapSource
*osmarender_type
=
44 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE
,
46 "label", "OpenStreetMap (Osmarender)",
47 "hostname", "tah.openstreetmap.org",
48 "url", "/Tiles/tile/%d/%d/%d.png",
49 "check-file-server-time", TRUE
,
52 gdouble lats
[] = { 0, 90, 45, -45, -90 };
53 gdouble lons
[] = { 0, 180, 90, 45, -45, -90, -180 };
55 for (scale
= 0 ; scale
< 18 ; scale
++)
58 for (i
=0 ; i
<sizeof(lats
)/sizeof(lats
[0]) ; i
++)
61 for (j
=0 ; j
<sizeof(lons
)/sizeof(lons
[0]) ; j
++)
63 test_coord_to_mapcoord (spotmaps4osm_wmsc_type
, lats
[i
], lons
[j
], 2<<scale
);
64 test_coord_to_mapcoord (osmarender_type
, lats
[i
], lons
[j
], 2<<scale
);
69 for (scale
= 0 ; scale
< 18 ; scale
++)
71 test_mapcoord_to_center_coord (spotmaps4osm_wmsc_type
, 0, 0, scale
);
72 test_mapcoord_to_center_coord (osmarender_type
, 0, 0, scale
);