]> err.no Git - mapper/commitdiff
Add sport POIs to default categories
authorKaj-Michael Lang <milang@angel.tal.org>
Tue, 23 Oct 2007 17:50:41 +0000 (20:50 +0300)
committerKaj-Michael Lang <milang@angel.tal.org>
Tue, 23 Oct 2007 17:50:41 +0000 (20:50 +0300)
src/poi.c

index f8a174d862af3a417c2667fca91a3685faeab0c0..b73a897bad07d9e3c0c6b37f0d7b5ba5afa414cf 100644 (file)
--- a/src/poi.c
+++ b/src/poi.c
@@ -35,44 +35,77 @@ struct _poi_categories {
 };
 
 static struct _poi_categories default_poi_categories[] = {
-       {NODE_AMENITY_PARKING, "Parking", "Parking place for vehicles."  , "vehicle/parking", "#2020ff" },
-       {NODE_AMENITY_FUEL, "Fuel", "Stations for purchasing fuel for vehicles."  , "vehicle/fuel_station", "#4040f0" },
-       {NODE_AMENITY_SPEEDCAM, "Speed Cam", "Automatic speed cameras."  , "vehicle/restrictions/speed_trap", "#ff0000" },
-       {NODE_AMENITY_HOSPITAL, "Hospital", ""  , "health/hospital", "#ff4040" },
-       {NODE_AMENITY_PHARMACY, "Pharmacy", "Place to get drugs."  , "health/pharmacy", "#40f040" },
-       {NODE_AMENITY_POLICE, "Police", "Police station" , "public/police", "#8570ff" },
-       {NODE_AMENITY_HOTEL, "Hotel", "Places to stay temporarily or for the night." , "accommodation/hotel", "#ba20ba" },
-       {NODE_AMENITY_HOSTEL, "Hostel", "Places to stay temporarily or for the night. Cheap." , "accommodation/hostel", "#ba30ba" },
-       {NODE_AMENITY_MOTEL, "Motel", "Places to stay temporarily or for the night. Cheap." , "accommodation/motel", "#ba40ba" },
-       {NODE_AMENITY_ATM, "ATM", "Automatic Teller Machine/Cashpoint." , "money/atm", "#40a040" },
-       {NODE_AMENITY_BANK, "Bank", "Place to take care of your money." , "money/bank", "#50b550" },
-       {NODE_AMENITY_POST, "Post office", "Place to handle mail." , "public/post_office", "#ff6868" },
-       {NODE_AMENITY_POST_BOX, "Post box", "Send letters." , "public/post_box", "#ff6060" },
-       {NODE_AMENITY_TOURISM_INFO, "Tourism info", "A place for tourists to get information." , "misc/information", "#4af04a" },
-       {NODE_AMENITY_TAXI, "Taxi station", "Get a Taxi here." , "", "#50ffff" },
-       {NODE_AMENITY_RAILWAY_STATION, "Railway station", "Transportation by train." , "transport/railway", "#fa7070" },
-       {NODE_AMENITY_RAILWAY_HALT, "Railway halt", "" , "transport/railway_small", "#f27777" },
-       {NODE_AMENITY_BUS_STATION, "Bus station", "Transportation by bus." , "transport/bus", "#f07070" },
-       {NODE_AMENITY_BOAT, "Harbour", "Transportation by boat." , "transport/ferry", "#9090ee" },
-       {NODE_AMENITY_AIRPORT, "Airport", "Transportation by air." , "transport/airport", "#909099" },
-       {NODE_AMENITY_CAMP_SITE, "Camp site", "Place to go camping" , "accommodation/camping", "#90f080" },
-       {NODE_AMENITY_CARAVAN_SITE, "Caravan site", "" , "accommodation/camping/caravan", "#90ff80" },
-       {NODE_AMENITY_PICNIC_SITE, "Picnic", "Place to have a Picnic" , "recreation/picnic", "#a5f8e5" },
-       {NODE_AMENITY_FOOD, "Restaurant, Fast food", "Places to eat or drink." , "food/fastfood", "#e5960d" },
-       {NODE_AMENITY_PUB, "Pub, Disco, Club", "Place to drink and party." , "food/pub", "#f5960d" },
-       {NODE_AMENITY_CAFE, "Cafe", "Place to drink coffe or tee and eat." , "food/cafe", "#ff960d" },
-       {NODE_AMENITY_CINEMA, "Cinema", "Place to see movies" , "recreation/cinema", "#9090a0" },
-       {NODE_AMENITY_THEATRE, "Theatre", "Place to see people performing" , "recreation/theater", "#9595a5" },
-       {NODE_AMENITY_SHOP, "Shopping", "Places to shop or acquire services." , "shopping", "#61ef1b" },
-       {NODE_AMENITY_POW, "Place of Worchip", "" , "religion/church", "#7c5b0b" },
-       {NODE_AMENITY_THEME_PARK, "Theme Park", "Place to have fun and ride for example rollercoasters." , "recreation/theme_park", "#8eef1b" },
-       {NODE_AMENITY_COLLEGE, "College Campus/Building", "" , "education/college", "#813fdc" },
-       {NODE_AMENITY_SCHOOL, "School", "" , "education/school", "#813fdc" },
-       {NODE_AMENITY_WC, "WC/Toilets", "" , "public/toilets", "#e1d62c" },
-       {NODE_AMENITY_TELEPHONE, "Telephone", "Public telephone" , "public/telephone", "#208060" },
-       {NODE_AMENITY_ATTRACTION, "Attraction", "Something interesting" , "generic", "#004000" },
-       {NODE_AMENITY_GENERIC, "Other", "Miscellaneous category for everything else." , "generic", "#002000" },
-       {NODE_POI_END, NULL, NULL }
+       { NODE_AMENITY_PARKING, "Parking", "Parking place for vehicles."  , "vehicle/parking", "#2020ff" },
+       { NODE_AMENITY_FUEL, "Fuel", "Stations for purchasing fuel for vehicles."  , "vehicle/fuel_station", "#4040f0" },
+       { NODE_AMENITY_SPEEDCAM, "Speed Cam", "Automatic speed cameras."  , "vehicle/restrictions/speed_trap", "#ff0000" },
+       { NODE_AMENITY_HOSPITAL, "Hospital", ""  , "health/hospital", "#ff4040" },
+       { NODE_AMENITY_PHARMACY, "Pharmacy", "Place to get drugs."  , "health/pharmacy", "#40f040" },
+       { NODE_AMENITY_POLICE, "Police", "Police station" , "public/police", "#8570ff" },
+       { NODE_TOURISM_HOTEL, "Hotel", "Places to stay temporarily or for the night." , "accommodation/hotel", "#ba20ba" },
+       { NODE_TOURISM_HOSTEL, "Hostel", "Places to stay temporarily or for the night. Cheap." , "accommodation/hostel", "#ba30ba" },
+       { NODE_TOURISM_MOTEL, "Motel", "Places to stay temporarily or for the night. Cheap." , "accommodation/motel", "#ba40ba" },
+       { NODE_AMENITY_ATM, "ATM", "Automatic Teller Machine/Cashpoint." , "money/atm", "#40a040" },
+       { NODE_AMENITY_BANK, "Bank", "Place to take care of your money." , "money/bank", "#50b550" },
+       { NODE_AMENITY_POST, "Post office", "Place to handle mail." , "public/post_office", "#ff6868" },
+       { NODE_AMENITY_POST_BOX, "Post box", "Send letters." , "public/post_box", "#ff6060" },
+       { NODE_TOURISM_INFO, "Tourism info", "A place for tourists to get information." , "misc/information", "#4af04a" },
+       { NODE_AMENITY_TAXI, "Taxi station", "Get a Taxi here." , "", "#50ffff" },
+       { NODE_RAILWAY_STATION, "Railway station", "Transportation by train." , "transport/railway", "#fa7070" },
+       { NODE_RAILWAY_HALT, "Railway halt", "" , "transport/railway_small", "#f27777" },
+       { NODE_AMENITY_BUS_STATION, "Bus station", "Transportation by bus." , "transport/bus", "#f07070" },
+       { NODE_AMENITY_BOAT, "Harbour", "Transportation by boat." , "transport/ferry", "#9090ee" },
+       { NODE_AIRPORT_TERMINAL, "Airport", "Transportation by air." , "transport/airport", "#909099" },
+       { NODE_TOURISM_CAMP_SITE, "Camp site", "Place to go camping" , "accommodation/camping", "#90f080" },
+       { NODE_TOURISM_CARAVAN_SITE, "Caravan site", "" , "accommodation/camping/caravan", "#90ff80" },
+       { NODE_TOURISM_PICNIC_SITE, "Picnic", "Place to have a Picnic" , "recreation/picnic", "#a5f8e5" },
+       { NODE_AMENITY_FOOD, "Restaurant, Fast food", "Places to eat or drink." , "food/fastfood", "#e5960d" },
+       { NODE_AMENITY_PUB, "Pub, Disco, Club", "Place to drink and party." , "food/pub", "#f5960d" },
+       { NODE_AMENITY_CAFE, "Cafe", "Place to drink coffe or tee and eat." , "food/cafe", "#ff960d" },
+       { NODE_AMENITY_CINEMA, "Cinema", "Place to see movies" , "recreation/cinema", "#9090a0" },
+       { NODE_AMENITY_THEATRE, "Theatre", "Place to see people performing" , "recreation/theater", "#9595a5" },
+       { NODE_AMENITY_SHOP, "Shopping", "Places to shop or acquire services." , "shopping", "#61ef1b" },
+       { NODE_AMENITY_POW, "Place of Worchip", "" , "religion/church", "#7c5b0b" },
+       { NODE_TOURISM_THEME_PARK, "Theme Park", "Place to have fun and ride for example rollercoasters." , "recreation/theme_park", "#8eef1b" },
+       { NODE_AMENITY_COLLEGE, "College Campus/Building", "" , "education/college", "#813fdc" },
+       { NODE_AMENITY_SCHOOL, "School", "" , "education/school", "#813fdc" },
+       { NODE_AMENITY_WC, "WC/Toilets", "" , "public/toilets", "#e1d62c" },
+       { NODE_AMENITY_TELEPHONE, "Telephone", "Public telephone" , "public/telephone", "#208060" },
+       { NODE_TOURISM_ATTRACTION, "Attraction", "Something interesting" , "generic", "#004000" },
+
+       { NODE_SPORT_CENTER, "Sport Center", "" , "sports/centre", "#101080" },
+       { NODE_SPORT_STADIUM, "Sport Stadium", "" , "sports/stadium", "#101080" },
+       { NODE_SPORT_SKIING, "Skiing", "" , "sports/skiing", "#5050A0" },
+       { NODE_SPORT_SWIMMING, "Swimming", "" , "sports/swimming", "#102080" },
+       { NODE_SPORT_FOOTBALL, "Football", "" , "sports/football", "#102080" },
+       { NODE_SPORT_SOCCER, "Soccer", "" , "sports/soccer", "#102080" },
+       { NODE_SPORT_GOLF, "Golf", "" , "sports/golf", "#102080" },
+       { NODE_SPORT_TENNIS, "Tennis", "" , "sports/tennis", "#101080" },
+       { NODE_SPORT_BOWLING, "Bowling", "" , "", "#101080" },
+       { NODE_SPORT_RUGBY, "Rugby", "" , "", "#101080" },
+       { NODE_SPORT_CLIMBING, "Climbing", "" , "", "#101080" },
+       { NODE_SPORT_CYCLING, "Cycling", "" , "sports/bicycle", "#101080" },
+       { NODE_SPORT_MOTOR, "Motor sport", "" , "", "#101080" },
+       { NODE_SPORT_HOCKEY, "Hockey", "" , "", "#5050A0" },
+       { NODE_SPORT_SKATING, "Skating", "" , "", "#5050A0" },
+       { NODE_SPORT_SKATEBOARD, "Skateboard", "" , "", "#101080" },
+       { NODE_SPORT_HORSES, "Horses", "Horse riding or racing" , "sports/riding", "#101080" },
+       { NODE_SPORT_DOG, "Dog racing", "" , "", "#101080" },
+       { NODE_SPORT_BASKETBALL, "Basketball", "" , "", "#101080" },
+       { NODE_SPORT_BASEBALL, "Baseball", "" , "", "#101080" },
+       { NODE_SPORT_CANOE, "Canoe", "" , "", "#101080" },
+       { NODE_SPORT_CROQUET, "Croquet", "" , "", "#101080" },
+       { NODE_SPORT_CRICKET, "Cricket", "" , "", "#101080" },
+       { NODE_SPORT_SHOOTING, "Shooting", "Shooting range" , "", "#101080" },
+       { NODE_SPORT_PAINTBALL, "Paintball", "Run around and shoot people with paintballs" , "", "#101080" },
+       { NODE_SPORT_TABLE_TENNIS, "Table tennis", "" , "", "#101080" },
+       { NODE_SPORT_PELOTA, "Pelota", "" , "", "#101080" },
+       { NODE_SPORT_RACQUET, "Racquet", "" , "sports/racquetball", "#101080" },
+       { NODE_SPORT_BOWLS, "Lawn Bowls", "" , "", "#101080" },
+       { NODE_SPORT_ATHLETICS, "Athletics", "" , "", "#101080" },
+       { NODE_SPORT_OTHER, "Other Sports", "" , "", "#101077" },
+
+       { NODE_AMENITY_GENERIC, "Other", "Miscellaneous category for everything else." , "generic", "#002000" },
+       { NODE_POI_END, NULL, NULL }
 };
 
 static gboolean
@@ -107,49 +140,51 @@ return TRUE;
 gboolean
 poi_db_create(sqlite3 *db)
 {
-       gchar **pszResult;
-       guint nRow, nColumn;
-       if (SQLITE_OK != sqlite3_get_table(db, "select label from poi limit 1",
-                                          &pszResult, &nRow, &nColumn, NULL)) {
-               gchar *create_sql;
-
-               g_printf("Creating initial tables\n");
-
-               create_sql = sqlite3_mprintf
-                   ("create table poi "
-                       "(poi_id integer PRIMARY KEY, "
-                       "lat real, "
-                       "lon real, "
-                       "elev real, "
-                       "label text, "
-                       "desc text, "
-                       "public integer, "
-                       "source integer default 0, "
-                       "osm_id integer default 0, "
-                       "priority integer default 2, "
-                       "cat_id integer);"
-                    "create table category (cat_id integer PRIMARY KEY,"
-                       "label text, "
-                       "desc text, "
-                       "icon text, "
-                       "color char(7), "
-                       "priority integer default 2, "
-                       "enabled integer);");
-
-               if (SQLITE_OK != sqlite3_exec(db, create_sql, NULL, NULL, NULL)
-                   && (SQLITE_OK != sqlite3_get_table(db, "select label from poi limit 1",
-                                         &pszResult, &nRow, &nColumn, NULL))) {
-                       g_printf("%s:\n%s",_("Failed to open or create database"),sqlite3_errmsg(db));
-                       sqlite3_close(db);
-                       db = NULL;
-                       return FALSE;
-               }
-       } else
-               sqlite3_free_table(pszResult);
+gchar **pszResult;
+guint nRow, nColumn;
+
+if (SQLITE_OK != sqlite3_get_table(db, "select label from poi limit 1",
+                                  &pszResult, &nRow, &nColumn, NULL)) {
+       gchar *create_sql;
+
+       g_printf("Creating initial tables\n");
+
+       create_sql = sqlite3_mprintf
+           ("create table poi "
+               "(poi_id integer PRIMARY KEY, "
+               "lat real, "
+               "lon real, "
+               "elev real, "
+               "label text, "
+               "desc text, "
+               "public integer, "
+               "source integer default 0, "
+               "osm_id integer default 0, "
+               "priority integer default 2, "
+               "cat_id integer);"
+            "create table category (cat_id integer PRIMARY KEY,"
+               "label text, "
+               "desc text, "
+               "icon text, "
+               "color char(7), "
+               "priority integer default 2, "
+               "enabled integer);");
+
+       if (SQLITE_OK != sqlite3_exec(db, create_sql, NULL, NULL, NULL)
+           && (SQLITE_OK != sqlite3_get_table(db, "select label from poi limit 1",
+                                 &pszResult, &nRow, &nColumn, NULL))) {
+               g_printf("%s:\n%s",_("Failed to open or create database"),sqlite3_errmsg(db));
+               sqlite3_close(db);
+               db = NULL;
+               return FALSE;
+       }
+} else {
+       sqlite3_free_table(pszResult);
+}
 
-       /* Make sure default categories exists */
-       poi_populate_categories(db);
-       return TRUE;
+/* Make sure default categories exists */
+poi_populate_categories(db);
+return TRUE;
 }
 
 gboolean
@@ -273,11 +308,15 @@ mapper_db_connect(sqlite3 **db, const gchar *data_db)
 {
 if (db_connect(db, data_db)) {
        poi_db_create(*db);
-       if (poi_db_prepare(*db)==FALSE)
-               g_printerr("Failed to prepare POI SQL statements");
+       if (poi_db_prepare(*db)==FALSE) {
+               g_printerr("Failed to prepare POI SQL statements:");
+               g_printf("SQLITE: %s\n", sqlite3_errmsg(*db));
+               return FALSE;
+       }
        if (osm_db_prepare(*db)==FALSE) {
-               g_printerr("Failed to prepare OSM SQL statements");
+               g_printerr("Failed to prepare OSM SQL statements:");
                g_printf("SQLITE: %s\n", sqlite3_errmsg(*db));
+               return FALSE;
        }
        return TRUE;
 }
@@ -296,6 +335,11 @@ poi_free(poi_info *p)
 g_slice_free(poi_info, p);
 }
 
+/*************************************
+ * POI Category functions
+ *
+ */
+
 poi_category *
 poi_category_new(void)
 {
@@ -553,6 +597,9 @@ poi_category_generate_store()
 GtkTreeIter iter;
 GtkListStore *store;
 
+if (!_db)
+       return NULL;
+
 store = gtk_list_store_new(CAT_NUM_COLUMNS,
                           G_TYPE_UINT,
                           G_TYPE_BOOLEAN,