From: <pg...@us...> - 2015-10-20 15:08:24
|
Revision: 2993 http://sourceforge.net/p/roadmap/code/2993 Author: pgf Date: 2015-10-20 15:08:22 +0000 (Tue, 20 Oct 2015) Log Message: ----------- buildmap_osm layers: clean up / simplify the layer configuration code Modified Paths: -------------- trunk/roadmap/src/buildmap_osm_layers.h trunk/roadmap/src/buildmap_osm_text.c Modified: trunk/roadmap/src/buildmap_osm_layers.h =================================================================== --- trunk/roadmap/src/buildmap_osm_layers.h 2015-10-20 15:08:19 UTC (rev 2992) +++ trunk/roadmap/src/buildmap_osm_layers.h 2015-10-20 15:08:22 UTC (rev 2993) @@ -27,14 +27,14 @@ #define ANY 7 typedef struct { - char *osm_vname; + char *value; int *layerp; int flags; } value_info_t; typedef struct { - char *osm_tname; - value_info_t *value_list; + char *tag; + value_info_t *value_table; } tag_info_t; @@ -52,15 +52,7 @@ }; -BuildMapDictionary DictionaryPrefix; -BuildMapDictionary DictionaryStreet; -BuildMapDictionary DictionaryType; -BuildMapDictionary DictionarySuffix; -BuildMapDictionary DictionaryCity; - - value_info_t highway_to_layer[] = { - { 0, NULL, 0 }, { "motorway", &Freeways, LINE }, { "motorway_link", &Freeways, LINE }, { "trunk", &Freeways, LINE }, @@ -73,6 +65,8 @@ { "minor", &Streets, LINE }, { "residential", &Streets, LINE }, { "service", &Streets, LINE }, + { "road", &Streets, LINE }, + { "secondary_link", &Streets, LINE }, { "track", &Trails, LINE }, { "cycleway", &Trails, LINE }, { "bridleway", &Trails, LINE }, @@ -80,14 +74,11 @@ { "steps", &Trails, LINE }, { "pedestrian", &Trails, LINE }, { "pathway", &Trails, LINE }, - { "road", &Streets, LINE }, - { "secondary_link", &Streets, LINE }, { "path", &Trails, LINE }, { 0, NULL, 0 }, }; value_info_t cycleway_to_layer[] = { - { 0, NULL, 0 }, { "lane", &Trails, LINE }, { "track", &Trails, LINE }, { "opposite_lane", &Trails, LINE }, @@ -96,21 +87,18 @@ }; value_info_t aeroway_to_layer[] = { - { 0, NULL, 0 }, { "runway", &Airports, AREA }, { "aerodrome", &Airports, AREA }, { 0, NULL, 0 }, }; value_info_t landuse_to_layer[] = { - { 0, NULL, 0 }, { "reservoir", &Lakes, AREA }, { "conservation", &Nature, AREA }, { 0, NULL, 0 }, }; value_info_t waterway_to_layer[] = { - { 0, NULL, 0 }, { "river", &Rivers, LINE }, { "canal", &Rivers, LINE }, { "stream", &Rivers, LINE }, @@ -131,7 +119,6 @@ }; value_info_t railway_to_layer[] = { - { 0, NULL, 0 }, { "rail", &Railroads, LINE }, { "tram", &Railroads, LINE }, { "light_rail", &Railroads, LINE }, @@ -152,7 +139,6 @@ }; value_info_t natural_to_layer[] = { - { 0, NULL, 0 }, { "coastline", &Shore, LINE }, { "water", &Lakes, AREA }, { "wood", &Nature, AREA }, @@ -162,28 +148,25 @@ }; value_info_t amenity_to_layer[] = { - { 0, NULL, 0 }, + { "school", &Schools, AREA }, + { "university", &Schools, AREA }, + { "college", &Schools, AREA }, { "hospital", &Hospitals, LINE }, { "pub", &Drinks, PLACE }, - // { "parking", &Parking, AREA }, { "fuel", &Fuel, PLACE }, - { "school", &Schools, AREA }, { "restaurant", &Food, PLACE }, { "fast_food", &Food, PLACE }, + { "food_court", &Food, PLACE }, { "cafe", &Cafe, PLACE }, { "grave_yard", &Parks, AREA }, - { "university", &Schools, AREA }, - { "college", &Schools, AREA }, - { "food_court", &Food, PLACE }, - { "bbq", &Food, PLACE }, { "bar", &Drinks, PLACE }, { "biergarten", &Drinks, PLACE }, { "atm", &ATM, PLACE }, + // { "parking", &Parking, AREA }, { 0, NULL, 0 }, }; value_info_t place_to_layer[] = { - { 0, NULL, 0 }, { "city", &City, PLACE }, { "town", &Town, PLACE }, { "village", &Village, PLACE }, @@ -194,7 +177,6 @@ }; value_info_t leisure_to_layer[] = { - { 0, NULL, 0 }, { "park", &Parks, AREA }, { "common", &Parks, AREA }, { "garden", &Parks, AREA }, @@ -207,15 +189,11 @@ }; value_info_t historic_to_layer[] = { - { 0, NULL, 0 }, { "castle", &Castle, PLACE }, - // { "archaeological_site",NULL, AREA }, - // { "ruins", NULL, AREA }, { 0, NULL, 0 }, }; value_info_t tourism_to_layer[] = { - { 0, NULL, 0 }, { "hotel", &Hotel, PLACE }, { "motel", &Motel, PLACE }, { "guest_house", &Guesthouse, PLACE }, @@ -225,10 +203,7 @@ }; -/* set the third column to a specific type only if that table - * contains _only_ that type */ -tag_info_t tag_info[] = { - {0, NULL }, +tag_info_t tag_table[] = { {"highway", highway_to_layer }, {"cycleway", cycleway_to_layer }, {"waterway", waterway_to_layer }, Modified: trunk/roadmap/src/buildmap_osm_text.c =================================================================== --- trunk/roadmap/src/buildmap_osm_text.c 2015-10-20 15:08:19 UTC (rev 2992) +++ trunk/roadmap/src/buildmap_osm_text.c 2015-10-20 15:08:22 UTC (rev 2993) @@ -125,6 +125,13 @@ static int l_shoreline, l_boundary, l_lake, l_river, l_island; static int nRels, nWays, nNodes; +static BuildMapDictionary DictionaryPrefix; +static BuildMapDictionary DictionaryStreet; +static BuildMapDictionary DictionaryType; +static BuildMapDictionary DictionarySuffix; +static BuildMapDictionary DictionaryCity; + + /** * @brief add string to dictionary, taking note of null inputs * @param d @@ -458,10 +465,11 @@ /** - * @brief checks to see if the tag and value found in the input data - * corresponds to a layer we're interested in recording in the map. - * the layer is returned if so (but we don't touch it if not). the - * returned flags indicate what sort of layer this is (LINE, PLACE, AREA). + * @brief looks up the layer corresponding to a tag/value pair. + * only layers we might be interested in rendering on the + * map will be in the tables. if a match is found, the layer + * is returned (but we don't touch the return parameter if not). the + * the returned flags indicate the layer type (LINE, PLACE, AREA). * @param lookfor limits the search to matching types (LINE, PLACE, AREA) */ @@ -469,21 +477,18 @@ buildmap_osm_get_layer(int lookfor, const char *tag, const char *value, int *flags, int *layer) { - int i,j; - value_info_t *value_list; + value_info_t *v; + tag_info_t *t; - for (i=1; tag_info[i].osm_tname != 0; i++) { - if (strcmp(tag, tag_info[i].osm_tname) == 0) { - value_list = tag_info[i].value_list; - if (value_list) { - for (j=1; value_list[j].osm_vname; j++) { - if ((lookfor & value_list[j].flags) && - strcmp(value, value_list[j].osm_vname) == 0) { - *flags = value_list[j].flags; - if (value_list[j].layerp) - *layer = *(value_list[j].layerp); - return 1; - } + for (t = tag_table; t->tag != 0; t++) { + if (strcmp(tag, t->tag) == 0) { + v = t->value_table; + for (v = t->value_table; v->value != 0; v++) { + if ((lookfor & v->flags) && strcmp(value, v->value) == 0) { + *flags = v->flags; + if (v->layerp) + *layer = *v->layerp; + return 1; } } break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |