]>
Commit | Line | Data |
---|---|---|
1 | #include <math.h> | |
2 | #include <vikwmscmapsource.h> | |
3 | #include <vikslippymapsource.h> | |
4 | ||
5 | void test_coord_to_mapcoord(VikMapSource *source, gdouble lat, gdouble lon, gdouble zoom) | |
6 | { | |
7 | VikCoord vikCoord; | |
8 | MapCoord mapCoord; | |
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); | |
15 | } | |
16 | ||
17 | void test_mapcoord_to_center_coord (VikMapSource *source, int x, int y, int scale) | |
18 | { | |
19 | VikCoord vikCoord; | |
20 | MapCoord mapCoord; | |
21 | mapCoord.x = x; | |
22 | mapCoord.y = y; | |
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); | |
27 | } | |
28 | ||
29 | int main(int argc, char *argv[]) | |
30 | { | |
31 | g_type_init(); | |
32 | ||
33 | VikMapSource *spotmaps4osm_wmsc_type = | |
34 | VIK_MAP_SOURCE(g_object_new(VIK_TYPE_WMSC_MAP_SOURCE, | |
35 | "id", 202, | |
36 | "label", "Spotmaps (WMS-C)", | |
37 | "hostname", "spotmaps.youmapps.org", | |
38 | "url", "/spotmaps4osm/?LAYERS=spotmaps4osm&SERVICE=SPOTMAPS4OSM&SRS=EPSG:4326&bbox=%s,%s,%s,%s&width=256&height=256", | |
39 | NULL)); | |
40 | ||
41 | VikMapSource *osmarender_type = | |
42 | VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE, | |
43 | "id", 12, | |
44 | "label", "OpenStreetMap (Osmarender)", | |
45 | "hostname", "tah.openstreetmap.org", | |
46 | "url", "/Tiles/tile/%d/%d/%d.png", | |
47 | "check-file-server-time", TRUE, | |
48 | NULL)); | |
49 | ||
50 | gdouble lats[] = { 0, 90, 45, -45, -90 }; | |
51 | gdouble lons[] = { 0, 180, 90, 45, -45, -90, -180 }; | |
52 | int scale; | |
53 | for (scale = 0 ; scale < 18 ; scale++) | |
54 | { | |
55 | int i; | |
56 | for (i=0 ; i<sizeof(lats)/sizeof(lats[0]) ; i++) | |
57 | { | |
58 | int j; | |
59 | for (j=0 ; j<sizeof(lons)/sizeof(lons[0]) ; j++) | |
60 | { | |
61 | test_coord_to_mapcoord (spotmaps4osm_wmsc_type, lats[i], lons[j], 2<<scale); | |
62 | test_coord_to_mapcoord (osmarender_type, lats[i], lons[j], 2<<scale); | |
63 | } | |
64 | } | |
65 | } | |
66 | ||
67 | for (scale = 0 ; scale < 18 ; scale++) | |
68 | { | |
69 | test_mapcoord_to_center_coord (spotmaps4osm_wmsc_type, 0, 0, scale); | |
70 | test_mapcoord_to_center_coord (osmarender_type, 0, 0, scale); | |
71 | } | |
72 | ||
73 | return 0; | |
74 | } |