Add missing trailing dot in sentences
[viking/guyou.git] / test / test_coord_conversion.c
blob85781e4762106bc95dd3a30d49165f69a1868ce8
1 #include <math.h>
2 #include <vikwmscmapsource.h>
3 #include <vikslippymapsource.h>
5 void test_coord_to_mapcoord(VikMapSource *source, gdouble lat, gdouble lon, gdouble zoom)
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);
17 void test_mapcoord_to_center_coord (VikMapSource *source, int x, int y, int scale)
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);
29 int main(int argc, char *argv[])
31 #if ! GLIB_CHECK_VERSION (2, 36, 0)
32 g_type_init();
33 #endif
35 VikMapSource *spotmaps4osm_wmsc_type =
36 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_WMSC_MAP_SOURCE,
37 "id", 202,
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",
41 NULL));
43 VikMapSource *osmarender_type =
44 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
45 "id", 12,
46 "label", "OpenStreetMap (Osmarender)",
47 "hostname", "tah.openstreetmap.org",
48 "url", "/Tiles/tile/%d/%d/%d.png",
49 "check-file-server-time", TRUE,
50 NULL));
52 gdouble lats[] = { 0, 90, 45, -45, -90 };
53 gdouble lons[] = { 0, 180, 90, 45, -45, -90, -180 };
54 int scale;
55 for (scale = 0 ; scale < 18 ; scale++)
57 int i;
58 for (i=0 ; i<sizeof(lats)/sizeof(lats[0]) ; i++)
60 int j;
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);
75 return 0;