You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(92) |
Dec
(141) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(126) |
Feb
(72) |
Mar
(31) |
Apr
(200) |
May
(81) |
Jun
(130) |
Jul
(112) |
Aug
(134) |
Sep
(76) |
Oct
(89) |
Nov
(153) |
Dec
(9) |
2007 |
Jan
(59) |
Feb
(82) |
Mar
(50) |
Apr
(20) |
May
(9) |
Jun
(81) |
Jul
(41) |
Aug
(109) |
Sep
(91) |
Oct
(87) |
Nov
(33) |
Dec
(60) |
2008 |
Jan
(21) |
Feb
(15) |
Mar
(38) |
Apr
(75) |
May
(59) |
Jun
(46) |
Jul
(30) |
Aug
(20) |
Sep
(35) |
Oct
(32) |
Nov
(34) |
Dec
(19) |
2009 |
Jan
(29) |
Feb
(71) |
Mar
(54) |
Apr
(17) |
May
(4) |
Jun
|
Jul
(3) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(3) |
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(3) |
Aug
(58) |
Sep
(7) |
Oct
(7) |
Nov
(12) |
Dec
(18) |
2011 |
Jan
(17) |
Feb
(29) |
Mar
(11) |
Apr
(5) |
May
(1) |
Jun
|
Jul
|
Aug
(11) |
Sep
|
Oct
|
Nov
|
Dec
|
2012 |
Jan
(2) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(87) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(44) |
Jun
(79) |
Jul
(16) |
Aug
(31) |
Sep
|
Oct
(51) |
Nov
|
Dec
|
2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
From: <pg...@us...> - 2015-10-20 15:06:12
|
Revision: 2949 http://sourceforge.net/p/roadmap/code/2949 Author: pgf Date: 2015-10-20 15:06:09 +0000 (Tue, 20 Oct 2015) Log Message: ----------- roadmap_main.c: compiler warning suppression Modified Paths: -------------- trunk/roadmap/src/gtk2/roadmap_main.c Modified: trunk/roadmap/src/gtk2/roadmap_main.c =================================================================== --- trunk/roadmap/src/gtk2/roadmap_main.c 2015-10-20 15:06:06 UTC (rev 2948) +++ trunk/roadmap/src/gtk2/roadmap_main.c 2015-10-20 15:06:09 UTC (rev 2949) @@ -190,7 +190,7 @@ */ static void special_keypad_arrow_treatment(int keyval) { - int key; + int key = 0; switch (keyval) { case GDK_KP_Left: key = 0; break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2015-10-20 15:06:09
|
Revision: 2948 http://sourceforge.net/p/roadmap/code/2948 Author: pgf Date: 2015-10-20 15:06:06 +0000 (Tue, 20 Oct 2015) Log Message: ----------- buildmap_osm_text: remove obsolete code from rewrite, cleanup Modified Paths: -------------- trunk/roadmap/src/buildmap_osm_text.c Modified: trunk/roadmap/src/buildmap_osm_text.c =================================================================== --- trunk/roadmap/src/buildmap_osm_text.c 2015-10-20 15:06:03 UTC (rev 2947) +++ trunk/roadmap/src/buildmap_osm_text.c 2015-10-20 15:06:06 UTC (rev 2948) @@ -28,6 +28,13 @@ * @brief a module to read OSM text format */ +/* + * this module uses libreadosm to process OSM input. see: + * http://www.gaia-gis.it/gaia-sins/readosm-1.0.0b-doxy-doc/index.html + * it's packaged for debian and others. for fedora, see: + * http://rpmfind.net//linux/RPM/fedora/updates/18/armhfp/readosm-1.0.0b-1.fc18.armv7hl.html + */ + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -38,7 +45,6 @@ #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> -#include <sys/mman.h> #include <time.h> #include <readosm.h> @@ -52,8 +58,6 @@ #include "roadmap_hash.h" #include "buildmap.h" -#include "buildmap_zip.h" -#include "buildmap_city.h" #include "buildmap_square.h" #include "buildmap_point.h" #include "buildmap_place.h" @@ -72,131 +76,21 @@ extern char *BuildMapResult; /* OSM has over 2G nodes already -- enough to overflow a 32 bit signed int */ -typedef unsigned int nodeid_t; -typedef unsigned int wayid_t; +typedef unsigned nodeid_t; +typedef unsigned wayid_t; -/** - * @brief a couple of variables to keep track of the way we're dealing with - */ -static struct WayInfo { - wayid_t WayId; /**< are we in a way (its id) */ - int nWayNodes; /**< number of nodes known for - this way */ - int WayLayer; /**< the layer for this way */ - char *WayName; /**< the street name */ - char *WayStreetRef; /**< street code, - to be used when no name (e.g. motorway) */ - int WayFlags; /**< properties of this way, from - the table flags */ - int WayIsOneWay; /**< is this way one direction only */ - int WayIsBuilding; /**< this way represents a building */ - char *WayTourism; /**< value of tourism tag, if any */ - char *WayAmenity; /**< value of amenity tag, if any */ - int WayAdminLevel; /**< boundaries */ - int WayTerritorial; /**< is this a territorial boundary? */ - int WayCoast; /**< coastline */ - int WayIsInteresting; /**< this way is interesting for RoadMap */ -} wi; /** - * @brief variables referring to the current node - */ -static struct NodeInfo { - nodeid_t NodeId; /**< which node */ - int NodeLayer; /**< the layer for this node */ - int NodeFlags; /**< properties of this node, from - the table flags */ - char *NodePlace; /**< what kind of place is this */ - char *NodeName; /**< what's it's name? */ - int NodeLon, /**< coordinates */ - NodeLat; /**< coordinates */ - int NodeFakeFips; /**< fake postal code */ -} ni; - -/** * @brief some global variables */ -// static int LineNo; /**< line number in the input file */ -static int nPolygons = 0; /**< current polygon id (number of - polygons until now) */ -static int LineId = 0; /**< for buildmap_line_add */ +static int PolygonId = 0; +static int LineId = 0; -/** - * @brief table for translating the names in XML strings into readable format - */ -static struct XmlIsms { - char *code; /**< the piece between & and ; */ - char *string; /**< translates into this */ -} XmlIsms[] = { - { "apos", "'" }, - { "gt", ">" }, - { "lt", "<" }, - { "quot", """" }, - { "amp", "&" }, - { NULL, NULL } /* end */ -}; +static int l_shoreline, l_boundary; +static int nWays, nNodes; /** - * @brief remove XMLisms such as ' and strdup - * limitation : names must be shorter than 512 bytes - * @param s input string - * @return duplicate, to be freed elsewhere - */ -static char *FromXmlAndDup(const char *s) -{ - int i, j, k, l, found; - static char res[512]; - - for (i=j=0; s[i]; i++) - if (s[i] == '&') { - found = 0; - for (k=0; XmlIsms[k].code && !found; k++) { - for (l=0; s[l+i+1] == XmlIsms[k].code[l]; l++) - ; - /* When not equal, must be at end of code */ - if (XmlIsms[k].code[l] == '\0' && - s[l+i+1] == ';') { - found = 1; - i += l+1; - for (l=0; XmlIsms[k].string[l]; l++) - res[j++] = XmlIsms[k].string[l]; - } - } - if (!found) - res[j++] = s[i]; - } else { - res[j++] = s[i]; - } - res[j] = '\0'; - return strdup(res); -} - -/** - * @brief reset all the info about this way - */ -static void -buildmap_osm_text_reset_way(void) -{ - if (wi.WayName) free(wi.WayName); - if (wi.WayStreetRef) free(wi.WayStreetRef); - if (wi.WayTourism) free(wi.WayTourism); - if (wi.WayAmenity) free(wi.WayAmenity); - memset(&wi, 0, sizeof(wi)); -} - -/** - * @brief reset all the info about this node - */ -static void -buildmap_osm_text_reset_node(void) -{ - if (ni.NodePlace) free(ni.NodePlace); - if (ni.NodeName) free(ni.NodeName); - memset(&ni, 0, sizeof(ni)); -} - -/** - * @brief + * @brief add string to dictionary, taking note of null inputs * @param d * @param string * @return @@ -210,18 +104,28 @@ return buildmap_dictionary_add (d, (char *) string, strlen(string)); } +int +qsort_compare_unsigneds(const void *id1, const void *id2) +{ + if (*(unsigned int *)id1 < *(unsigned int *)id2) + return -1; + else if (*(unsigned int *)id1 > *(unsigned int *)id2) + return 1; + else + return 0; +} + /** - * @brief simplistic way to gather point data + * @brief incoming lat/lon nodes are translated to roadmap points, + * and a hash is maintained */ static int nPointsAlloc = 0; static int nPoints = 0; static struct points { int id; int point; -} *points = 0; +} *Points = 0; -#define NPOINTSINC 10000 - RoadMapHash *PointsHash = NULL; static void @@ -229,8 +133,8 @@ { nPoints = 0; PointsHash = 0; - if (points) free(points); - points = 0; + if (Points) free(Points); + Points = 0; nPointsAlloc = 0; } @@ -238,21 +142,23 @@ buildmap_osm_text_point_add(int id, int point) { if (nPoints == nPointsAlloc) { - nPointsAlloc += NPOINTSINC; - + if (Points) + nPointsAlloc *= 2; + else + nPointsAlloc = 10000; if (PointsHash == NULL) PointsHash = roadmap_hash_new("PointsHash", nPointsAlloc); else roadmap_hash_resize(PointsHash, nPointsAlloc); - points = realloc(points, sizeof(struct points) * nPointsAlloc); - buildmap_check_allocated(points); + Points = realloc(Points, sizeof(struct points) * nPointsAlloc); + buildmap_check_allocated(Points); } roadmap_hash_add(PointsHash, id, nPoints); - points[nPoints].id = id; - points[nPoints++].point = point; + Points[nPoints].id = id; + Points[nPoints++].point = point; } /** @@ -268,69 +174,13 @@ for (i = roadmap_hash_get_first(PointsHash, id); i >= 0; i = roadmap_hash_get_next(PointsHash, i)) - if (points[i].id == id) - return points[i].point; + if (Points[i].id == id) + return Points[i].point; return -1; } -/** - * @brief At the end of a node, process its data - * @param data point to the line buffer - * @return error indication - */ -void -buildmap_osm_text_node_finish(void) -{ - int point; - RoadMapString s; - - /* Add the node */ - point = buildmap_point_add(ni.NodeLon, ni.NodeLat); - buildmap_osm_text_point_add(ni.NodeId, point); - - if (ni.NodeName && ni.NodePlace) { - if (ni.NodeLayer) { - buildmap_debug( "finishing %f %f %s %s layer: %d", - (float)ni.NodeLat/1000000.0, (float)ni.NodeLon/1000000.0, - ni.NodePlace, ni.NodeName, ni.NodeLayer); - s = str2dict (DictionaryCity, (char *) ni.NodeName); - buildmap_place_add(s, ni.NodeLayer, point); - } else { - buildmap_debug( "dropping %s %s", ni.NodePlace, ni.NodeName); - } - } - - buildmap_osm_text_reset_node(); -} - -/** - * @brief this structure keeps shape data for a postprocessing step - */ -struct shapeinfo { - int lineid; - int count; - int *lons; - int *lats; -}; - -static int numshapes = 0; -static int nallocshapes = 0; - -/** - * @brief ? - */ -static struct shapeinfo *shapes; - -struct neighbor_ways { - int tileid; // these are the ways for this tileid - RoadMapFileContext fc; // file context for the mmap - int count; // how many ways - const wayid_t *ways; // the way ids for that tileid. - // (also serves as the "populated" flag.) -} Neighbor_Ways[8]; - static int maxWayTable = 0; int nWayTable = 0; wayid_t *WayTable = NULL; @@ -345,6 +195,12 @@ memcpy(WayTableCopy, WayTable, nWayTable * sizeof(wayid_t)); } +/** + * @brief we mark a way as interesting by adding it to WayTable. this + * is later sorted, and we can use it later to quickly check if + * we thought it was interesing. + * @param wayid + */ static void saveInterestingWay(wayid_t wayid) { @@ -363,23 +219,10 @@ nWayTable++; } -int -qsort_compare_unsigneds(const void *id1, const void *id2) -{ - if (*(unsigned int *)id1 < *(unsigned int *)id2) - return -1; - else if (*(unsigned int *)id1 > *(unsigned int *)id2) - return 1; - else - return 0; -} - /** - * @brief find out if this way is interesting + * @brief after WayTable has been sorted, see if this way is interesting * @param wayid * @return whether we thought way was interesting when we found it - * - * Note : relies on the order of ways encountered in the file, for performance */ static wayid_t * isWayInteresting(wayid_t wayid) @@ -395,6 +238,10 @@ static nodeid_t *NodeTable = NULL; +/* + * @brief creates our .ways table, later used by our neighbors so they + * know which ways are already being taken care of by us. + */ void buildmap_osm_text_save_wayids(const char *path, const char *outfile) { @@ -427,8 +274,14 @@ } +/** + * @brief we mark a node as interesting by adding it to NodeTable. this + * is later sorted, and we can use it later to quickly check if + * we thought it was interesting. + * @param nodeid + */ static void -saveInterestingNode(nodeid_t node) +saveInterestingNode(nodeid_t nodeid) { if (nNodeTable == maxNodeTable) { @@ -441,10 +294,15 @@ buildmap_check_allocated(NodeTable); } - NodeTable[nNodeTable] = node; + NodeTable[nNodeTable] = nodeid; nNodeTable++; } +/** + * @brief after NodeTable has been sorted, see if this node is interesting + * @param nodeid + * @return whether we thought way was interesting when we found it + */ static int isNodeInteresting(nodeid_t nodeid) { @@ -459,105 +317,13 @@ /** - * @brief - * @param data points into the line of text being processed - * @return error indication - * - * Example line : - * <nd ref="997470"/> + * @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 (PLACE, AREA). + * @param lookfor limits the search to matching types (PLACE, AREA) */ -int nWayNodeAlloc; /**< size of the allocation of the array */ -int *WayNodes; /**< the array to keep track of this way's nodes */ - -void -buildmap_osm_text_save_way_nodes(char *data) -{ - nodeid_t node; - int s; - - if (!wi.WayId) - buildmap_fatal(0, "Wasn't in a way (%s)", data); - - s = sscanf(data, "nd ref=%*[\"']%u%*[\"']", &node); - if (s != 1) - buildmap_fatal(0, "fail to scanf interesting nd"); - - if (buildmap_osm_text_point_get(node) < 0) { - return; - } - - if (wi.nWayNodes == nWayNodeAlloc) { - if (WayNodes) - nWayNodeAlloc *= 2; - else - nWayNodeAlloc = 1000; - WayNodes = - (int *)realloc(WayNodes, sizeof(*WayNodes) * nWayNodeAlloc); - buildmap_check_allocated(WayNodes); - } - WayNodes[wi.nWayNodes++] = node; -} - -/** - * @brief collect node data in pass 1 - * @param data - * @return an error indicator - * - * The input line is discarded if a bounding box is specified and - * the node is outside. - * - * Example input line : - * <node id="123295" timestamp="2005-07-05T03:26:11Z" user="LA2" - * lat="50.4443626" lon="3.6855288"/> - */ -void -buildmap_osm_text_node_read_lat_lon(char *p) -{ - int nchars; - double flat, flon; - int NodeLatRead, NodeLonRead; - char tag[512], value[512]; - int s; - - ni.NodeLat = ni.NodeLon = 0; - NodeLatRead = NodeLonRead = 0; - - while (NodeLatRead == 0 || NodeLonRead == 0) { - - for (; *p && isspace(*p); p++) ; - - s = sscanf(p, "%[a-zA-Z0-9_]=%*[\"']%[^\"']%*[\"']%n", - tag, value, &nchars); - if (s != 2) - buildmap_fatal(0, "bad tag read at '%s'\n", p); - - if (strcmp(tag, "lat") == 0) { - sscanf(value, "%lf", &flat); - ni.NodeLat = flat * 1000000; - NodeLatRead++; - } else if (strcmp(tag, "lon") == 0) { - sscanf(value, "%lf", &flon); - ni.NodeLon = flon * 1000000; - NodeLonRead++; - } - - p += nchars; - } - - /* if the node is finished ("\>"), then finish it off. i.e., - * these are untagged nodes */ - for (; *p && isspace(*p); p++) ; - if (*p == '/' && *(p+1) == '>') { - /* since this is a tagless node, it can only be interesting - * because it's in the interesting list. */ - if (isNodeInteresting(ni.NodeId)) { - buildmap_osm_text_node_finish(); - } - } - -} - int buildmap_osm_get_layer(int lookfor, const char *tag, const char *value, int *flags, int *layer) @@ -585,443 +351,19 @@ return 0; } -/** - * @brief deal with tag lines outside of ways - * @param data points into the line of text being processed - * @return error indication - */ -void -buildmap_osm_text_node_tag(char *data, int catalog) -{ - static char *tagk = 0; - static char *tagv = 0; - int s; - if (! tagk) - tagk = malloc(512); - if (! tagv) - tagv = malloc(512); - -// it turns out that the OSM xml output contains raw apostrophe -// characters, e.g. "Cortina d'Ampezzo". but i assume that if -// a placename actually contained a '"', then the XML escape -// mechanisms would be used, and not single quotes. -// summary: stop parsing for 'string', just get "string". -#ifdef BEFORE - s = sscanf(data, "tag k=%*['\"]%[^\"']%*['\"] v=%*['\"]%[^\"']%*['\"]", - tagk, tagv); -#else - s = sscanf(data, "tag k=%*[\"]%[^\"]%*[\"] v=%*[\"]%[^\"]%*[\"]/>", - tagk, tagv); -#endif - if (s != 2) - buildmap_fatal(0, "fail to scanf tag k and v (%s)", data); - - if (strcmp(tagk, "name") == 0) { - /* <tag k="name" v="Herent"/> */ - if (ni.NodeName) - free(ni.NodeName); - ni.NodeName = FromXmlAndDup(tagv); - if (catalog) { - saveInterestingNode(ni.NodeId); - } - } else { - if (!buildmap_osm_get_layer(PLACE, tagk, tagv, - &ni.NodeFlags, &ni.NodeLayer)) { - return; - } - if (ni.NodeFlags & PLACE) { - if (ni.NodePlace) - free(ni.NodePlace); - ni.NodePlace = strdup(tagv); - if (catalog) { - saveInterestingNode(ni.NodeId); - } - } else { - buildmap_debug("dropping node %u info k %s v %s", ni.NodeId, tagk, tagv); - } - } - -} - /** - * @brief deal with tag lines inside a <way> </way> pair - * @param data points into the line of text being processed - * @return error indication - * - * Example line : - * <tag k="highway" v="residential"/> - * <tag k="name" v="Rue de Thiribut"/> - * <tag k="created_by" v="JOSM"/> - * <tag k="ref" v="E40"> - * <tag k="int_ref" v="E 40"> + * @brief neighbor_ways keeps track of ways our neighbors are already + * taking care of. */ -void -buildmap_osm_text_way_tag(char *data) -{ - static char *tag = 0, *value = 0; - int s; +struct neighbor_ways { + int tileid; // these are the ways for this tileid + RoadMapFileContext fc; // file context for the mmap + int count; // how many ways + const wayid_t *ways; // the way ids for that tileid. + // (also serves as the "populated" flag.) +} Neighbor_Ways[8]; - /* have we already decided this way is uninteresting? */ - if (!wi.WayIsInteresting) - return; - - if (! tag) tag = malloc(512); - if (! value) value = malloc(512); - - s = sscanf(data, "tag k=%*[\"']%[^\"']%*[\"'] v=%*[\"']%[^\"']%*[\"']", - tag, value); - if (s != 2) - buildmap_fatal(0, "fail to scanf tag and value (%s)", data); - - /* street names */ - if (strcasecmp(tag, "name") == 0) { - if (wi.WayName) - free(wi.WayName); - wi.WayName = FromXmlAndDup(value); - return; - } - - if (strcasecmp(tag, "ref") == 0) { - if (wi.WayStreetRef) - free(wi.WayStreetRef); - wi.WayStreetRef = FromXmlAndDup(value); - return; - } - -#ifdef BUILDMAP_NAVIGATION_SUPPORT - if (strcasecmp(tag, "oneway") == 0 && strcasecmp(value, "yes") == 0) { - wi.WayIsOneWay = ROADMAP_LINE_DIRECTION_ONEWAY; - return; - } -#endif - - if (strcasecmp(tag, "building") == 0) { - /* the value can be things like "shed", "barn", "temple", - * or "yes". we don't really care which. - */ - wi.WayIsBuilding = 1; - return; - } - - if (strcasecmp(tag, "tourism") == 0) { - if (wi.WayTourism) - free(wi.WayTourism); - wi.WayTourism = FromXmlAndDup(value); - return; - } - if (strcasecmp(tag, "amenity") == 0) { - if (wi.WayAmenity) - free(wi.WayAmenity); - wi.WayAmenity = FromXmlAndDup(value); - return; - } - - if (strcasecmp(tag, "admin_level") == 0) { - wi.WayAdminLevel = atoi(value); - return; - } else if (strcasecmp(tag, "border_type") == 0) { - wi.WayTerritorial = !strcasecmp(value, "territorial"); - return; - } else if (strcasecmp(tag, "natural") == 0 && - strcasecmp(value, "coastline") == 0) { - wi.WayCoast = 1; - } - - /* - * Get layer info - */ - buildmap_osm_get_layer(ANY, tag, value, &wi.WayFlags, &wi.WayLayer); - -} - -void -bxuildmap_osm_text_way_drop_uninteresting(void) -{ - if (wi.WayIsBuilding) { - if (!wi.WayTourism && !wi.WayAmenity) { - wi.WayIsInteresting = 0; - } - } -} - -/** - * @brief We found an end tag for a way, so we must have read all - * the required data. Process it. - * @param data points to the line of text being processed - * @return error indication - */ -void -buildmap_osm_text_way_finish(void) -{ - int from_point, to_point, line, street; - int fromlon, fromlat; - RoadMapString rms_dirp, rms_dirs, rms_type, rms_name; - int j; - char compound_name[1024]; - char *n; - static int l_shoreline = 0, - l_boundary = 0; - - if (l_shoreline == 0) - l_shoreline = buildmap_layer_get("shore");; - if (l_boundary == 0) - l_boundary = buildmap_layer_get("boundaries");; - - if (wi.WayId == 0) - buildmap_fatal(0, "Wasn't in a way"); - - if (wi.nWayNodes < 1) { - buildmap_osm_text_reset_way(); - return; - } - - - if (wi.WayIsBuilding) { - if (wi.WayTourism) { - buildmap_osm_get_layer(PLACE, "tourism", wi.WayTourism, &wi.WayFlags, &wi.WayLayer); - } else if (wi.WayAmenity) { - buildmap_osm_get_layer(PLACE, "amenity", wi.WayAmenity, &wi.WayFlags, &wi.WayLayer); - } else { - buildmap_osm_text_reset_way(); - return; - } - } - - if (wi.WayLayer == 0) { - /* if a way is both a coast and a boundary, treat it only as coast */ - if (wi.WayCoast) { - wi.WayLayer = l_shoreline; - } else if (wi.WayAdminLevel) { - /* national == 2, state == 4, ignore lesser boundaries */ - /* also ignore territorial (marine) borders */ - if (wi.WayAdminLevel > 4 || wi.WayTerritorial) { - wi.WayIsInteresting = 0; - } else if (wi.WayAdminLevel > 2) { - - from_point = buildmap_osm_text_point_get(WayNodes[0]); - fromlon = buildmap_point_get_longitude(from_point); - fromlat = buildmap_point_get_latitude(from_point); - - /* if we're not (roughly) in north america, - * discard state boundaries as well. */ - if (fromlon > -32 || fromlat < 17) { - /* east of the azores or south of mexico */ - wi.WayIsInteresting = 0; - } - } - - wi.WayLayer = l_boundary; - } - } - - if ( !wi.WayIsInteresting || wi.WayLayer == 0) { - wayid_t *wp; - buildmap_debug("discarding way %d, not interesting (%s)", wi.WayId, wi.WayName); - wp = isWayInteresting(wi.WayId); - if (wp) { - WayTableCopy[wp-WayTable] = 0; - } - - buildmap_osm_text_reset_way(); - return; - } - - rms_dirp = str2dict(DictionaryPrefix, ""); - rms_dirs = str2dict(DictionarySuffix, ""); - rms_type = str2dict(DictionaryType, ""); - rms_name = 0; - - - if ((wi.WayFlags & PLACE) && (wi.WayTourism || wi.WayAmenity)) { - /* we're finishing a way, but the flags may say PLACE if - * we're treating a polygon as a place, for instance. find - * the center of the bounding box (which is good enough, for - * these purposes), and make it into a place. - */ - int minlat = 999999999, maxlat = -999999999; - int minlon = 999999999, maxlon = -999999999; - int point, lon, lat; - - for (j = 0; j < wi.nWayNodes; j++) { - point = buildmap_osm_text_point_get(WayNodes[j]); - lon = buildmap_point_get_longitude(point); - lat = buildmap_point_get_latitude(point); - - if (lat < minlat) minlat = lat; - if (lat > maxlat) maxlat = lat; - if (lon < minlon) minlon = lon; - if (lon > maxlon) maxlon = lon; - } - - lat = (maxlat + minlat) / 2; - lon = (maxlon + minlon) / 2; - - /* this code looks like buildmap_osm_text_node_finish() */ - point = buildmap_point_add(lon, lat); - - if (!wi.WayName) - wi.WayName = FromXmlAndDup("??"); - - if (wi.WayLayer) { - RoadMapString s; - buildmap_debug( "wayplace: finishing %f %f %s %s layer: %d", - (float)lat/1000000.0, (float)lon/1000000.0, - wi.WayTourism ? wi.WayTourism : wi.WayAmenity, - wi.WayName, wi.WayLayer); - s = str2dict (DictionaryCity, (char *) wi.WayName); - buildmap_place_add(s, wi.WayLayer, point); - } else { - buildmap_debug( "dropping %s %s", - wi.WayTourism ? wi.WayTourism : wi.WayAmenity, - wi.WayName); - } - - - } else if ((wi.WayFlags & AREA) && - (WayNodes[0] == WayNodes[wi.nWayNodes-1])) { - /* see http://wiki.openstreetmap.org/wiki/The_Future_of_Areas - * for why the above conditions are simplistic */ - static int polyid = 0; - static int cenid = 0; - - /* - * Detect an AREA -> create a polygon - */ - nPolygons++; - cenid++; - polyid++; - - rms_name = str2dict(DictionaryStreet, wi.WayName); - buildmap_polygon_add_landmark (nPolygons, wi.WayLayer, rms_name); - buildmap_polygon_add(nPolygons, cenid, polyid); - - for (j=1; j<wi.nWayNodes; j++) { - int prevpoint = - buildmap_osm_text_point_get(WayNodes[j-1]); - int point = - buildmap_osm_text_point_get(WayNodes[j]); - - LineId++; - buildmap_line_add - (LineId, wi.WayLayer, prevpoint, point, - ROADMAP_LINE_DIRECTION_BOTH); - buildmap_polygon_add_line (cenid, polyid, LineId, POLYGON_SIDE_RIGHT); - } - } else { - /* - * Register the way - * - * Need to do this several different ways : - * - begin and end points form a "line" - * - register street name - * - adjust the square - * - keep memory of the point coordinates so we can - * postprocess the so called shapes (otherwise we only have - * straight lines) - */ - - int *lonsbuf, *latsbuf; - - /* Street name */ - buildmap_debug ("Way %d [%s] ref [%s]", wi.WayId, - wi.WayName ? wi.WayName : "", - wi.WayStreetRef ? wi.WayStreetRef : ""); - - if (wi.WayStreetRef) { - char *d = compound_name; - char *s = wi.WayStreetRef; -#define ENDASHSEP " \xe2\x80\x93 " -#define EMDASHSEP " \xe2\x80\x94 " - while (*s) { /* OSM separates multi-value refs with ';' */ - if (*s == ';') { - d += sprintf(d, ENDASHSEP); - } else { - *d++ = *s; - } - s++; - } - n = compound_name; - *d = '\0'; - - if (wi.WayName) { - // sprintf(d, ", %s", wi.WayName); - sprintf(d, "%s%s", ENDASHSEP, wi.WayName); - } - } else { - n = wi.WayName; - } - rms_name = str2dict(DictionaryStreet, n); - - LineId++; - /* Map begin and end points to internal point id */ - from_point = buildmap_osm_text_point_get(WayNodes[0]); - to_point = buildmap_osm_text_point_get(WayNodes[wi.nWayNodes-1]); - - line = buildmap_line_add(LineId, - wi.WayLayer, from_point, to_point, wi.WayIsOneWay); - - street = buildmap_street_add(wi.WayLayer, - rms_dirp, rms_name, rms_type, - rms_dirs, line); - buildmap_range_add_no_address(line, street); - - /* - * We're passing too much here - the endpoints of - * the line don't need to be passed to the shape - * module. We're keeping them here just to be on - * the safe side, they'll be ignored in - * buildmap_osm_text_ways_shapeinfo(). - * - * The lonsbuf/latsbuf are never freed, need to be - * preserved for shape registration which happens - * at the end of the program run, so exit() will - * free this for us. - */ - - lonsbuf = calloc(wi.nWayNodes, sizeof(int)); - latsbuf = calloc(wi.nWayNodes, sizeof(int)); - - for (j=0; j<wi.nWayNodes; j++) { - int point = - buildmap_osm_text_point_get(WayNodes[j]); - int lon = buildmap_point_get_longitude(point); - int lat = buildmap_point_get_latitude(point); - - /* Keep info for the shapes */ - lonsbuf[j] = lon; - latsbuf[j] = lat; - - buildmap_square_adjust_limits(lon, lat); - } - - if (numshapes == nallocshapes) { - /* Allocate additional space (in big - * chunks) when needed */ - if (shapes) - nallocshapes *= 2; - else - nallocshapes = 1000; - shapes = realloc(shapes, - nallocshapes * sizeof(struct shapeinfo)); - buildmap_check_allocated(shapes); - } - - buildmap_debug("lineid %d wi.nWayNodes %d", - LineId, wi.nWayNodes); - /* Keep info for the shapes */ - shapes[numshapes].lons = lonsbuf; - shapes[numshapes].lats = latsbuf; - shapes[numshapes].count = wi.nWayNodes; - shapes[numshapes].lineid = LineId; - - numshapes++; - } - - buildmap_osm_text_reset_way(); - -} - /* * @brief memory maps the way list for the give tileid, if it exists */ @@ -1117,6 +459,20 @@ } /** + * @brief this structure keeps shape data for a postprocessing step + */ +struct shapeinfo { + int lineid; + int count; + int *lons; + int *lats; +}; + +static int nShapes = 0; +static int nShapesAlloc = 0; +static struct shapeinfo *shapes; + +/** * @brief a postprocessing step to load shape info * * this needs to be a separate step because lines need to be sorted @@ -1131,11 +487,11 @@ int *lons, *lats; /* , *used; */ int line_index; - buildmap_info("loading shape info (from %d ways) ...", numshapes); + buildmap_info("loading shape info (from %d ways) ...", nShapes); buildmap_line_sort(); - for (i = 0; i < numshapes; i++) { + for (i = 0; i < nShapes; i++) { count = shapes[i].count; @@ -1162,460 +518,10 @@ } -static int text_file_is_pipe; -FILE *buildmap_osm_text_fopen(char *fn) -{ - FILE *fdata; - int len; - - len = strlen(fn); - if (len > 3 && strcmp(&fn[len-3], ".gz") == 0) { - char command[1024]; - sprintf(command, "gzip -d -c %s", fn); - fdata = popen(command, "r"); - text_file_is_pipe = 1; - } else { - fdata = fopen(fn, "r"); - text_file_is_pipe = 0; - } - - if (fdata == NULL) { - buildmap_fatal(0, "couldn't open \"%s\"", fn); - return NULL; - } - - return fdata; -} - -int buildmap_osm_text_fclose(FILE *fp) -{ - if (text_file_is_pipe) - return pclose(fp); - else - return fclose(fp); -} - -#if BEFORE -/** - * @brief This is the gut of buildmap_osm_text : parse an OSM XML file - * @param fdata an open file pointer, this will get read twice - * @param country_num the country id that we're working for - * @param division_num the country subdivision id that we're working for - * @return error indication - * - * This is a simplistic approach to parsing the OSM text (XML) files. - * It scans the XML twice, to cope with out of order information. - * (Note that this simplistic approach may raise eyebrows, but this is - * not a big time consumer !) - * - * Pass 1 deals with way definitions -- make a list of interesting ways. - * Pass 2 catalogs interesting nodes, based on references from ways. - * Pass 3 interprets ways and a few tags. - * - * All underlying processing is passed to other functions. - */ -void -buildmap_osm_text_read(char *fn, int tileid, int country_num, int division_num) -{ - FILE *fdata; - int lines; - char *got; - static char buf[LINELEN]; - char *p; - time_t t[10]; - int passid, NumNodes, NumWays; - struct stat st; - wayid_t interesting_way = 0; - int in_relation; - int need_xml_header = 1; - int need_osm_header = 1; - int need_osm_trailer = 1; - int s; - - fdata = buildmap_osm_text_fopen(fn); - fstat(fileno(fdata), &st); - - ni.NodeFakeFips = 1000000 + country_num * 1000 + division_num; - - if (tileid) - buildmap_osm_text_neighbor_way_maps(tileid); - - buildmap_osm_text_point_hash_reset(); - buildmap_osm_text_reset_way(); - buildmap_osm_text_reset_node(); - - (void) time(&t[0]); - passid = 1; - - DictionaryPrefix = buildmap_dictionary_open("prefix"); - DictionaryStreet = buildmap_dictionary_open("street"); - DictionaryType = buildmap_dictionary_open("type"); - DictionarySuffix = buildmap_dictionary_open("suffix"); - DictionaryCity = buildmap_dictionary_open("city"); - - buildmap_osm_common_find_layers (); - - /* - * Pass 1 - just figure out which ways are interesting - */ - buildmap_info("Starting pass %d", passid); - buildmap_set_source("pass 1"); - LineNo = 0; - NumWays = 0; - numshapes = 0; - nPolygons = 0; - LineId = 0; - nWayTable = 0; - nNodeTable = 0; - - while (! feof(fdata) && need_osm_trailer) { - buildmap_set_line(++LineNo); - if (LineNo % 1000 == 0) buildmap_progress(LineNo, 0); - got = fgets(buf, LINELEN, fdata); - if (got == NULL) { - if (feof(fdata)) - break; - buildmap_fatal(0, "short read (length)"); - } - - /* Figure out the XML */ - for (p=buf; *p && isspace(*p); p++) ; - if (*p == '\n' || *p == '\r') - continue; - - /* do some error checking in the first pass */ - if (need_xml_header) { - if (strncmp(p, "<?xml ", 6)) - buildmap_fatal(0, "bad input from %s, no <?xml line", fn); - need_xml_header = 0; - continue; - } - if (need_osm_header) { - if (strncmp(p, "<osm ", 5)) - buildmap_fatal(0, "bad input from %s, no <osm line", fn); - need_osm_header = 0; - continue; - } - - if (*p != '<') { - /* - * Assume we're in a continuation line such as - * <tag k='opening_hours' v='Sa 09:30-19:00; - * Su 10:00-14:00'/> - * and just continue with the next line and hope we'll pick up - * a new tag soon. - */ - continue; - } - - p++; /* point to character after '<' now */ - for (; *p && isspace(*p); p++) ; - - in_relation = 0; - if (strncasecmp(p, "relation", 8) == 0) { - - in_relation = 1; - continue; - - } else if (strncasecmp(p, "/relation", 9) == 0) { - - in_relation = 0; - continue; - - } else if (in_relation) { - - continue; - - } else if (strncasecmp(p, "way", 3) == 0) { - - // assume ways are interesting, to begin with - wi.WayIsInteresting = 1; - s = sscanf(p, "way id=%*[\"']%u%*[\"']", &wi.WayId); - if (s != 1) - buildmap_fatal(0, "buildmap_osm_text(%s) way error", p); - - NumWays++; - continue; - - } else if (strncasecmp(p, "/way", 4) == 0) { - - /* if we're processing a quadtile, don't include any - * ways that our neighbors already include */ - if (tileid && wi.WayId && wi.WayIsInteresting && - buildmap_osm_text_check_neighbors(wi.WayId)) { - buildmap_verbose("dropping way %d because a neighbor " - "already has it", wi.WayId); - wi.WayIsInteresting = 0; - } - - if (wi.WayIsBuilding) { - if (!wi.WayTourism && !wi.WayAmenity) { - wi.WayIsInteresting = 0; - } - } - - /* if the way is still flagged interesting, save it */ - if (wi.WayId && wi.WayIsInteresting) - saveInterestingWay(wi.WayId); - - buildmap_osm_text_reset_way(); - continue; - - } else if (strncasecmp(p, "tag", 3) == 0) { - - if (wi.WayId) - buildmap_osm_text_way_tag(p); - else - buildmap_osm_text_node_tag(p, 0); - continue; - - } else if (strncasecmp(p, "/osm>", 5) == 0) { - - need_osm_trailer = 0; - - } - } - buildmap_progress(LineNo, 0); - putchar('\n'); - lines = LineNo; - - if (need_osm_trailer) - buildmap_fatal(0, "bad input from %s, no </osm> line", fn); - - qsort(WayTable, nWayTable, sizeof(*WayTable), qsort_compare_unsigneds); - - (void) time(&t[passid]); - buildmap_info("Pass %d : %d lines read (%d seconds)", - passid, LineNo, t[passid] - t[passid - 1]); - passid++; - - /* - * Pass 2 - flag interesting nodes : any node (a <nd>) in a way, - * but e.g. nodes that represent town definitions as well. - */ - LineNo = 0; - buildmap_set_source("pass 2"); - buildmap_osm_text_fclose(fdata); - fdata = buildmap_osm_text_fopen(fn); - buildmap_osm_text_reset_way(); - buildmap_osm_text_reset_node(); - - while (! feof(fdata)) { - buildmap_progress(LineNo, lines); - buildmap_set_line(++LineNo); - got = fgets(buf, LINELEN, fdata); - if (got == NULL) { - if (feof(fdata)) - break; - buildmap_fatal(0, "short read (length)"); - } - - /* Figure out the XML */ - for (p=buf; *p && isspace(*p); p++) ; - if (*p == '\n' || *p == '\r') - continue; - if (*p != '<') // continuation line? - continue; - - in_relation = 0; - p++; /* point to character after '<' now */ - for (; *p && isspace(*p); p++) ; - - if (strncasecmp(p, "relation", 8) == 0) { - - in_relation = 1; - continue; - - } else if (strncasecmp(p, "/relation", 9) == 0) { - - in_relation = 0; - continue; - - } else if (in_relation) { - - continue; - - } else if (strncasecmp(p, "way", 3) == 0) { - - s = sscanf(p, "way id=%*[\"']%u%*[\"']", &wi.WayId); - if (s != 1) - buildmap_fatal(0, "buildmap_osm_text(%s) way error", p); - - interesting_way = !!isWayInteresting(wi.WayId); - continue; - - } else if (strncasecmp(p, "/way", 4) == 0) { - - wi.WayId = 0; - buildmap_osm_text_reset_way(); - continue; - - } else if (strncasecmp(p, "nd", 2) == 0) { - - nodeid_t node; - /* nodes referenced by interesting ways are interesting */ - if (wi.WayId && interesting_way) { - s = sscanf(p, "nd ref=%*[\"']%u%*[\"']", &node); - if (s != 1) - buildmap_fatal(0, "buildmap_osm_text(%s) way error", p); - - saveInterestingNode(node); - } - continue; - - } else if (strncasecmp(p, "tag", 3) == 0) { - continue; - } - } - buildmap_progress(LineNo, lines); - putchar('\n'); - - qsort(NodeTable, nNodeTable, sizeof(*NodeTable), qsort_compare_unsigneds); - - (void) time(&t[passid]); - buildmap_info("Pass %d : %d lines read (%d seconds)", - passid, LineNo, t[passid] - t[passid - 1]); - passid++; - - /* - * Pass 3 - look for all <node>s, define the interesting ones. - * nodes that are interesting because they're a part of - * interesting ways are already on the interesting list. - * nodes interesting in their own right (i.e., places) are not. - * Pass 3 - define ways flagged as interesting - */ - LineNo = 0; - NumNodes = 0; - buildmap_set_source("pass 3"); - buildmap_osm_text_fclose(fdata); - fdata = buildmap_osm_text_fopen(fn); - buildmap_osm_text_reset_way(); - buildmap_osm_text_reset_node(); - - /* we've finished saving ways. we need a fresh place to mark - * the ones we're discarding, while still keeping the original list - * quickly searchable. */ - copyWayTable(); - - while (! feof(fdata)) { - buildmap_progress(LineNo, lines); - buildmap_set_line(++LineNo); - got = fgets(buf, LINELEN, fdata); - if (got == NULL) { - if (feof(fdata)) - break; - buildmap_fatal(0, "short read (length)"); - } - - /* Figure out the XML */ - for (p=buf; *p && isspace(*p); p++) ; - if (*p == '\n' || *p == '\r') - continue; - if (*p != '<') // continuation line? - continue; - - in_relation = 0; - p++; /* point to character after '<' now */ - for (; *p && isspace(*p); p++) ; - - if (strncasecmp(p, "relation", 8) == 0) { - in_relation = 1; - continue; - - } else if (strncasecmp(p, "/relation", 9) == 0) { - in_relation = 0; - continue; - - } else if (in_relation) { - continue; - - } else if (strncasecmp(p, "node", 4) == 0) { - int nchars; - - s = sscanf(p, "node id=%*[\"']%u%*[\"']%n", &ni.NodeId, &nchars); - if (s != 1) - buildmap_fatal(0, "buildmap_osm_text(%s) node error", p); - - p += nchars; - - /* next read lat/lon k/v tags, and also call _finish() - * if necessary. */ - buildmap_osm_text_node_read_lat_lon(p); - - NumNodes++; - continue; - } else if (strncasecmp(p, "/node", 5) == 0) { - - /* if what we had was <node .... />, then we won't get - * here. buildmap_osm_text_node_finish() was called - * already, from buildmap_osm_text_node_read_lat_lon() */ - // if (isNodeInteresting(ni.NodeId)) { - /* this could be either a tagged or untagged node. - * it will be interesting, and saved to the db, if - * the tags tell us to do so. */ - buildmap_osm_text_node_finish(); - // } - continue; - - } else if (strncasecmp(p, "tag", 3) == 0) { - - if (!wi.WayId) - buildmap_osm_text_node_tag(p, 1); - else - buildmap_osm_text_way_tag(p); - continue; - - } else if (strncasecmp(p, "way", 3) == 0) { - - s = sscanf(p, "way id=%*[\"']%u%*[\"']", &wi.WayId); - if (s != 1) - buildmap_fatal(0, "buildmap_osm_text(%s) way error", p); - - wi.WayIsInteresting = !!isWayInteresting(wi.WayId); - continue; - - } else if (strncasecmp(p, "/way", 4) == 0) { - - if (wi.WayIsInteresting) - buildmap_osm_text_way_finish(); - continue; - - } else if (strncasecmp(p, "nd", 2) == 0) { - - // the nd node references gets put on WayNodes list - if (wi.WayIsInteresting) - buildmap_osm_text_save_way_nodes(p); - continue; - } - } - buildmap_progress(LineNo, lines); - putchar('\n'); - - buildmap_osm_text_fclose(fdata); - - (void) time(&t[passid]); - buildmap_info("Pass %d : %d lines read (%d seconds)", - passid, LineNo, t[passid] - t[passid - 1]); - passid++; - - - buildmap_osm_text_ways_shapeinfo(); - - (void) time(&t[passid]); - buildmap_info("Ways %d, interesting %d", - NumWays, nWayTable); - buildmap_info("Number of nodes : %d, interesting %d", NumNodes, nNodeTable); - buildmap_info("Final: (%d seconds)", - passid, t[passid] - t[passid - 1]); - -} -#else - char *readosm_errors[] = { "READOSM_OK", "READOSM_INVALID_SUFFIX", "READOSM_FILE_NOT_FOUND", - "READOSM_NULL_HANDLE", "READOSM_INVALID_HANDLE", "READOSM_INSUFFICIENT_MEMORY", @@ -1627,11 +533,11 @@ "READOSM_ABORT" }; -static int l_shoreline, l_boundary; -static int nWays, nNodes; - +/** + * @brief callback for initial node parsing, called via readosm_parse() + */ static int -parse_node(const void *user_data, const readosm_node * node) +parse_node(const void *is_tile, const readosm_node * node) { const readosm_tag *tag; const char *name = NULL, *place = NULL; @@ -1662,8 +568,11 @@ return READOSM_OK; } +/** + * @brief callback for final node parsing, called via readosm_parse() + */ static int -parse_node_finalize(const void *user_data, const readosm_node * node) +parse_node_finalize(const void *is_tile, const readosm_node * node) { const readosm_tag *tag; const char *name = NULL, *place = NULL; @@ -1718,8 +627,11 @@ return READOSM_OK; } +/** + * @brief callback for initial way parsing, called via readosm_parse() + */ static int -parse_way(const void *user_data, const readosm_way *way) +parse_way(const void *is_tile, const readosm_way *way) { const readosm_tag *tag; const char *tourism = NULL, *amenity = NULL; @@ -1733,6 +645,14 @@ if (way->node_ref_count == 0) return READOSM_OK; + /* if we're processing a quadtile, don't include any + * ways that our neighbors already include */ + if (is_tile && buildmap_osm_text_check_neighbors(way->id)) { + buildmap_verbose("dropping way %d because a neighbor " + "already has it", way->id); + return READOSM_OK; + } + for (i = 0; i < way->tag_count; i++) { tag = way->tags + i; @@ -1809,8 +729,11 @@ return READOSM_OK; } +/** + * @brief callback for final way parsing, called via readosm_parse() + */ static int -parse_way_finalize(const void *user_data, const readosm_way *way) +parse_way_finalize(const void *is_tile, const readosm_way *way) { const readosm_tag *tag; const char *tourism = NULL, *amenity = NULL, *name = NULL, *ref = NULL; @@ -1894,9 +817,6 @@ /* this code looks like buildmap_osm_text_node_finish() */ point = buildmap_point_add(lon, lat); - if (!name) - name = FromXmlAndDup("??"); - if (layer) { RoadMapString s; int p; @@ -1915,19 +835,15 @@ (way->node_refs[0] == way->node_refs[way->node_ref_count-1])) { /* see http://wiki.openstreetmap.org/wiki/The_Future_of_Areas * for why the above conditions are simplistic */ - static int polyid = 0; - static int cenid = 0; /* * Detect an AREA -> create a polygon */ - nPolygons++; - cenid++; - polyid++; + PolygonId++; rms_name = str2dict(DictionaryStreet, name); - buildmap_polygon_add_landmark (nPolygons, layer, rms_name); - buildmap_polygon_add(nPolygons, cenid, polyid); + buildmap_polygon_add_landmark (PolygonId, layer, rms_name); + buildmap_polygon_add(PolygonId, 0, PolygonId); for (j=1; j<way->node_ref_count; j++) { int prevpoint = @@ -1939,7 +855,7 @@ buildmap_line_add (LineId, layer, prevpoint, point, ROADMAP_LINE_DIRECTION_BOTH); - buildmap_polygon_add_line (cenid, polyid, LineId, POLYGON_SIDE_RIGHT); + buildmap_polygon_add_line (0, PolygonId, LineId, POLYGON_SIDE_RIGHT); } } else { /* @@ -2027,27 +943,27 @@ buildmap_square_adjust_limits(lon, lat); } - if (numshapes == nallocshapes) { + if (nShapes == nShapesAlloc) { /* Allocate additional space (in big * chunks) when needed */ if (shapes) - nallocshapes *= 2; + nShapesAlloc *= 2; else - nallocshapes = 1000; + nShapesAlloc = 1000; shapes = realloc(shapes, - nallocshapes * sizeof(struct shapeinfo)); + nShapesAlloc * sizeof(struct shapeinfo)); buildmap_check_allocated(shapes); } buildmap_debug("lineid %d way->node_ref_count %d", LineId, way->node_ref_count); /* Keep info for the shapes */ - shapes[numshapes].lons = lonsbuf; - shapes[numshapes].lats = latsbuf; - shapes[numshapes].count = way->node_ref_count; - shapes[numshapes].lineid = LineId; + shapes[nShapes].lons = lonsbuf; + shapes[nShapes].lats = latsbuf; + shapes[nShapes].count = way->node_ref_count; + shapes[nShapes].lineid = LineId; - numshapes++; + nShapes++; } return READOSM_OK; } @@ -2060,11 +976,18 @@ } #endif -void buildmap_readosm_pass(int pass, char *fn) +/** + * @brief rather than trying to put an entire file's contents in memory, + * we parse it in two passes. this routine is called for each pass. + */ +void buildmap_readosm_pass(int pass, char *fn, int tileid) { int ret; const void *handle; + void *is_tile = 0; + if (tileid) is_tile = (void *)1; + buildmap_info("Starting pass %d", pass); // buildmap_set_source("pass %d", pass); @@ -2076,10 +999,10 @@ } switch (pass) { - case 1: ret = readosm_parse(handle, NULL, + case 1: ret = readosm_parse(handle, is_tile, parse_node, parse_way, NULL); break; - case 2: ret = readosm_parse(handle, NULL, + case 2: ret = readosm_parse(handle, is_tile, parse_node_finalize, parse_way_finalize, NULL); break; } @@ -2098,6 +1021,16 @@ } +/** + * @brief This is the gut of buildmap_osm_text : parse an OSM XML file + * @param fdata an open file pointer, this will get read twice + * @param country_num the country id that we're working for + * @param division_num the country subdivision id that we're working for + * + * currently this only handles tiles. the country and division parameters + * are ignored. + * + */ void buildmap_osm_text_read(char *fn, int tileid, int country_num, int division_num) @@ -2108,9 +1041,6 @@ buildmap_osm_text_point_hash_reset(); - buildmap_osm_text_reset_way(); - buildmap_osm_text_reset_node(); - DictionaryPrefix = buildmap_dictionary_open("prefix"); DictionaryStreet = buildmap_dictionary_open("street"); DictionaryType = buildmap_dictionary_open("type"); @@ -2121,15 +1051,16 @@ l_shoreline = buildmap_layer_get("shore");; l_boundary = buildmap_layer_get("boundaries");; - nWays = nNodes = 0; - numshapes = 0; - nPolygons = 0; - LineId = 0; + nWays = 0; + nNodes = 0; + nShapes = 0; nWayTable = 0; nNodeTable = 0; + PolygonId = 0; + LineId = 0; /* pass 1: look at all ways and nodes, decide if they're interesting */ - buildmap_readosm_pass(1, fn); + buildmap_readosm_pass(1, fn, tileid); qsort(WayTable, nWayTable, sizeof(*WayTable), qsort_compare_unsigneds); qsort(NodeTable, nNodeTable, sizeof(*NodeTable), qsort_compare_unsigneds); @@ -2140,7 +1071,7 @@ copyWayTable(); /* pass 2: look at ways again, and finalize */ - buildmap_readosm_pass(2, fn); + buildmap_readosm_pass(2, fn, tileid); buildmap_osm_text_ways_shapeinfo(); @@ -2149,4 +1080,3 @@ buildmap_info("Number of nodes : %d, interesting %d", nNodes, nNodeTable); buildmap_info("Number of points: %d", nPoints); } -#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2015-10-20 15:06:05
|
Revision: 2947 http://sourceforge.net/p/roadmap/code/2947 Author: pgf Date: 2015-10-20 15:06:03 +0000 (Tue, 20 Oct 2015) Log Message: ----------- buildmap_osm_text.c: rewrite, using libreadosm Modified Paths: -------------- trunk/roadmap/src/buildmap_osm_main.c trunk/roadmap/src/buildmap_osm_text.c trunk/roadmap/src/config.mk trunk/roadmap/src/options.mk Modified: trunk/roadmap/src/buildmap_osm_main.c =================================================================== --- trunk/roadmap/src/buildmap_osm_main.c 2015-08-25 15:58:47 UTC (rev 2946) +++ trunk/roadmap/src/buildmap_osm_main.c 2015-10-20 15:06:03 UTC (rev 2947) @@ -227,12 +227,12 @@ /* create all parents of our file */ parent = roadmap_path_parent(BuildMapResult, - roadmap_osm_filename(0, 1, tileid, ".osm.gz")); + roadmap_osm_filename(0, 1, tileid, ".osm")); roadmap_path_create(parent); roadmap_path_free(parent); xmlfile = roadmap_path_join(BuildMapResult, - roadmap_osm_filename(0, 1, tileid, ".osm.gz")); + roadmap_osm_filename(0, 1, tileid, ".osm")); snprintf(cmd, sizeof(cmd), "%s " "--bits %d --bbox %s --xmlfile %s", Modified: trunk/roadmap/src/buildmap_osm_text.c =================================================================== --- trunk/roadmap/src/buildmap_osm_text.c 2015-08-25 15:58:47 UTC (rev 2946) +++ trunk/roadmap/src/buildmap_osm_text.c 2015-10-20 15:06:03 UTC (rev 2947) @@ -40,6 +40,7 @@ #include <unistd.h> #include <sys/mman.h> #include <time.h> +#include <readosm.h> #include "roadmap.h" #include "roadmap_types.h" @@ -115,7 +116,7 @@ /** * @brief some global variables */ -static int LineNo; /**< line number in the input file */ +// static int LineNo; /**< line number in the input file */ static int nPolygons = 0; /**< current polygon id (number of polygons until now) */ static int LineId = 0; /**< for buildmap_line_add */ @@ -558,7 +559,8 @@ } int -buildmap_osm_get_layer(int lookfor, char *tag, char *value, int *flags, int *layer) +buildmap_osm_get_layer(int lookfor, const char *tag, const char *value, + int *flags, int *layer) { int i,j; value_info_t *value_list; @@ -734,7 +736,7 @@ } void -buildmap_osm_text_way_drop_uninteresting(void) +bxuildmap_osm_text_way_drop_uninteresting(void) { if (wi.WayIsBuilding) { if (!wi.WayTourism && !wi.WayAmenity) { @@ -1063,12 +1065,10 @@ */ for (i = 0; i < 8; i++) { neighbor_tile = roadmap_osm_tileid_to_neighbor(tileid, i); - // fprintf(stderr, "loading ways list for neighbor 0x%x\n", neighbor_tile); /* if we already have that neighbor's ways, reuse */ for (j = 0; j < 8; j++) { if (Neighbor_Ways[j].tileid == neighbor_tile) { - // fprintf(stderr, "reusing neighbor 0x%x\n", neighbor_tile); new_neighbor_ways[i] = Neighbor_Ways[j]; Neighbor_Ways[j].ways = 0; break; @@ -1077,7 +1077,6 @@ /* didn't find it -- fetch the neighbor's ways */ if (j == 8) { - // fprintf(stderr, "fetching neighbor 0x%x\n", neighbor_tile); buildmap_osm_text_load_neighbor_ways(neighbor_tile, &new_neighbor_ways[i]); } @@ -1196,6 +1195,7 @@ return fclose(fp); } +#if BEFORE /** * @brief This is the gut of buildmap_osm_text : parse an OSM XML file * @param fdata an open file pointer, this will get read twice @@ -1348,7 +1348,11 @@ wi.WayIsInteresting = 0; } - buildmap_osm_text_way_drop_uninteresting(); + if (wi.WayIsBuilding) { + if (!wi.WayTourism && !wi.WayAmenity) { + wi.WayIsInteresting = 0; + } + } /* if the way is still flagged interesting, save it */ if (wi.WayId && wi.WayIsInteresting) @@ -1605,3 +1609,544 @@ passid, t[passid] - t[passid - 1]); } +#else + +char *readosm_errors[] = { + "READOSM_OK", + "READOSM_INVALID_SUFFIX", + "READOSM_FILE_NOT_FOUND", + + "READOSM_NULL_HANDLE", + "READOSM_INVALID_HANDLE", + "READOSM_INSUFFICIENT_MEMORY", + "READOSM_CREATE_XML_PARSER_ERROR", + "READOSM_READ_ERROR", + "READOSM_XML_ERROR", + "READOSM_INVALID_PBF_HEADER", + "READOSM_UNZIP_ERROR", + "READOSM_ABORT" +}; + +static int l_shoreline, l_boundary; +static int nWays, nNodes; + +static int +parse_node(const void *user_data, const readosm_node * node) +{ + const readosm_tag *tag; + const char *name = NULL, *place = NULL; + int layer = 0, flags = 0; + int i; + + nNodes++; + + for (i = 0; i < node->tag_count; i++) + { + tag = node->tags + i; + if (strcasecmp(tag->key, "name") == 0) { + name = tag->value; + break; + } else if (buildmap_osm_get_layer(PLACE, tag->key, tag->value, + &flags, &layer)) { + if (flags & PLACE) + place = tag->value; + break; + } + } + + if (name || (flags & PLACE)) { + buildmap_debug( "saving %s %s", place, name); + saveInterestingNode((nodeid_t)(node->id)); + } + + return READOSM_OK; +} + +static int +parse_node_finalize(const void *user_data, const readosm_node * node) +{ + const readosm_tag *tag; + const char *name = NULL, *place = NULL; + int layer = 0, flags = 0; + int point; + RoadMapString s; + int i; + + if (!isNodeInteresting(node->id)) + return READOSM_OK; + + for (i = 0; i < node->tag_count; i++) + { + tag = node->tags + i; + if (strcasecmp(tag->key, "name") == 0) { + name = tag->value; + } else if (buildmap_osm_get_layer(PLACE, tag->key, tag->value, + &flags, &layer)) { + if (flags & PLACE) + place = tag->value; + } + } + + /* Add this interesting node as a point */ + /* libreadosm uses float to handle lat/lon, which introduces + * small errors. try and ensure we get the same lat/lon as OSM + * provided. it doesn't make a difference in practice, but can + * be annoying when debugging, or comparing values later. + */ + point = buildmap_point_add( + (((int)(10000000. * node->longitude)+5)/10), + (((int)(10000000. * node->latitude)+5)/10) + ); + buildmap_osm_text_point_add(node->id, point); + + /* If it's a place, add it to the place table as well */ + if (place) { + int p; + if (layer) { + if (name) { + s = str2dict (DictionaryCity, (char *)name); + p = buildmap_place_add(s, layer, point); + } + buildmap_debug( "finishing %1.7f %1.7f %s (%d) %s layer: %d", + node->latitude, node->longitude, + place, p, name, layer); + } else { + buildmap_debug( "dropping %s %s", place, name); + } + } + + return READOSM_OK; +} + +static int +parse_way(const void *user_data, const readosm_way *way) +{ + const readosm_tag *tag; + const char *tourism = NULL, *amenity = NULL; + int adminlevel = 0; + int is_building = 0, is_territorial = 0, is_coast = 0; // booleans + int layer = 0, flags = 0; + int i; + + nWays++; + + if (way->node_ref_count == 0) + return READOSM_OK; + + for (i = 0; i < way->tag_count; i++) + { + tag = way->tags + i; + + if (strcasecmp(tag->key, "building") == 0) { + is_building = 1; +#ifdef BUILDMAP_NAVIGATION_SUPPORT + } else if (strcasecmp(tag->key, "oneway") == 0) { + is_oneway = !strcasecmp(tag->value, "yes"); +#endif + } else if (strcasecmp(tag->key, "tourism") == 0) { + tourism = tag->value; + } else if (strcasecmp(tag->key, "amenity") == 0) { + amenity = tag->value; + } else if (strcasecmp(tag->key, "admin_level") == 0) { + adminlevel = atoi(tag->value); + } else if (strcasecmp(tag->key, "border_type") == 0) { + is_territorial = !strcasecmp(tag->value, "territorial"); + } else if (strcasecmp(tag->key, "natural") == 0 && + strcasecmp(tag->key, "coastline") == 0) { + is_coast = 1; + } + + // really? + buildmap_osm_get_layer(ANY, tag->key, tag->value, &flags, &layer); + } + + + /* only save buildings that are amenities or touristic */ + if (is_building) { + if (tourism) { + buildmap_osm_get_layer(PLACE, "tourism", tourism, &flags, &layer); + } else if (amenity) { + buildmap_osm_get_layer(PLACE, "amenity", amenity, &flags, &layer); + } else { + return READOSM_OK; + } + } + + if (layer == 0) { + if (is_coast) { + layer = l_shoreline; + } else if (adminlevel) { + /* national == 2, state == 4, ignore lesser boundaries */ + /* also ignore territorial (marine) borders */ + if (adminlevel > 4 || is_territorial) { + return READOSM_OK; + } +#if LATER /* we don't actually have the points yet in pass 1 */ + else if (adminlevel > 2) { + from_point = buildmap_osm_text_point_get(WayNodes[0]); + fromlon = buildmap_point_get_longitude(from_point); + fromlat = buildmap_point_get_latitude(from_point); + + /* if we're not (roughly) in north america, + * discard state boundaries as well. */ + if (fromlon > -32 || fromlat < 17) { + /* east of the azores or south of mexico */ + return READOSM_OK; + } + } +#endif + + layer = l_boundary; + } + } + + if (layer) { + saveInterestingWay((wayid_t)(way->id)); + for (i = 0; i < way->node_ref_count; i++) + saveInterestingNode((nodeid_t)way->node_refs[i]); + } + + return READOSM_OK; +} + +static int +parse_way_finalize(const void *user_data, const readosm_way *way) +{ + const readosm_tag *tag; + const char *tourism = NULL, *amenity = NULL, *name = NULL, *ref = NULL; + int is_oneway = 0; // booleans + int layer = 0, flags = 0; + int from_point, to_point, line, street; + RoadMapString rms_dirp, rms_dirs, rms_type, rms_name; + char compound_name[1024]; + const char *n; + int i, j; + + if (!isWayInteresting(way->id)) + return READOSM_OK; + + if (way->node_ref_count == 0) + return READOSM_OK; + + for (i = 0; i < way->tag_count; i++) + { + tag = way->tags + i; + + if (strcasecmp(tag->key, "name") == 0) { + name = tag->value; + } else if (strcasecmp(tag->key, "ref") == 0) { + ref = tag->value; +#ifdef BUILDMAP_NAVIGATION_SUPPORT + } else if (strcasecmp(tag->key, "oneway") == 0) { + is_oneway = !strcasecmp(tag->value, "yes"); +#endif + } else if (strcasecmp(tag->key, "tourism") == 0) { + tourism = tag->value; + } else if (strcasecmp(tag->key, "amenity") == 0) { + amenity = tag->value; + } + + // this will preserve the layer/flags for the last tag that + // indicates a layer. + buildmap_osm_get_layer(ANY, tag->key, tag->value, &flags, &layer); + } + + if ( layer == 0) { + wayid_t *wp; + buildmap_debug("discarding way %d, not interesting (%s)", way->id, name); + wp = isWayInteresting(way->id); + if (wp) { + WayTableCopy[wp-WayTable] = 0; + } + return READOSM_OK; + } + + rms_dirp = str2dict(DictionaryPrefix, ""); + rms_dirs = str2dict(DictionarySuffix, ""); + rms_type = str2dict(DictionaryType, ""); + rms_name = 0; + + + if ((flags & PLACE) && (tourism || amenity)) { + /* we're finishing a way, but the flags may say PLACE if + * we're treating a polygon as a place, for instance. find + * the center of the bounding box (which is good enough, for + * these purposes), and make it into a place. + */ + int minlat = 999999999, maxlat = -999999999; + int minlon = 999999999, maxlon = -999999999; + int point, lon, lat; + + for (j = 0; j < way->node_ref_count; j++) { + point = buildmap_osm_text_point_get(way->node_refs[j]); + lon = buildmap_point_get_longitude(point); + lat = buildmap_point_get_latitude(point); + + if (lat < minlat) minlat = lat; + if (lat > maxlat) maxlat = lat; + if (lon < minlon) minlon = lon; + if (lon > maxlon) maxlon = lon; + } + + lat = (maxlat + minlat) / 2; + lon = (maxlon + minlon) / 2; + + /* this code looks like buildmap_osm_text_node_finish() */ + point = buildmap_point_add(lon, lat); + + if (!name) + name = FromXmlAndDup("??"); + + if (layer) { + RoadMapString s; + int p; + s = str2dict (DictionaryCity, (char *)name); + p = buildmap_place_add(s, layer, point); + buildmap_debug( "wayplace: finishing %f %f %s (%d) %s layer: %d", + (float)lat/1000000.0, (float)lon/1000000.0, + tourism ? tourism : amenity, p, name, layer); + } else { + buildmap_debug( "dropping %s %s", + tourism ? tourism : amenity, name); + } + + + } else if ((flags & AREA) && + (way->node_refs[0] == way->node_refs[way->node_ref_count-1])) { + /* see http://wiki.openstreetmap.org/wiki/The_Future_of_Areas + * for why the above conditions are simplistic */ + static int polyid = 0; + static int cenid = 0; + + /* + * Detect an AREA -> create a polygon + */ + nPolygons++; + cenid++; + polyid++; + + rms_name = str2dict(DictionaryStreet, name); + buildmap_polygon_add_landmark (nPolygons, layer, rms_name); + buildmap_polygon_add(nPolygons, cenid, polyid); + + for (j=1; j<way->node_ref_count; j++) { + int prevpoint = + buildmap_osm_text_point_get(way->node_refs[j-1]); + int point = + buildmap_osm_text_point_get(way->node_refs[j]); + + LineId++; + buildmap_line_add + (LineId, layer, prevpoint, point, + ROADMAP_LINE_DIRECTION_BOTH); + buildmap_polygon_add_line (cenid, polyid, LineId, POLYGON_SIDE_RIGHT); + } + } else { + /* + * Register the way + * + * Need to do this several different ways : + * - begin and end points form a "line" + * - register street name + * - adjust the square + * - keep memory of the point coordinates so we can + * postprocess the so called shapes (otherwise we only have + * straight lines) + */ + + int *lonsbuf, *latsbuf; + + /* Street name */ + buildmap_debug ("Way %d [%s] ref [%s]", way->id, + name ? name : "", ref ? ref : ""); + + if (ref) { + char *d = compound_name; + const char *s = ref; +#define ENDASHSEP " \xe2\x80\x93 " +#define EMDASHSEP " \xe2\x80\x94 " + while (*s) { /* OSM separates multi-value refs with ';' */ + if (*s == ';') { + d += sprintf(d, ENDASHSEP); + } else { + *d++ = *s; + } + s++; + } + n = compound_name; + *d = '\0'; + + if (name) { + // sprintf(d, ", %s", name); + sprintf(d, "%s%s", ENDASHSEP, name); + } + } else { + n = name; + } + rms_name = str2dict(DictionaryStreet, n); + + LineId++; + /* Map begin and end points to internal point id */ + from_point = buildmap_osm_text_point_get(way->node_refs[0]); + to_point = buildmap_osm_text_point_get(way->node_refs[way->node_ref_count-1]); + + line = buildmap_line_add(LineId, + layer, from_point, to_point, is_oneway); + + street = buildmap_street_add(layer, + rms_dirp, rms_name, rms_type, + rms_dirs, line); + buildmap_range_add_no_address(line, street); + + /* + * We're passing too much here - the endpoints of + * the line don't need to be passed to the shape + * module. We're keeping them here just to be on + * the safe side, they'll be ignored in + * buildmap_osm_text_ways_shapeinfo(). + * + * The lonsbuf/latsbuf are never freed, need to be + * preserved for shape registration which happens + * at the end of the program run, so exit() will + * free this for us. + */ + + lonsbuf = calloc(way->node_ref_count, sizeof(way->node_refs[0])); + latsbuf = calloc(way->node_ref_count, sizeof(way->node_refs[0])); + + for (j=0; j < way->node_ref_count; j++) { + int point = + buildmap_osm_text_point_get(way->node_refs[j]); + int lon = buildmap_point_get_longitude(point); + int lat = buildmap_point_get_latitude(point); + + /* Keep info for the shapes */ + lonsbuf[j] = lon; + latsbuf[j] = lat; + + buildmap_square_adjust_limits(lon, lat); + } + + if (numshapes == nallocshapes) { + /* Allocate additional space (in big + * chunks) when needed */ + if (shapes) + nallocshapes *= 2; + else + nallocshapes = 1000; + shapes = realloc(shapes, + nallocshapes * sizeof(struct shapeinfo)); + buildmap_check_allocated(shapes); + } + + buildmap_debug("lineid %d way->node_ref_count %d", + LineId, way->node_ref_count); + /* Keep info for the shapes */ + shapes[numshapes].lons = lonsbuf; + shapes[numshapes].lats = latsbuf; + shapes[numshapes].count = way->node_ref_count; + shapes[numshapes].lineid = LineId; + + numshapes++; + } + return READOSM_OK; +} + +#if NEEDED +static int +parse_relation(const void *user_data, const readosm_relation * relation) +{ + return READOSM_OK; +} +#endif + +void buildmap_readosm_pass(int pass, char *fn) +{ + int ret; + const void *handle; + + buildmap_info("Starting pass %d", pass); + // buildmap_set_source("pass %d", pass); + + ret = readosm_open(fn, &handle); + if (ret != READOSM_OK) { + buildmap_fatal(0, "buildmap_osm_text: couldn't open \"%s\", %s", + fn, readosm_errors[-ret]); + return; + } + + switch (pass) { + case 1: ret = readosm_parse(handle, NULL, + parse_node, parse_way, NULL); + break; + case 2: ret = readosm_parse(handle, NULL, + parse_node_finalize, parse_way_finalize, NULL); + break; + } + if (ret != READOSM_OK) { + buildmap_fatal(0, "buildmap_osm_text pass %d: %s", + pass, readosm_errors[-ret]); + return; + } + + ret = readosm_close(handle); + if (ret != READOSM_OK) { + buildmap_fatal(0, "buildmap_osm_text pass %d: %s", + pass, readosm_errors[-ret]); + return; + } +} + + +void +buildmap_osm_text_read(char *fn, int tileid, + int country_num, int division_num) +{ + + if (tileid) + buildmap_osm_text_neighbor_way_maps(tileid); + + buildmap_osm_text_point_hash_reset(); + + buildmap_osm_text_reset_way(); + buildmap_osm_text_reset_node(); + + DictionaryPrefix = buildmap_dictionary_open("prefix"); + DictionaryStreet = buildmap_dictionary_open("street"); + DictionaryType = buildmap_dictionary_open("type"); + DictionarySuffix = buildmap_dictionary_open("suffix"); + DictionaryCity = buildmap_dictionary_open("city"); + + buildmap_osm_common_find_layers (); + l_shoreline = buildmap_layer_get("shore");; + l_boundary = buildmap_layer_get("boundaries");; + + nWays = nNodes = 0; + numshapes = 0; + nPolygons = 0; + LineId = 0; + nWayTable = 0; + nNodeTable = 0; + + /* pass 1: look at all ways and nodes, decide if they're interesting */ + buildmap_readosm_pass(1, fn); + + qsort(WayTable, nWayTable, sizeof(*WayTable), qsort_compare_unsigneds); + qsort(NodeTable, nNodeTable, sizeof(*NodeTable), qsort_compare_unsigneds); + + /* we've finished saving ways. we need a fresh place to mark + * the ones we're discarding, while still keeping the original list + * quickly searchable. */ + copyWayTable(); + + /* pass 2: look at ways again, and finalize */ + buildmap_readosm_pass(2, fn); + + buildmap_osm_text_ways_shapeinfo(); + + buildmap_info("Ways %d, interesting %d", + nWays, nWayTable); + buildmap_info("Number of nodes : %d, interesting %d", nNodes, nNodeTable); + buildmap_info("Number of points: %d", nPoints); +} +#endif Modified: trunk/roadmap/src/config.mk =================================================================== --- trunk/roadmap/src/config.mk 2015-08-25 15:58:47 UTC (rev 2946) +++ trunk/roadmap/src/config.mk 2015-10-20 15:06:03 UTC (rev 2947) @@ -133,6 +133,9 @@ SHAPEFILES = NO # SHAPEFILES = YES +# building OSM libraries relies on libreadosm +READOSM = YES + # For better-looking lines and a better looking street-label # font, RoadMap can use the "Anti-Grain Geometry" library, # libagg.a, on some desktops. If you don't have this library, Modified: trunk/roadmap/src/options.mk =================================================================== --- trunk/roadmap/src/options.mk 2015-08-25 15:58:47 UTC (rev 2946) +++ trunk/roadmap/src/options.mk 2015-10-20 15:06:03 UTC (rev 2947) @@ -193,6 +193,11 @@ LIBS += -lshp endif +# libreadosm support needed for building OSM maps +ifneq ($(strip $(READOSM)),NO) + LIBS += -lreadosm +endif + # rotation support in QT/QPE? ifeq ($(strip $(QT_NO_ROTATE)),YES) CFLAGS += -DQT_NO_ROTATE This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2015-08-25 15:58:49
|
Revision: 2946 http://sourceforge.net/p/roadmap/code/2946 Author: pgf Date: 2015-08-25 15:58:47 +0000 (Tue, 25 Aug 2015) Log Message: ----------- buildmap_osm_text.c: places: pick up ways tagged "amenity" just as building ways might be "tourism" (hotel, guesthouse, etc), they might also be "amenity" (fuel, pub, etc). also, pick up places that are unnamed. label them "??". Modified Paths: -------------- trunk/roadmap/src/buildmap_osm_text.c Modified: trunk/roadmap/src/buildmap_osm_text.c =================================================================== --- trunk/roadmap/src/buildmap_osm_text.c 2015-08-25 15:58:44 UTC (rev 2945) +++ trunk/roadmap/src/buildmap_osm_text.c 2015-08-25 15:58:47 UTC (rev 2946) @@ -90,6 +90,7 @@ int WayIsOneWay; /**< is this way one direction only */ int WayIsBuilding; /**< this way represents a building */ char *WayTourism; /**< value of tourism tag, if any */ + char *WayAmenity; /**< value of amenity tag, if any */ int WayAdminLevel; /**< boundaries */ int WayTerritorial; /**< is this a territorial boundary? */ int WayCoast; /**< coastline */ @@ -178,6 +179,7 @@ if (wi.WayName) free(wi.WayName); if (wi.WayStreetRef) free(wi.WayStreetRef); if (wi.WayTourism) free(wi.WayTourism); + if (wi.WayAmenity) free(wi.WayAmenity); memset(&wi, 0, sizeof(wi)); } @@ -289,13 +291,13 @@ if (ni.NodeName && ni.NodePlace) { if (ni.NodeLayer) { - buildmap_verbose("finishing %f %f %s %s layer: %d", + buildmap_debug( "finishing %f %f %s %s layer: %d", (float)ni.NodeLat/1000000.0, (float)ni.NodeLon/1000000.0, ni.NodePlace, ni.NodeName, ni.NodeLayer); s = str2dict (DictionaryCity, (char *) ni.NodeName); buildmap_place_add(s, ni.NodeLayer, point); } else { - buildmap_verbose("dropping %s %s", ni.NodePlace, ni.NodeName); + buildmap_debug( "dropping %s %s", ni.NodePlace, ni.NodeName); } } @@ -693,10 +695,10 @@ #endif if (strcasecmp(tag, "building") == 0) { - if (strcasecmp(value, "yes") == 0) { - /* what else would the value be? */ - wi.WayIsBuilding = 1; - } + /* the value can be things like "shed", "barn", "temple", + * or "yes". we don't really care which. + */ + wi.WayIsBuilding = 1; return; } @@ -706,6 +708,12 @@ wi.WayTourism = FromXmlAndDup(value); return; } + if (strcasecmp(tag, "amenity") == 0) { + if (wi.WayAmenity) + free(wi.WayAmenity); + wi.WayAmenity = FromXmlAndDup(value); + return; + } if (strcasecmp(tag, "admin_level") == 0) { wi.WayAdminLevel = atoi(value); @@ -729,7 +737,7 @@ buildmap_osm_text_way_drop_uninteresting(void) { if (wi.WayIsBuilding) { - if (!wi.WayTourism) { + if (!wi.WayTourism && !wi.WayAmenity) { wi.WayIsInteresting = 0; } } @@ -770,6 +778,8 @@ if (wi.WayIsBuilding) { if (wi.WayTourism) { buildmap_osm_get_layer(PLACE, "tourism", wi.WayTourism, &wi.WayFlags, &wi.WayLayer); + } else if (wi.WayAmenity) { + buildmap_osm_get_layer(PLACE, "amenity", wi.WayAmenity, &wi.WayFlags, &wi.WayLayer); } else { buildmap_osm_text_reset_way(); return; @@ -821,7 +831,7 @@ rms_name = 0; - if ((wi.WayFlags & PLACE) && wi.WayTourism) { + if ((wi.WayFlags & PLACE) && (wi.WayTourism || wi.WayAmenity)) { /* we're finishing a way, but the flags may say PLACE if * we're treating a polygon as a place, for instance. find * the center of the bounding box (which is good enough, for @@ -848,17 +858,21 @@ /* this code looks like buildmap_osm_text_node_finish() */ point = buildmap_point_add(lon, lat); - if (wi.WayName && wi.WayTourism) { - if (wi.WayLayer) { - RoadMapString s; - buildmap_verbose("wayplace: finishing %f %f %s %s layer: %d", - (float)lat/1000000.0, (float)lon/1000000.0, - wi.WayTourism, wi.WayName, wi.WayLayer); - s = str2dict (DictionaryCity, (char *) wi.WayName); - buildmap_place_add(s, wi.WayLayer, point); - } else { - buildmap_verbose("dropping %s %s", wi.WayTourism, wi.WayName); - } + if (!wi.WayName) + wi.WayName = FromXmlAndDup("??"); + + if (wi.WayLayer) { + RoadMapString s; + buildmap_debug( "wayplace: finishing %f %f %s %s layer: %d", + (float)lat/1000000.0, (float)lon/1000000.0, + wi.WayTourism ? wi.WayTourism : wi.WayAmenity, + wi.WayName, wi.WayLayer); + s = str2dict (DictionaryCity, (char *) wi.WayName); + buildmap_place_add(s, wi.WayLayer, point); + } else { + buildmap_debug( "dropping %s %s", + wi.WayTourism ? wi.WayTourism : wi.WayAmenity, + wi.WayName); } @@ -991,7 +1005,7 @@ buildmap_check_allocated(shapes); } - buildmap_debug("lineid %d wi.nWayNodes %d\n", + buildmap_debug("lineid %d wi.nWayNodes %d", LineId, wi.nWayNodes); /* Keep info for the shapes */ shapes[numshapes].lons = lonsbuf; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2015-08-25 15:58:46
|
Revision: 2945 http://sourceforge.net/p/roadmap/code/2945 Author: pgf Date: 2015-08-25 15:58:44 +0000 (Tue, 25 Aug 2015) Log Message: ----------- roadmap_math, and others: fix naming of roadmap_math_declutter() "roadmap_math_should_declutter()" is a better name. (of course, the return value is also flipped from previously.) Modified Paths: -------------- trunk/roadmap/src/roadmap_features.c trunk/roadmap/src/roadmap_landmark.c trunk/roadmap/src/roadmap_layer.c trunk/roadmap/src/roadmap_math.c trunk/roadmap/src/roadmap_math.h Modified: trunk/roadmap/src/roadmap_features.c =================================================================== --- trunk/roadmap/src/roadmap_features.c 2015-08-25 15:58:38 UTC (rev 2944) +++ trunk/roadmap/src/roadmap_features.c 2015-08-25 15:58:44 UTC (rev 2945) @@ -68,7 +68,7 @@ RoadMapPen pen = RoadMapFeatureList->pen; char *sprite = RoadMapFeatureList->sprite; - if ( ! roadmap_math_declutter(RoadMapFeatureList->label_declutter)) { + if ( roadmap_math_should_declutter(RoadMapFeatureList->label_declutter)) { pen = NULL; /* not drawing label? make sure there's a sprite */ if (sprite == NULL) { @@ -77,7 +77,7 @@ } if ( RoadMapFeatureList->sprite_declutter >= 0 && - ! roadmap_math_declutter(RoadMapFeatureList->sprite_declutter)) { + roadmap_math_should_declutter(RoadMapFeatureList->sprite_declutter)) { sprite = NULL; } Modified: trunk/roadmap/src/roadmap_landmark.c =================================================================== --- trunk/roadmap/src/roadmap_landmark.c 2015-08-25 15:58:38 UTC (rev 2944) +++ trunk/roadmap/src/roadmap_landmark.c 2015-08-25 15:58:44 UTC (rev 2945) @@ -91,7 +91,7 @@ roadmap_sprite_draw (sprite, &guipoint, 0); } - if (pen && roadmap_math_declutter(RoadMapLandmarkDeclutter )) { + if (pen && ! roadmap_math_should_declutter(RoadMapLandmarkDeclutter )) { roadmap_canvas_select_pen (pen); /* FIXME -- We should do label collision detection, which Modified: trunk/roadmap/src/roadmap_layer.c =================================================================== --- trunk/roadmap/src/roadmap_layer.c 2015-08-25 15:58:38 UTC (rev 2944) +++ trunk/roadmap/src/roadmap_layer.c 2015-08-25 15:58:44 UTC (rev 2945) @@ -260,7 +260,7 @@ return 0; d = roadmap_config_get_integer (&layer->declutter); - r = roadmap_math_declutter (d); + r = ! roadmap_math_should_declutter (d); return r; } @@ -1174,7 +1174,7 @@ layerp = RoadMapLayerCurrentClass->layers + layer; d = roadmap_config_get_integer (&layerp->label_declutter); roadmap_log (ROADMAP_DEBUG, "roadmap_layer_road_last: declutter %d", d); - return roadmap_math_declutter (d); + return ! roadmap_math_should_declutter (d); } Modified: trunk/roadmap/src/roadmap_math.c =================================================================== --- trunk/roadmap/src/roadmap_math.c 2015-08-25 15:58:38 UTC (rev 2944) +++ trunk/roadmap/src/roadmap_math.c 2015-08-25 15:58:44 UTC (rev 2945) @@ -1155,10 +1155,10 @@ } -/* returns true if the current zoom is _less_ than the declutter level */ -int roadmap_math_declutter (int declutter_level) { +/* returns true if the current zoom is >= than the declutter level */ +int roadmap_math_should_declutter (int declutter_level) { - return (RoadMapContext->zoom < declutter_level); + return (RoadMapContext->zoom >= declutter_level); } Modified: trunk/roadmap/src/roadmap_math.h =================================================================== --- trunk/roadmap/src/roadmap_math.h 2015-08-25 15:58:38 UTC (rev 2944) +++ trunk/roadmap/src/roadmap_math.h 2015-08-25 15:58:44 UTC (rev 2945) @@ -64,7 +64,7 @@ void roadmap_math_get_focus (RoadMapArea *area); void roadmap_math_release_focus (void); -int roadmap_math_declutter (int level); +int roadmap_math_should_declutter (int level); int roadmap_math_thickness (int base, int declutter, int use_multiple_pens); int roadmap_math_areas_intersect This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2015-08-25 15:58:41
|
Revision: 2944 http://sourceforge.net/p/roadmap/code/2944 Author: pgf Date: 2015-08-25 15:58:38 +0000 (Tue, 25 Aug 2015) Log Message: ----------- doc updates Modified Paths: -------------- trunk/roadmap/doc/ChangeLog trunk/roadmap/doc/Configuration Modified: trunk/roadmap/doc/ChangeLog =================================================================== --- trunk/roadmap/doc/ChangeLog 2015-08-25 15:58:35 UTC (rev 2943) +++ trunk/roadmap/doc/ChangeLog 2015-08-25 15:58:38 UTC (rev 2944) @@ -1,6 +1,83 @@ RoadMap Changelog + - The polygon node limit is now 32bits wide, allowing for lots and + lots of big polygons. Backward compatiblity with old maps is + still maintained. + - The php subdirectory is gone, along the helper programs that + were used to create quadtiles. Quadtiles are now converted by the + native XML parser, just as other OSM source data is converted. + roadmap_osm_text.c has seen a lot of cleanup, and is at least 10x + faster than it was before. + + - The new OSM download helper script now points at the OSM + "Overpass API" servers, which are read-only servers intended for + higher volume downloading. These servers are easier to use, are + faster, and support bigger map segment requests. + + - RoadMap now builds a world basemap (using data from + naturalearthdata.com) which gives country (and US state) outlines. + These are very rough outlines, but help give a geographic sense + while one is panning or zooming through an area not covered by the + current maps. + + - Class file entries now assume the previous class.name if if that + field is left empty on a line + + - Map "places" can now be displayed and labeled, e.g. cities, + towns, villages, points of interest, and are configured just as + lines and polygons are, in the class file. Finally. + + + - New POI support: restaurants, lodging, fuel, ATM (currently), + complete with sprites and labels + + - Finally fully enabled the "ADVANCED_STYLE" canvas ifdef, giving + pens the ability to have many more properties. Only a few + implemented for gtk2. + + - Openstreetmap XML is now parsed a bit more carefully. The next + step will be to switch to using libreadosm. + + - We now do a better job of tracking online/offline status of a + GPS device, when talking to it via gpsd. + + - Any keyboard key can now be rebound from a user or system + configuration file. I believe this makes the entire UI + redefinable by a user. + + - Text scaling for labels is now implemented via pen definitions + in the class file. + + - Implemented angled street labels, and font size control, for + gtk2. The AGG implementation is no longer functionally superior + to plain GTK2 as a canvas implementation. (It still looks much + better, but on a slow machine, the jaggies you get with GTK2 are + worth it, just to make the map update faster. + + - Support for the old "Hershey" line font has been dropped. + + - A bug was causing street labels to be angled incorrectly with + respect to their street. They are now shown parallel. + + - Cleaned up the tables in buildmap_osm, making it much easier to + add a new layer to the maps. + + - Voice announcements detailing progress are available when + following a GPX route. + + - The current route name is now saved across program restarts, if + possible, and is displayed in window title. + + - RoadMap's dependency on using the exact same class file that was + used to when buildmap was run has been eliminated: maps can not + contain more, or fewer, layers than RoadMap's class file wishes to + display. (The maps now contain an index of the classes used when + building. Roadmap constructs a mapping to that index at runtime.) + + - Several performance improvements. + + Roadmap v1.2.1 (February, 2009) This list is current as of 2/8/2009, created with the help of Modified: trunk/roadmap/doc/Configuration =================================================================== --- trunk/roadmap/doc/Configuration 2015-08-25 15:58:35 UTC (rev 2943) +++ trunk/roadmap/doc/Configuration 2015-08-25 15:58:38 UTC (rev 2944) @@ -160,30 +160,32 @@ parameters ("-f" and "On %N"). -== Menus and Toolbar == +== Menus, Toolbar, and Key bindings == - The items shown in the RoadMap and RoadGps menus and toolbars can be - redefined by the user in text configuration files. Note that each - program comes with a built-in menus and toolbar configuration that - serves as the default, so none of these configuration files is required - to be present for RoadMap or RoadGps to work. In fact, RoadMap is - distributed with none of the configuration files described in this - section. (Example files are provided for RoadMap, but are not installed - automatically.) + The items shown in the RoadMap and RoadGps menus and toolbars, as + well as the keyboard bindings, can be redefined by the user in + text configuration files. Note that each program comes with a + built-in versions of these tables which serve serves as the + defaults, so none of these configuration files is required to be + present for RoadMap or RoadGps to work. In fact, RoadMap is + distributed with none of the configuration files described in + this section. (Example files are provided for RoadMap, but are + not installed automatically.) - It must be realized that making any change to the menus and the toolbar - comes at a price: this documentation was written using the standard - user interface. Modifying the user interface is likely to make this - documentation even more confusing than it originally is. + It must be realized that making any change to the menus, toolbar, + or key bindings comes at a price: this documentation was written + using the standard user interface. Modifying the user interface + is likely to make this documentation even more confusing than it + originally is. - The major reason for customizing the menus or the toolbar is to let - the user tailor the toolbar to fill small screens (such as a PDA) with - his preferred controls at the most convenient place. Using a GUI in + The major reason for customizing the is to let the user tailor + the toolbar to fill small screens (such as a PDA) with his + preferred controls at the most convenient place. Using a GUI in a car or on a bike is challenging enough. - The configuration files are organized with one entity per line. An - entity is either the title of a menu, the name of an action, a separator - or a comment. + The configuration files are organized with one entity per line. + An entity is either the title of a menu, the name of an action, a + separator or a comment. Each menu is described by it's title (prefixed with character '/'), followed by the list of items in that menu. The title of a menu is @@ -295,6 +297,15 @@ Remember that the toolbar labels should be very short, since the toolbar has a limited size. + Keyboard bindings are configured in a "roadmap.keys" file. Each + line should consist of the name of key, an '=' symbol, and the + name of the RoadMap action to which it is bound. For example: +``` + LeftArrow = resumeroute + C = gpsconsole + Q = quit +``` + == On-Screen Objects == RoadMap can display small images on the screen (on-screen objects) which @@ -1093,6 +1104,12 @@ - //Format:// string - //Default:// default + : Trip.Route Name + The name of the last selected route. This route will be + (re)selected if it exists in the chosen trip file. + - //Format:// string + - //Default:// none + : Delta.X The horizontal map shift compare to the reference position. - //Format:// number of pixels @@ -1160,18 +1177,13 @@ (*) NOTE: the default position values match 1 Market St, San Francisco, CA. -== Schema Items == +== Class Items == - The schema file uses the same format as the preference file. It defines - the properties of the various categories of objects that make a map. - the list of categories matches the list of Tiger file's categories - (see Tiger's CFCC field) that have been filtered by buildmap. + The Class file uses the same format as the preference file. It defines + the properties of the various categories of objects that make a map + when the map database is built, as well as the categories of + objects which RoadMap will display on the screen. - The two differences with the preferences files are that there is no - pre-defined category in RoadMap: categories are defined by the maps - (FIXME: this is still to be done--as a temporary hack, the categories - have been hardcoded somewhere) and there is no default value. - For each category, RoadMap use the following items: : <category>.Class: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2015-08-25 15:58:37
|
Revision: 2943 http://sourceforge.net/p/roadmap/code/2943 Author: pgf Date: 2015-08-25 15:58:35 +0000 (Tue, 25 Aug 2015) Log Message: ----------- docs/Configuration: add %1 and %2 to message format list Modified Paths: -------------- trunk/roadmap/doc/Configuration Modified: trunk/roadmap/doc/Configuration =================================================================== --- trunk/roadmap/doc/Configuration 2015-08-25 15:58:29 UTC (rev 2942) +++ trunk/roadmap/doc/Configuration 2015-08-25 15:58:35 UTC (rev 2943) @@ -118,6 +118,8 @@ | %v | Total number of available satellites. | %x | Distance from one side of the screen to the other. | %y | Distance from the top to the bottom of the screen. + | %1 | Angle (in vague english) to the next waypoint + | %2 | Angle (in vague english) to the one after that waypoint Note that the time is always shown using the military format: HH:MM. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2015-08-25 15:58:32
|
Revision: 2942 http://sourceforge.net/p/roadmap/code/2942 Author: pgf Date: 2015-08-25 15:58:29 +0000 (Tue, 25 Aug 2015) Log Message: ----------- roadmap_locator: improve debug logging Modified Paths: -------------- trunk/roadmap/src/roadmap_locator.c Modified: trunk/roadmap/src/roadmap_locator.c =================================================================== --- trunk/roadmap/src/roadmap_locator.c 2015-08-25 15:54:28 UTC (rev 2941) +++ trunk/roadmap/src/roadmap_locator.c 2015-08-25 15:58:29 UTC (rev 2942) @@ -290,7 +290,7 @@ while(1) { name = roadmap_metadata_get_attribute_next ("Class", types[t], i); if (name == NULL || name[0] == 0) { - roadmap_log(ROADMAP_DEBUG, "Found %d %s in db\n", i, types[t]); + roadmap_log(ROADMAP_DEBUG, "Found %d %s layers in db", i, types[t]); break; } /* @@ -309,7 +309,7 @@ db_layer++; } } - roadmap_log(ROADMAP_DEBUG, "Found %d total types in map %d (0x%x)\n", + roadmap_log(ROADMAP_DEBUG, "Found %d total layer types in map %d (0x%x)", db_layer, RoadMapActiveCounty, -RoadMapActiveCounty); RoadMapCountyCache[RoadMapActiveCountyCache].mapcount = db_layer; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2015-08-25 15:54:31
|
Revision: 2941 http://sourceforge.net/p/roadmap/code/2941 Author: pgf Date: 2015-08-25 15:54:28 +0000 (Tue, 25 Aug 2015) Log Message: ----------- roadmap_option: add sticky option for starting in full screen mode starting roadmap with the --full option will set the General.FullScreen preference to "yes", which will cause this and all subsequent startups to be in fullscreen mode. change the preference setting to "no" to undo. Modified Paths: -------------- trunk/roadmap/doc/Usage trunk/roadmap/src/roadmap_option.c trunk/roadmap/src/roadmap_start.c Modified: trunk/roadmap/doc/Usage =================================================================== --- trunk/roadmap/doc/Usage 2015-08-07 14:59:32 UTC (rev 2940) +++ trunk/roadmap/doc/Usage 2015-08-25 15:54:28 UTC (rev 2941) @@ -59,6 +59,10 @@ Use the imperial system for all units. This option is sticky (preference item General.Unit = "imperial"). + : --full + Go directly to full screen mode on startup. This option is sticky + (preference item General.FullScreen = "yes"). + : --no-area Do not show the polygons (parks, hospitals, malls, airports, etc..). Modified: trunk/roadmap/src/roadmap_option.c =================================================================== --- trunk/roadmap/src/roadmap_option.c 2015-08-07 14:59:32 UTC (rev 2940) +++ trunk/roadmap/src/roadmap_option.c 2015-08-25 15:54:28 UTC (rev 2941) @@ -39,6 +39,9 @@ static RoadMapConfigDescriptor RoadMapConfigGeneralUnit = ROADMAP_CONFIG_ITEM("General", "Unit"); +static RoadMapConfigDescriptor RoadMapConfigGeneralFullScreen = + ROADMAP_CONFIG_ITEM("General", "FullScreen"); + static RoadMapConfigDescriptor RoadMapConfigAddressPosition = ROADMAP_CONFIG_ITEM("Address", "Position"); @@ -258,7 +261,12 @@ roadmap_config_set (&RoadMapConfigGeneralUnit, "imperial"); } +static void roadmap_option_set_fullscreen (const char *value) { + roadmap_config_set (&RoadMapConfigGeneralFullScreen, "yes"); +} + + static void roadmap_option_set_no_area (const char *value) { roadmap_option_no_area = 1; @@ -423,6 +431,9 @@ {"--imperial", "", roadmap_option_set_imperial, 1, "Use the imperial system for all units"}, + {"--full", "", roadmap_option_set_fullscreen, 1, + "Start in full screen mode"}, + {"--no-area", "", roadmap_option_set_no_area, 1, "Do not show the polygons (parks, hospitals, airports, etc..)"}, Modified: trunk/roadmap/src/roadmap_start.c =================================================================== --- trunk/roadmap/src/roadmap_start.c 2015-08-07 14:59:32 UTC (rev 2940) +++ trunk/roadmap/src/roadmap_start.c 2015-08-25 15:54:28 UTC (rev 2941) @@ -118,6 +118,9 @@ static RoadMapConfigDescriptor RoadMapConfigGeneralUnit = ROADMAP_CONFIG_ITEM("General", "Unit"); +static RoadMapConfigDescriptor RoadMapConfigGeneralFullScreen = + ROADMAP_CONFIG_ITEM("General", "FullScreen"); + static RoadMapConfigDescriptor RoadMapConfigGeneralKeyboard = ROADMAP_CONFIG_ITEM("General", "Keyboard"); @@ -1694,6 +1697,9 @@ ("preferences", &RoadMapConfigGeneralKeyboard, "yes", "no", NULL); roadmap_config_declare_enumeration + ("preferences", &RoadMapConfigGeneralFullScreen, "no", "yes", NULL); + + roadmap_config_declare_enumeration ("preferences", &RoadMapConfigGeneralShowErrors, "yes", "no", NULL); roadmap_config_declare @@ -1771,6 +1777,7 @@ roadmap_option (argc, argv, 1, roadmap_start_usage); + #ifdef _WIN32 roadmap_log (ROADMAP_WARNING, "RoadMap build %s starting, time %s", @@ -1833,6 +1840,9 @@ trip_new (); # endif #endif + if (!strcmp(roadmap_config_get (&RoadMapConfigGeneralFullScreen), "yes")) { + roadmap_main_toggle_full_screen(); + } roadmap_locator_declare_downloader (&roadmap_start_no_download); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2015-08-07 14:59:35
|
Revision: 2940 http://sourceforge.net/p/roadmap/code/2940 Author: pgf Date: 2015-08-07 14:59:32 +0000 (Fri, 07 Aug 2015) Log Message: ----------- roadmap_locator: improve cache hit rate the access "time" on a cache entry must be updated on every access, not just at entry creation. Modified Paths: -------------- trunk/roadmap/src/roadmap_locator.c Modified: trunk/roadmap/src/roadmap_locator.c =================================================================== --- trunk/roadmap/src/roadmap_locator.c 2015-08-07 14:59:29 UTC (rev 2939) +++ trunk/roadmap/src/roadmap_locator.c 2015-08-07 14:59:32 UTC (rev 2940) @@ -309,7 +309,8 @@ db_layer++; } } - roadmap_log(ROADMAP_DEBUG, "Found %d total types in database\n", db_layer); + roadmap_log(ROADMAP_DEBUG, "Found %d total types in map %d (0x%x)\n", + db_layer, RoadMapActiveCounty, -RoadMapActiveCounty); RoadMapCountyCache[RoadMapActiveCountyCache].mapcount = db_layer; } @@ -366,6 +367,8 @@ roadmap_locator_filename(map_name, fips); + access = roadmap_locator_new_access (); + /* Look for the oldest entry in the cache. */ for (i = RoadMapCountyCacheSize-1; i >= 0; --i) { @@ -375,6 +378,7 @@ roadmap_db_activate (RoadMapCountyCache[i].path, map_name); RoadMapActiveCounty = fips; RoadMapActiveCountyCache = i; + RoadMapCountyCache[i].last_access = access; return ROADMAP_US_OK; } @@ -393,8 +397,6 @@ roadmap_locator_remove (oldest); } - access = roadmap_locator_new_access (); - do { for (path = roadmap_scan ("maps", map_name); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2015-08-07 14:59:32
|
Revision: 2939 http://sourceforge.net/p/roadmap/code/2939 Author: pgf Date: 2015-08-07 14:59:29 +0000 (Fri, 07 Aug 2015) Log Message: ----------- start using the new layer mappings, for line, place, and polygon layers the mapping layers must be called, and errors (or rather, incomplete mappings) must be checked for. Modified Paths: -------------- trunk/roadmap/src/roadmap_line.c trunk/roadmap/src/roadmap_place.c trunk/roadmap/src/roadmap_polygon.c trunk/roadmap/src/roadmap_polygon.h trunk/roadmap/src/roadmap_screen.c Modified: trunk/roadmap/src/roadmap_line.c =================================================================== --- trunk/roadmap/src/roadmap_line.c 2015-08-07 14:59:26 UTC (rev 2938) +++ trunk/roadmap/src/roadmap_line.c 2015-08-07 14:59:29 UTC (rev 2939) @@ -304,6 +304,8 @@ return 0; /* This square is empty. */ } + layer = roadmap_locator_layer_to_db(layer); + if (layer <= 0 || layer > RoadMapLineActive->LineBySquare1[square].count) { return 0; } @@ -329,6 +331,8 @@ return 0; /* This square is empty. */ } + layer = roadmap_locator_layer_to_db(layer); + if (layer <= 0 || layer > RoadMapLineActive->LineBySquare2[square].count) { return 0; } @@ -465,7 +469,8 @@ *line_id = RoadMapLineActive->LongLines[index].line; *area = RoadMapLineActive->LongLines[index].area; - *cfcc = RoadMapLineActive->LongLines[index].layer; + *cfcc = roadmap_locator_layer_to_roadmap( + RoadMapLineActive->LongLines[index].layer ); return 1; } Modified: trunk/roadmap/src/roadmap_place.c =================================================================== --- trunk/roadmap/src/roadmap_place.c 2015-08-07 14:59:26 UTC (rev 2938) +++ trunk/roadmap/src/roadmap_place.c 2015-08-07 14:59:29 UTC (rev 2939) @@ -46,6 +46,7 @@ #include "roadmap_point.h" #include "roadmap_place.h" #include "roadmap_square.h" +#include "roadmap_locator.h" #include "roadmap_dictionary.h" @@ -211,6 +212,8 @@ return 0; /* This square is empty. */ } + layer = roadmap_locator_layer_to_db(layer); + if (layer <= 0 || layer > RoadMapPlaceActive->PlaceBySquare[square].count) { return 0; } Modified: trunk/roadmap/src/roadmap_polygon.c =================================================================== --- trunk/roadmap/src/roadmap_polygon.c 2015-08-07 14:59:26 UTC (rev 2938) +++ trunk/roadmap/src/roadmap_polygon.c 2015-08-07 14:59:29 UTC (rev 2939) @@ -40,6 +40,7 @@ #include "roadmap_db_polygon.h" #include "roadmap_polygon.h" +#include "roadmap_locator.h" static char *RoadMapPolygonType = "RoadMapPolygonContext"; @@ -260,6 +261,12 @@ return count; } +struct roadmap_polygon_version { + int (*category)(int polygon); + void (*edges)(int polygon, RoadMapArea *edges); + int (*lines)(int polygon, int **listp); +}; + struct roadmap_polygon_version roadmap_polygon_versions[] = { { roadmap_polygon_category1, @@ -272,3 +279,26 @@ } }; +int roadmap_polygon_category(int polygon) { + + int layer = (roadmap_polygon_versions[roadmap_polygon_db_version].category) + (polygon); + + return roadmap_locator_layer_to_roadmap(layer); + +} + +void roadmap_polygon_edges(int polygon, RoadMapArea *edges) { + + (roadmap_polygon_versions[roadmap_polygon_db_version].edges) + (polygon, edges); + +} + +int roadmap_polygon_lines(int polygon, int **listp) { + + return (roadmap_polygon_versions[roadmap_polygon_db_version].lines) + (polygon, listp); + +} + Modified: trunk/roadmap/src/roadmap_polygon.h =================================================================== --- trunk/roadmap/src/roadmap_polygon.h 2015-08-07 14:59:26 UTC (rev 2938) +++ trunk/roadmap/src/roadmap_polygon.h 2015-08-07 14:59:29 UTC (rev 2939) @@ -28,22 +28,11 @@ #include "roadmap_dbread.h" int roadmap_polygon_count (void); -struct roadmap_polygon_version { - int (*category)(int polygon); - void (*edges)(int polygon, RoadMapArea *edges); - int (*lines)(int polygon, int **listp); -}; -extern struct roadmap_polygon_version roadmap_polygon_versions[]; -extern int roadmap_polygon_db_version; -#define roadmap_polygon_category(p) \ - (roadmap_polygon_versions[roadmap_polygon_db_version].category)(p) -#define roadmap_polygon_edges(p, e) \ - (roadmap_polygon_versions[roadmap_polygon_db_version].edges)(p, e) -#define roadmap_polygon_lines(p, lp) \ - (roadmap_polygon_versions[roadmap_polygon_db_version].lines)(p, lp) +int roadmap_polygon_category(int polygon); +void roadmap_polygon_edges(int polygon, RoadMapArea *edges); +int roadmap_polygon_lines(int polygon, int **listp); - extern roadmap_db_handler RoadMapPolygonHandler; #endif // _ROADMAP_POLYGON__H_ Modified: trunk/roadmap/src/roadmap_screen.c =================================================================== --- trunk/roadmap/src/roadmap_screen.c 2015-08-07 14:59:26 UTC (rev 2938) +++ trunk/roadmap/src/roadmap_screen.c 2015-08-07 14:59:29 UTC (rev 2939) @@ -677,6 +677,8 @@ for (i = polycount - 1; i >= 0; --i) { category = roadmap_polygon_category (i); + if (!category) continue; + pen = roadmap_layer_get_pen (category, 0); if (pen == NULL) continue; @@ -1167,6 +1169,9 @@ roadmap_log_push ("roadmap_screen_draw_long_lines"); while (roadmap_line_long (index++, &line, &area, &layer)) { + + if (layer == 0) continue; + RoadMapPosition position; RoadMapPosition to_position; int to_square; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2015-08-07 14:59:29
|
Revision: 2938 http://sourceforge.net/p/roadmap/code/2938 Author: pgf Date: 2015-08-07 14:59:26 +0000 (Fri, 07 Aug 2015) Log Message: ----------- roadmap_locator: create mapping between internal layers and map layers this mapping will allow breaking the current hard dependency that roadmap must be run with the same class file that was used to build the maps. it's very arguable that this mapping shouldn't live in roadmap_locator. but the results should be cacheable, and the mapping needs to happen after the map's metadata module is available. so i'm leaving it here for now. perhaps someday it could move to a dummy database module whose activate() routine establishes the mapping? Modified Paths: -------------- trunk/roadmap/src/roadmap_locator.c trunk/roadmap/src/roadmap_locator.h Modified: trunk/roadmap/src/roadmap_locator.c =================================================================== --- trunk/roadmap/src/roadmap_locator.c 2015-08-07 14:59:24 UTC (rev 2937) +++ trunk/roadmap/src/roadmap_locator.c 2015-08-07 14:59:26 UTC (rev 2938) @@ -53,6 +53,8 @@ #include "roadmap_county.h" #include "roadmap_config.h" #include "roadmap_iso.h" +#include "roadmap_layer.h" +#include "roadmap_metadata.h" #include "roadmap_locator.h" @@ -64,6 +66,9 @@ int fips; const char *path; unsigned int last_access; + short *db_to_roadmap; + short *roadmap_to_db;; + short mapcount; // zero indicates no mapping found }; static struct roadmap_cache_entry *RoadMapCountyCache = NULL; @@ -71,6 +76,7 @@ static int RoadMapCountyCacheSize = 0; static int RoadMapActiveCounty; +static int RoadMapActiveCountyCache; static int RoadMapUseCounties = 1; @@ -88,7 +94,7 @@ void roadmap_locator_use_counties(int yesno) { - RoadMapUseCounties = yesno; + RoadMapUseCounties = yesno; } @@ -99,11 +105,15 @@ static void roadmap_locator_configure (void) { const char *path; + int i; if (RoadMapCountyCache == NULL) { RoadMapCountyModel = roadmap_db_register + (RoadMapCountyModel, "metadata", &RoadMapMetadataHandler); + RoadMapCountyModel = + roadmap_db_register (RoadMapCountyModel, "zip", &RoadMapZipHandler); RoadMapCountyModel = roadmap_db_register @@ -147,6 +157,14 @@ RoadMapCountyCache = (struct roadmap_cache_entry *) calloc (RoadMapCountyCacheSize, sizeof(struct roadmap_cache_entry)); roadmap_check_allocated (RoadMapCountyCache); + for (i = 0; i < RoadMapCountyCacheSize; i++) { + RoadMapCountyCache[i].db_to_roadmap = + calloc (roadmap_layer_max_defined(), sizeof(short)); + roadmap_check_allocated (RoadMapCountyCache[i].db_to_roadmap ); + RoadMapCountyCache[i].roadmap_to_db = + calloc (roadmap_layer_max_defined(), sizeof(short)); + roadmap_check_allocated (RoadMapCountyCache[i].roadmap_to_db ); + } for (path = roadmap_scan ("maps", "usdir.rdm"); path != NULL; @@ -208,6 +226,7 @@ RoadMapCountyCache[index].fips = 0; RoadMapCountyCache[index].path = NULL; RoadMapCountyCache[index].last_access = 0; + RoadMapCountyCache[index].mapcount = 0; } /** @@ -232,6 +251,7 @@ } } RoadMapActiveCounty = 0; + RoadMapActiveCountyCache = 0; RoadMapLocatorAccessCount += 1; } @@ -239,6 +259,92 @@ return RoadMapLocatorAccessCount; } +static void roadmap_locator_layer_mapping_init(void) { + + const char *name; + int db_layer, layer; + short *db_to_roadmap; + short *roadmap_to_db; + int i, t; + char *types[] = { + "Places", + "Lines", + "Polygons" + }; + + db_to_roadmap = RoadMapCountyCache[RoadMapActiveCountyCache].db_to_roadmap; + roadmap_to_db = RoadMapCountyCache[RoadMapActiveCountyCache].roadmap_to_db; + + /* order is important. the classes are indexed sequentially in + * both the database and internally to roadmap with places + * followed by lines followed by polygons. + * + * fetch all places, lines, and polygon names from the metadata + * attributes Class.Places, Class.Lines, and Class.Polygons. for + * each one, get the internal roadmap layer index corresponding + * to that classname, and create a bidirectional mapping. + */ + db_layer = 0; + for (t = 0; t < 3; t++) { + i = 0; + while(1) { + name = roadmap_metadata_get_attribute_next ("Class", types[t], i); + if (name == NULL || name[0] == 0) { + roadmap_log(ROADMAP_DEBUG, "Found %d %s in db\n", i, types[t]); + break; + } + /* + * the indices are a little tricky. roadmap layers external to + * roadmap_layer.c are all offset by 1, leaving '0' to indicate + * a missing layer. we do the same with the db_layers as stored + * in the roadmap_to_db[] table. but the indices to both mapping + * tables are 0-based. + */ + layer = roadmap_layer_find(name); + // fprintf(stderr, "%s: db %d --> roadmap %d\n", name, db_layer, layer); + db_to_roadmap[db_layer] = layer; + // fprintf(stderr, "roadmap %d --> db %d\n", layer-1, db_layer+1); + roadmap_to_db[layer-1] = db_layer + 1; + i++; + db_layer++; + } + } + roadmap_log(ROADMAP_DEBUG, "Found %d total types in database\n", db_layer); + RoadMapCountyCache[RoadMapActiveCountyCache].mapcount = db_layer; +} + +int roadmap_locator_layer_to_roadmap(int i) { + int l; + + /* if no mappings exists, use a transparent mapping */ + if (RoadMapCountyCache[RoadMapActiveCountyCache].mapcount == 0) + return i; + + l = RoadMapCountyCache[RoadMapActiveCountyCache].db_to_roadmap[i-1]; +#if 0 + if (l == 0) { + fprintf(stderr, "empty to_roadmap mapping for db layer %d\n", i); + } +#endif + return l; +} + +int roadmap_locator_layer_to_db(int i) { + int l; + + /* if no mappings exists, use a transparent mapping */ + if (RoadMapCountyCache[RoadMapActiveCountyCache].mapcount == 0) + return i; + + l = RoadMapCountyCache[RoadMapActiveCountyCache].roadmap_to_db[i-1]; +#if 0 + if (l == 0) { + fprintf(stderr, "empty to_db mapping for roadmap layer %d\n", i); + } +#endif + return l; +} + /** * @brief * @param fips @@ -268,6 +374,7 @@ roadmap_db_activate (RoadMapCountyCache[i].path, map_name); RoadMapActiveCounty = fips; + RoadMapActiveCountyCache = i; return ROADMAP_US_OK; } @@ -301,6 +408,8 @@ RoadMapCountyCache[oldest].last_access = access; RoadMapActiveCounty = fips; + RoadMapActiveCountyCache = oldest; + roadmap_locator_layer_mapping_init(); return ROADMAP_US_OK; } @@ -343,9 +452,9 @@ if (RoadMapCountyCache == NULL) return 0; if (RoadMapUseCounties) - count = roadmap_county_count(); + count = roadmap_county_count(); else - count = 0; + count = 0; /* note that this can also be resized during tile splitting in * roadmap_osm.c -- see usage of roadmap_osm_tilelist in that file. Modified: trunk/roadmap/src/roadmap_locator.h =================================================================== --- trunk/roadmap/src/roadmap_locator.h 2015-08-07 14:59:24 UTC (rev 2937) +++ trunk/roadmap/src/roadmap_locator.h 2015-08-07 14:59:26 UTC (rev 2938) @@ -55,5 +55,8 @@ void roadmap_locator_use_counties(int yesno); +int roadmap_locator_layer_to_roadmap(int i); +int roadmap_locator_layer_to_db(int i); + #endif // _ROADMAP_LOCATOR__H_ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2015-08-07 14:59:26
|
Revision: 2937 http://sourceforge.net/p/roadmap/code/2937 Author: pgf Date: 2015-08-07 14:59:24 +0000 (Fri, 07 Aug 2015) Log Message: ----------- roadmap_layer: add ability to look up a layer index by name Modified Paths: -------------- trunk/roadmap/src/roadmap_layer.c trunk/roadmap/src/roadmap_layer.h Modified: trunk/roadmap/src/roadmap_layer.c =================================================================== --- trunk/roadmap/src/roadmap_layer.c 2015-08-07 14:59:21 UTC (rev 2936) +++ trunk/roadmap/src/roadmap_layer.c 2015-08-07 14:59:24 UTC (rev 2937) @@ -61,16 +61,6 @@ /** - * @brief This is the maximum number of layers PER CLASS. As there is no limit on - * the number of classes, the total number of layers is actually unlimited. - * We could have implemented support for an unlimited number of layers per - * class, but who wants a thousand layers per map, anyway? - * Having this limit makes life easier for everyone, and the downside is nil. - * Note that this has no impact on the API of roadmap_layer. - */ -#define ROADMAP_MAX_LAYERS 512 - -/** * @brief There is a maximum number of navigation modules that can be registered. * This is not really a limitation for now, since there is currently only * one navigation mode (car) and any other would be hiking, boat, plane, @@ -555,7 +545,22 @@ } #endif +int roadmap_layer_find(const char *name) { + const char *n; + short i; + short total = RoadMapLayerCurrentClass->place_layer_count + + RoadMapLayerCurrentClass->line_layer_count + + RoadMapLayerCurrentClass->polygon_layer_count; + for (i = 0; i < total; i++) { + n = RoadMapLayerCurrentClass->layers[i].name; + if (strcmp(name, n) == 0) + return i+1; + } + return 0; +} + + void roadmap_layer_select_set (const char *name) { static RoadMapSet *default_set = NULL; Modified: trunk/roadmap/src/roadmap_layer.h =================================================================== --- trunk/roadmap/src/roadmap_layer.h 2015-08-07 14:59:21 UTC (rev 2936) +++ trunk/roadmap/src/roadmap_layer.h 2015-08-07 14:59:24 UTC (rev 2937) @@ -61,6 +61,16 @@ #include "roadmap_canvas.h" +/** + * @brief This is the maximum number of layers PER CLASS. As there is no limit on + * the number of classes, the total number of layers is actually unlimited. + * We could have implemented support for an unlimited number of layers per + * class, but who wants a thousand layers per map, anyway? + * Having this limit makes life easier for everyone, and the downside is nil. + * Note that this has no impact on the API of roadmap_layer. + */ +#define ROADMAP_MAX_LAYERS 512 + /* defines the types of parameter a pen attribute function gets */ enum { ROADMAP_STYLE_TYPE_INT, @@ -80,6 +90,7 @@ void roadmap_layer_adjust (void); +int roadmap_layer_find(const char *name); void roadmap_layer_select_set (const char *set); /* Either "day" or "night". */ @@ -119,5 +130,4 @@ const char *roadmap_layer_sprite (int layer); int roadmap_layer_labels_visible(int layer); - #endif // INCLUDED__ROADMAP_LAYER__H This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2015-08-07 14:59:23
|
Revision: 2936 http://sourceforge.net/p/roadmap/code/2936 Author: pgf Date: 2015-08-07 14:59:21 +0000 (Fri, 07 Aug 2015) Log Message: ----------- buildus_main: don't reference the "zip" tables i don't believe this reference is needed (and it makes no difference to the output of buildus). leaving it in pulls in roadmap_street, which wants roadmap_locator, then roadmap_layer, which is in the gui library. clearly things need refactoring, but for now this is okay. Modified Paths: -------------- trunk/roadmap/src/buildus_main.c Modified: trunk/roadmap/src/buildus_main.c =================================================================== --- trunk/roadmap/src/buildus_main.c 2015-08-07 14:59:18 UTC (rev 2935) +++ trunk/roadmap/src/buildus_main.c 2015-08-07 14:59:21 UTC (rev 2936) @@ -167,9 +167,11 @@ RoadMapCountyModel = roadmap_db_register (RoadMapCountyModel, "square", &RoadMapSquareHandler); +#ifdef NEEDED RoadMapCountyModel = roadmap_db_register (RoadMapCountyModel, "zip", &RoadMapZipHandler); +#endif for (mappath = roadmap_path_first("maps"); mappath != NULL; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2015-08-07 14:59:20
|
Revision: 2935 http://sourceforge.net/p/roadmap/code/2935 Author: pgf Date: 2015-08-07 14:59:18 +0000 (Fri, 07 Aug 2015) Log Message: ----------- roadmap_start/factory: reduce link dependencies for smaller roadgps it turns out roadgps (and even buildus!) pull in fairly large chunks of roadmap code that they don't need. this change stops roadmap_plugin, and therefore roadmap_locator (and possibly others), from being linked in. Modified Paths: -------------- trunk/roadmap/src/roadmap_factory.c trunk/roadmap/src/roadmap_factory.h trunk/roadmap/src/roadmap_start.c Modified: trunk/roadmap/src/roadmap_factory.c =================================================================== --- trunk/roadmap/src/roadmap_factory.c 2015-08-07 14:59:15 UTC (rev 2934) +++ trunk/roadmap/src/roadmap_factory.c 2015-08-07 14:59:18 UTC (rev 2935) @@ -783,7 +783,7 @@ * @param actions the list of actions for this plugin * @param menu the menu configuration for this plugin */ -static void roadmap_factory_handle_plugin_actions_menu +void roadmap_factory_handle_plugin_actions_menu (RoadMapAction *actions, const char **menu) { int use_tips; @@ -864,7 +864,6 @@ roadmap_main_set_keyboard (roadmap_factory_keyboard); } - roadmap_plugin_actions_menu(roadmap_factory_handle_plugin_actions_menu); } static char *RoadMapFactoryKeyMapFile; Modified: trunk/roadmap/src/roadmap_factory.h =================================================================== --- trunk/roadmap/src/roadmap_factory.h 2015-08-07 14:59:15 UTC (rev 2934) +++ trunk/roadmap/src/roadmap_factory.h 2015-08-07 14:59:18 UTC (rev 2935) @@ -77,5 +77,8 @@ void roadmap_factory_load (RoadMapAction *actions); void roadmap_factory_shutdown (void); +void roadmap_factory_handle_plugin_actions_menu + (RoadMapAction *actions, const char **menu); + #endif /* INCLUDE__ROADMAP_FACTORY__H */ Modified: trunk/roadmap/src/roadmap_start.c =================================================================== --- trunk/roadmap/src/roadmap_start.c 2015-08-07 14:59:15 UTC (rev 2934) +++ trunk/roadmap/src/roadmap_start.c 2015-08-07 14:59:18 UTC (rev 2935) @@ -1501,6 +1501,8 @@ RoadMapStartMenu, RoadMapStartToolbar); + roadmap_plugin_actions_menu(roadmap_factory_handle_plugin_actions_menu); + roadmap_main_add_canvas (); roadmap_main_show (); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2015-08-07 14:59:17
|
Revision: 2934 http://sourceforge.net/p/roadmap/code/2934 Author: pgf Date: 2015-08-07 14:59:15 +0000 (Fri, 07 Aug 2015) Log Message: ----------- roadmap_line: ifdef some NAVIGATE_PLUGIN code Modified Paths: -------------- trunk/roadmap/src/roadmap_line.c Modified: trunk/roadmap/src/roadmap_line.c =================================================================== --- trunk/roadmap/src/roadmap_line.c 2015-08-07 14:59:12 UTC (rev 2933) +++ trunk/roadmap/src/roadmap_line.c 2015-08-07 14:59:15 UTC (rev 2934) @@ -470,6 +470,7 @@ return 1; } +#ifdef HAVE_NAVIGATE_PLUGIN /** * @brief determine the layer that some line is in * @param line the line whose layer we want to query @@ -604,3 +605,5 @@ return -1; return fl[0]; } + +#endif // HAVE_NAVIGATE_PLUGIN This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2015-08-07 14:59:14
|
Revision: 2933 http://sourceforge.net/p/roadmap/code/2933 Author: pgf Date: 2015-08-07 14:59:12 +0000 (Fri, 07 Aug 2015) Log Message: ----------- roadmap_line.h: comment reformatting Modified Paths: -------------- trunk/roadmap/src/roadmap_line.h Modified: trunk/roadmap/src/roadmap_line.h =================================================================== --- trunk/roadmap/src/roadmap_line.h 2015-08-07 14:59:09 UTC (rev 2932) +++ trunk/roadmap/src/roadmap_line.h 2015-08-07 14:59:12 UTC (rev 2933) @@ -27,23 +27,26 @@ * * Lines have two endpoints, nothing in between. * - * A line A-B should not be in a RoadMap map if it is a street that intersects with street C-D. + * A line A-B should not be in a RoadMap map if it is a street that + * intersects with street C-D. * * A ---- C ------ B * | * / * D - * In this case, A-B should not be a line in the map, but A-C, C-B and C-D should be. + * In this case, A-B should not be a line in the map, but A-C, C-B and + * C-D should be. * * There are two higher level concepts also in RoadMap : streets and shapes. * - * A street is something you'll recognize in real life : it has a name, and consists of - * some pieces that aren't even always adjacent. + * A street is something you'll recognize in real life : it has a + * name, and consists of some pieces that aren't even always adjacent. * - * A shape is a RoadMap concept to represent the curves followed by a non-straight line. + * A shape is a RoadMap concept to represent the curves followed by a + * non-straight line. * - * Lines are basic elements for navigation : they're interesting because we know there's - * nothing between the two endpoints. + * Lines are basic elements for navigation : they're interesting + * because we know there's nothing between the two endpoints. */ #ifndef INCLUDED__ROADMAP_LINE__H This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2015-08-07 14:59:11
|
Revision: 2932 http://sourceforge.net/p/roadmap/code/2932 Author: pgf Date: 2015-08-07 14:59:09 +0000 (Fri, 07 Aug 2015) Log Message: ----------- roadmap_screen: share the static layers array between line and place layers Modified Paths: -------------- trunk/roadmap/src/roadmap_screen.c Modified: trunk/roadmap/src/roadmap_screen.c =================================================================== --- trunk/roadmap/src/roadmap_screen.c 2015-08-07 14:59:06 UTC (rev 2931) +++ trunk/roadmap/src/roadmap_screen.c 2015-08-07 14:59:09 UTC (rev 2932) @@ -1523,9 +1523,17 @@ int *drawnlist; int max_pen; static int nomap; + static int *layers; + static int layers_size; if (!RoadMapScreenDragging && RoadMapScreenFrozen) return; + if (layers == NULL) { + layers_size = roadmap_layer_max_defined(); + layers = (int *)calloc (layers_size, sizeof(int)); + roadmap_check_allocated(layers); + } + dbg_time_start(DBG_TIME_FULL); if (RoadMapScreenDragging && (! roadmap_config_match(&RoadMapConfigStylePrettyDrag, "yes"))) { @@ -1628,17 +1636,10 @@ for (pen = 0; pen < max_pen; ++pen) { if (sqcount > 0) { - static int *layers = NULL; - static int layers_size = 0; int layer_count; roadmap_screen_reset_square_mask(); - if (layers == NULL) { - layers_size = roadmap_layer_max_defined(); - layers = (int *)calloc (layers_size, sizeof(int)); - roadmap_check_allocated(layers); - } layer_count = roadmap_layer_visible_line_layers (layers, layers_size, pen); @@ -1684,17 +1685,10 @@ pen = 0; if (sqcount > 0) { - static int *layers = NULL; - static int layers_size = 0; int layer_count; roadmap_screen_reset_square_mask(); - if (layers == NULL) { - layers_size = roadmap_layer_max_defined(); - layers = (int *)calloc (layers_size, sizeof(int)); - roadmap_check_allocated(layers); - } layer_count = roadmap_layer_visible_place_layers (layers, layers_size, pen); if (!layer_count) continue; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2015-08-07 14:59:08
|
Revision: 2931 http://sourceforge.net/p/roadmap/code/2931 Author: pgf Date: 2015-08-07 14:59:06 +0000 (Fri, 07 Aug 2015) Log Message: ----------- roadmap_layer: variable and function renaming for clarity these aren't counts of lines or places or polygons -- they're counts of line layers, place layers, and polygon layers. Modified Paths: -------------- trunk/roadmap/src/roadmap_layer.c trunk/roadmap/src/roadmap_layer.h trunk/roadmap/src/roadmap_screen.c Modified: trunk/roadmap/src/roadmap_layer.c =================================================================== --- trunk/roadmap/src/roadmap_layer.c 2015-08-07 14:59:03 UTC (rev 2930) +++ trunk/roadmap/src/roadmap_layer.c 2015-08-07 14:59:06 UTC (rev 2931) @@ -120,13 +120,13 @@ const char *before; const char *after; - short places_count; - short lines_count; - short polygons_count; + short place_layer_count; + short line_layer_count; + short polygon_layer_count; /* "first_line" and "last_line" make it easier to loop through lines */ -#define first_line places_count - short last_line; // really this is one past the last line +#define first_line_layer place_layer_count + short last_line_layer; // really this is one past the last line struct roadmap_layer_record *layers; @@ -307,7 +307,7 @@ if (RoadMapLayerCurrentClass == NULL) return 0; - for (i = RoadMapLayerCurrentClass->first_line; i < RoadMapLayerCurrentClass->last_line; ++i) { + for (i = RoadMapLayerCurrentClass->first_line_layer; i < RoadMapLayerCurrentClass->last_line_layer; ++i) { layer = RoadMapLayerCurrentClass->layers + i; @@ -323,7 +323,7 @@ return count; } -int roadmap_layer_visible_lines (int *layers, int size, unsigned int pen_index) +int roadmap_layer_visible_line_layers (int *layers, int size, unsigned int pen_index) { int i; int count = 0; @@ -333,7 +333,7 @@ if (RoadMapLayerCurrentClass == NULL) return 0; - for (i = RoadMapLayerCurrentClass->last_line - 1; i >= RoadMapLayerCurrentClass->first_line; --i) { + for (i = RoadMapLayerCurrentClass->last_line_layer - 1; i >= RoadMapLayerCurrentClass->first_line_layer; --i) { layerp = RoadMapLayerCurrentClass->layers + i; @@ -350,7 +350,7 @@ return count; } -int roadmap_layer_visible_places (int *layers, int size, unsigned int pen_index) +int roadmap_layer_visible_place_layers (int *layers, int size, unsigned int pen_index) { int i; int count = 0; @@ -360,7 +360,7 @@ if (RoadMapLayerCurrentClass == NULL) return 0; - for (i = 0; i < RoadMapLayerCurrentClass->places_count; i++) { + for (i = 0; i < RoadMapLayerCurrentClass->place_layer_count; i++) { layerp = RoadMapLayerCurrentClass->layers + i; @@ -387,7 +387,7 @@ if (RoadMapLayerCurrentClass == NULL) return; - for (i = RoadMapLayerCurrentClass->last_line - 1; i >= RoadMapLayerCurrentClass->first_line; --i) { + for (i = RoadMapLayerCurrentClass->last_line_layer - 1; i >= RoadMapLayerCurrentClass->first_line_layer; --i) { layerp = RoadMapLayerCurrentClass->layers + i; @@ -481,9 +481,9 @@ if (RoadMapLayerCurrentClass == NULL) return NULL; - total = RoadMapLayerCurrentClass->polygons_count - + RoadMapLayerCurrentClass->places_count - + RoadMapLayerCurrentClass->lines_count; + total = RoadMapLayerCurrentClass->polygon_layer_count + + RoadMapLayerCurrentClass->place_layer_count + + RoadMapLayerCurrentClass->line_layer_count; if (layer >= 0 && layer < total && pen_index < RoadMapMaxUsedPen) { @@ -538,9 +538,9 @@ int roadmap_layer_names (const char *names[], int max) { short i; - short total = RoadMapLayerCurrentClass->places_count - + RoadMapLayerCurrentClass->lines_count - + RoadMapLayerCurrentClass->polygons_count; + short total = RoadMapLayerCurrentClass->place_layer_count + + RoadMapLayerCurrentClass->line_layer_count + + RoadMapLayerCurrentClass->polygon_layer_count; if (total > max) { @@ -777,7 +777,7 @@ int j; unsigned int pen_index; - int places_count, lines_count, polygons_count, total_count; + int place_lcount, line_lcount, polygon_lcount, total_layer_count; char *layernames[ROADMAP_MAX_LAYERS]; RoadMapSet *set; @@ -817,23 +817,23 @@ * consecutive to each other, so that we can manage them as a * single list. */ - places_count = + place_lcount = roadmap_layer_decode (class_config, "Class", "Places", layernames, ROADMAP_MAX_LAYERS); - lines_count = + line_lcount = roadmap_layer_decode (class_config, "Class", "Lines", - layernames + places_count, - ROADMAP_MAX_LAYERS - places_count); + layernames + place_lcount, + ROADMAP_MAX_LAYERS - place_lcount); - polygons_count = + polygon_lcount = roadmap_layer_decode (class_config, "Class", "Polygons", - layernames + lines_count + places_count, - ROADMAP_MAX_LAYERS - (lines_count + places_count)); + layernames + line_lcount + place_lcount, + ROADMAP_MAX_LAYERS - (line_lcount + place_lcount)); - total_count = polygons_count + lines_count + places_count; - if (total_count == 0) { + total_layer_count = polygon_lcount + line_lcount + place_lcount; + if (total_layer_count == 0) { roadmap_log (ROADMAP_FATAL, "No Class entries found in %s", class_file); } @@ -842,17 +842,17 @@ new_class = calloc (sizeof(RoadMapClass) + - (total_count * sizeof(RoadMapLayer)), 1); + (total_layer_count * sizeof(RoadMapLayer)), 1); roadmap_check_allocated(new_class); roadmap_log (ROADMAP_DEBUG, "Class [%s] lines %d polygons %d places %d", - class_name, lines_count, polygons_count, places_count); + class_name, line_lcount, polygon_lcount, place_lcount); new_class->name = class_name; - new_class->places_count = places_count; - new_class->lines_count = lines_count; - new_class->last_line = lines_count + places_count; // one past the last line layer - new_class->polygons_count = polygons_count; + new_class->place_layer_count = place_lcount; + new_class->line_layer_count = line_lcount; + new_class->last_line_layer = line_lcount + place_lcount; // one past the last line layer + new_class->polygon_layer_count = polygon_lcount; new_class->layers = (RoadMapLayer *) (new_class + 1); @@ -869,14 +869,14 @@ set->class_count += 1; - if (RoadMapMaxDefinedLayers < (unsigned int) total_count) { - RoadMapMaxDefinedLayers = total_count; + if (RoadMapMaxDefinedLayers < (unsigned int) total_layer_count) { + RoadMapMaxDefinedLayers = total_layer_count; } int n_of_callbacks = (int) sizeof(RoadMapLayerPenSetupTable) / sizeof(RoadMapLayerPenAttribute); - for (i = total_count - 1; i >= 0; --i) { + for (i = total_layer_count - 1; i >= 0; --i) { const char *svalues[ROADMAP_MAX_LAYER_PENS][n_of_callbacks]; int ivalues[ROADMAP_MAX_LAYER_PENS][n_of_callbacks]; @@ -961,7 +961,7 @@ /* Create all necessary pens. */ - if (i < places_count || i >= lines_count + places_count) { + if (i < place_lcount || i >= line_lcount + place_lcount) { /* this is a place or a polygon */ layer->in_use[0] = 1; } @@ -1007,7 +1007,7 @@ } } - if (i < places_count || i >= lines_count + places_count) { + if (i < place_lcount || i >= line_lcount + place_lcount) { /* this is a place or a polygon */ layer->in_use[0] = 1; } @@ -1031,16 +1031,16 @@ int mask = 1 << i; char *navigation_layers[ROADMAP_MAX_LAYERS]; - int layers_count = roadmap_layer_decode (class_config, + int layer_lcount = roadmap_layer_decode (class_config, "Navigation", RoadMapNavigationMode[i], navigation_layers, ROADMAP_MAX_LAYERS); roadmap_log (ROADMAP_DEBUG, "Navigation %d [%s] -> %d modes", - i, RoadMapNavigationMode[i], layers_count); + i, RoadMapNavigationMode[i], layer_lcount); - for (j = layers_count - 1; j >= 0; --j) { + for (j = layer_lcount - 1; j >= 0; --j) { - for (k = lines_count - 1; k >= places_count; --k) { + for (k = line_lcount - 1; k >= place_lcount; --k) { if (strcasecmp(layernames[k], navigation_layers[j]) == 0) { new_class->layers[k].navigation_modes |= mask; @@ -1144,8 +1144,8 @@ roadmap_log (ROADMAP_FATAL, "roadmap_layer_is_street : no current class"); return 0; } - return (layer >= RoadMapLayerCurrentClass->first_line && - layer < RoadMapLayerCurrentClass->last_line); + return (layer >= RoadMapLayerCurrentClass->first_line_layer && + layer < RoadMapLayerCurrentClass->last_line_layer); } /** Modified: trunk/roadmap/src/roadmap_layer.h =================================================================== --- trunk/roadmap/src/roadmap_layer.h 2015-08-07 14:59:03 UTC (rev 2930) +++ trunk/roadmap/src/roadmap_layer.h 2015-08-07 14:59:06 UTC (rev 2931) @@ -89,8 +89,8 @@ void roadmap_layer_set_group_visibility(int group, int hide); -int roadmap_layer_visible_lines (int *layers, int size, unsigned int pen_index); -int roadmap_layer_visible_places (int *layers, int size, unsigned int pen_index); +int roadmap_layer_visible_line_layers (int *layers, int size, unsigned int pen_index); +int roadmap_layer_visible_place_layers (int *layers, int size, unsigned int pen_index); int roadmap_layer_line_is_visible (int layer); Modified: trunk/roadmap/src/roadmap_screen.c =================================================================== --- trunk/roadmap/src/roadmap_screen.c 2015-08-07 14:59:03 UTC (rev 2930) +++ trunk/roadmap/src/roadmap_screen.c 2015-08-07 14:59:06 UTC (rev 2931) @@ -1639,7 +1639,7 @@ layers = (int *)calloc (layers_size, sizeof(int)); roadmap_check_allocated(layers); } - layer_count = roadmap_layer_visible_lines + layer_count = roadmap_layer_visible_line_layers (layers, layers_size, pen); if (!layer_count) continue; @@ -1695,7 +1695,7 @@ layers = (int *)calloc (layers_size, sizeof(int)); roadmap_check_allocated(layers); } - layer_count = roadmap_layer_visible_places + layer_count = roadmap_layer_visible_place_layers (layers, layers_size, pen); if (!layer_count) continue; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2015-08-07 14:59:05
|
Revision: 2930 http://sourceforge.net/p/roadmap/code/2930 Author: pgf Date: 2015-08-07 14:59:03 +0000 (Fri, 07 Aug 2015) Log Message: ----------- buildmap_layer: store layer values from the class file into metadata this creates a record of what layers the map was built with, and maps the layer names to their (sequential) indices. Modified Paths: -------------- trunk/roadmap/src/buildmap_layer.c trunk/roadmap/src/buildmap_osm_main.c Modified: trunk/roadmap/src/buildmap_layer.c =================================================================== --- trunk/roadmap/src/buildmap_layer.c 2015-08-07 14:58:59 UTC (rev 2929) +++ trunk/roadmap/src/buildmap_layer.c 2015-08-07 14:59:03 UTC (rev 2930) @@ -37,6 +37,7 @@ #include "buildmap.h" #include "buildmap_layer.h" +#include "buildmap_metadata.h" #define BUILDMAP_LAYER_MAX 1024 @@ -93,15 +94,25 @@ int i; char *p; + i = strlen(text); + if (i == 0) + return 0; + + for (p = &text[i-1]; p > text; p--) { + if (*p == ' ') + *p = '\0'; + else + break; + } + field[0] = text; p = strchr (text, ' '); for (i = 1; p != NULL && *p != 0; ++i) { - - *p = 0; + while (*p == ' ') *p++ = 0; if (i >= max) return -1; - field[i] = ++p; + field[i] = p; p = strchr (p, ' '); } return i; @@ -118,7 +129,7 @@ static int buildmap_layer_decode (const char *config, const char *id, char**args, int max) { - int count; + int count, i; char *buffer; if (max <= 0) { @@ -141,6 +152,14 @@ roadmap_config_file(config)); } + for (i = 0; i < count; i++) + { + if (i == 0) + buildmap_metadata_add_attribute ("Class", id, args[i]); + else + buildmap_metadata_add_value ("Class", id, args[i]); + } + return count; } Modified: trunk/roadmap/src/buildmap_osm_main.c =================================================================== --- trunk/roadmap/src/buildmap_osm_main.c 2015-08-07 14:58:59 UTC (rev 2929) +++ trunk/roadmap/src/buildmap_osm_main.c 2015-08-07 14:59:03 UTC (rev 2930) @@ -898,7 +898,7 @@ buildmap_layer_load(class); - buildmap_metadata_add_attribute ("MapFormat", "Version", "1.3 alpha"); + buildmap_metadata_add_attribute ("MapFormat", "Version", "1.4 alpha"); if (tileid) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2015-08-07 14:59:01
|
Revision: 2929 http://sourceforge.net/p/roadmap/code/2929 Author: pgf Date: 2015-08-07 14:58:59 +0000 (Fri, 07 Aug 2015) Log Message: ----------- roadmap_street: remove inappropriate restriction on some lookups the checks for RoadMapRangeActive being non-null were probably copy/paste errors initially. those checks, in the presence of a Map.Path which included a basemap layer (which contains no range sections), cause all street selection lookups (and likely, intersection lookups) to fail. Modified Paths: -------------- trunk/roadmap/src/roadmap_street.c Modified: trunk/roadmap/src/roadmap_street.c =================================================================== --- trunk/roadmap/src/roadmap_street.c 2015-08-07 14:58:52 UTC (rev 2928) +++ trunk/roadmap/src/roadmap_street.c 2015-08-07 14:58:59 UTC (rev 2929) @@ -1444,8 +1444,6 @@ int count = 0; - if (RoadMapRangeActive == NULL) return 0; - county_count = roadmap_locator_by_position (position, &fipslist); /* - For each candidate county: */ @@ -1840,9 +1838,6 @@ RoadMapStreetIdentifier street1, street2; - - if (RoadMapRangeActive == NULL) return 0; - county_count = roadmap_locator_by_state (state, &fipslist); for (i = county_count - 1; i >= 0; --i) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2015-08-07 14:58:54
|
Revision: 2928 http://sourceforge.net/p/roadmap/code/2928 Author: pgf Date: 2015-08-07 14:58:52 +0000 (Fri, 07 Aug 2015) Log Message: ----------- roadmap_trip: consolidate some more HAVE_NAVIGATE_PLUGIN ifdefs if or when we start working on navigation again, we need to fully separate it from the current roadmap_trip implementation. for better or worse, the roadmap_trip code is all about following GPX. the navigate code will be something quite different, and should remain separate until we see what can be merged safely. Modified Paths: -------------- trunk/roadmap/src/roadmap_trip.c Modified: trunk/roadmap/src/roadmap_trip.c =================================================================== --- trunk/roadmap/src/roadmap_trip.c 2015-08-07 14:58:49 UTC (rev 2927) +++ trunk/roadmap/src/roadmap_trip.c 2015-08-07 14:58:52 UTC (rev 2928) @@ -4090,7 +4090,6 @@ } return NULL; } -#endif // HAVE_NAVIGATE_PLUGIN /** * @brief indicate that refresh is needed @@ -4100,7 +4099,6 @@ RoadMapTripRefresh = 1; } -#if 1 /* * Stuff to add menu items in the navigate menu * These could be integrated with the existing Trip UI. @@ -4149,14 +4147,12 @@ roadmap_dialog_add_button ("Show", roadmap_trip_dialog_cancel); -#ifdef HAVE_NAVIGATE_PLUGIN if (destination) roadmap_dialog_add_button ("Destination", roadmap_trip_set_nav_destination); else roadmap_dialog_add_button ("Departure", roadmap_trip_set_nav_departure); -#endif // HAVE_NAVIGATE_PLUGIN roadmap_dialog_new_hidden ("Names", ".which"); @@ -4166,7 +4162,6 @@ roadmap_trip_waypoint_manage_dialog_populate (which); } -#ifdef HAVE_NAVIGATE_PLUGIN /** * @brief Pop up a dialog to select a departure from the list of Personal waypoints * Calls the (static) worker function roadmap_trip_waypoint_select_navigation_waypoint @@ -4186,17 +4181,14 @@ { roadmap_trip_waypoint_select_navigation_waypoint(PERSONAL_WAYPOINTS, 1); } -#endif // HAVE_NAVIGATE_PLUGIN -#endif /** * @brief call this after having added all waypoints and ways */ void roadmap_trip_complete (void) { -#ifdef HAVE_NAVIGATE_PLUGIN roadmap_tripdb_complete (); -#endif RoadMapCurrentRoute = (route_head *)ROADMAP_LIST_FIRST(&RoadMapTripRouteHead); roadmap_trip_set_route_current(RoadMapCurrentRoute->rte_name); } +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2015-08-07 14:58:51
|
Revision: 2927 http://sourceforge.net/p/roadmap/code/2927 Author: pgf Date: 2015-08-07 14:58:49 +0000 (Fri, 07 Aug 2015) Log Message: ----------- roadmap_trip: include the current route name in the window title be sure and use the actual current route's name, and not the name we might try and load if it existed. Modified Paths: -------------- trunk/roadmap/src/roadmap_trip.c Modified: trunk/roadmap/src/roadmap_trip.c =================================================================== --- trunk/roadmap/src/roadmap_trip.c 2015-08-07 14:58:46 UTC (rev 2926) +++ trunk/roadmap/src/roadmap_trip.c 2015-08-07 14:58:49 UTC (rev 2927) @@ -104,9 +104,9 @@ ROADMAP_CONFIG_ITEM("Trip", "GPS Focus Release Delay"); /* - * try and put the trip name in the window title + * try and put the trip and route names in the window title */ -#define TRIP_TITLE_FMT " - %s" +#define TRIP_TITLE_FMT " - %s (%s)" /* Default location is: 1 Market St, San Francisco, California, * but every effort is made to choose a more "local" initial @@ -269,21 +269,37 @@ static RoadMapPosition RoadMapTripDefaultPosition = {ROADMAP_INITIAL_LONGITUDE, ROADMAP_INITIAL_LATITUDE}; - static const char *roadmap_trip_current() { return roadmap_config_get (&RoadMapConfigTripName); } +static const char *roadmap_trip_route_current() { + return roadmap_config_get (&RoadMapConfigTripRouteName); +} + + +void roadmap_trip_set_window_name(void) { + + const char *trip, *route; + + trip = roadmap_path_skip_directories(roadmap_trip_current()); + route = (RoadMapCurrentRoute && RoadMapCurrentRoute->rte_name) ? + RoadMapCurrentRoute->rte_name : NULL; + + roadmap_main_title(TRIP_TITLE_FMT, + (trip && *trip) ? trip : "Unnamed Trip", + (route && *route) ? route: "Unnamed Route"); +} + static void roadmap_trip_set_current(const char *name) { + roadmap_config_set (&RoadMapConfigTripName, name); + roadmap_trip_set_window_name(); } -static const char *roadmap_trip_route_current() { - return roadmap_config_get (&RoadMapConfigTripRouteName); -} - static void roadmap_trip_set_route_current(const char *name) { roadmap_config_set (&RoadMapConfigTripRouteName, name); + roadmap_trip_set_window_name(); } /** @@ -2876,8 +2892,6 @@ roadmap_trip_set_current(""); - roadmap_main_title(""); - RoadMapTripUntitled = 1; @@ -2930,7 +2944,6 @@ if ( RoadMapTripUntitled ) { filename = roadmap_trip_path_relative_to_trips(filename); roadmap_trip_set_current(filename); - roadmap_main_title(TRIP_TITLE_FMT, roadmap_path_skip_directories(filename)); RoadMapTripUntitled = 0; } } @@ -3069,7 +3082,6 @@ roadmap_trip_set_current(roadmap_trip_path_relative_to_trips(name)); roadmap_trip_set_modified(0); - roadmap_main_title(TRIP_TITLE_FMT, roadmap_path_skip_directories(name)); RoadMapTripUntitled = 0; } @@ -3090,6 +3102,7 @@ if ( rh->rte_name && rh->rte_name[0] && !strcmp(routename, rh->rte_name)) { RoadMapCurrentRoute = rh; + roadmap_trip_set_route_current(RoadMapCurrentRoute->rte_name); } } } @@ -3131,9 +3144,6 @@ } #endif - roadmap_main_title(TRIP_TITLE_FMT, - roadmap_path_skip_directories(roadmap_trip_current())); - roadmap_screen_refresh (); return ret; @@ -3222,7 +3232,6 @@ if (roadmap_trip_save_file (name)) { roadmap_trip_set_current(name); - roadmap_main_title(TRIP_TITLE_FMT, roadmap_path_skip_directories(name)); RoadMapTripUntitled = 0; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2015-08-07 14:58:48
|
Revision: 2926 http://sourceforge.net/p/roadmap/code/2926 Author: pgf Date: 2015-08-07 14:58:46 +0000 (Fri, 07 Aug 2015) Log Message: ----------- roadmap_trip: preserve selected route across program restarts Modified Paths: -------------- trunk/roadmap/src/roadmap_trip.c Modified: trunk/roadmap/src/roadmap_trip.c =================================================================== --- trunk/roadmap/src/roadmap_trip.c 2015-08-01 17:01:32 UTC (rev 2925) +++ trunk/roadmap/src/roadmap_trip.c 2015-08-07 14:58:46 UTC (rev 2926) @@ -70,6 +70,9 @@ static RoadMapConfigDescriptor RoadMapConfigTripName = ROADMAP_CONFIG_ITEM("Trip", "Name"); +static RoadMapConfigDescriptor RoadMapConfigTripRouteName = + ROADMAP_CONFIG_ITEM("Trip", "Route Name"); + static RoadMapConfigDescriptor RoadMapConfigTripShowInactiveRoutes = ROADMAP_CONFIG_ITEM("Trip", "Show Inactive Routes"); @@ -266,6 +269,23 @@ static RoadMapPosition RoadMapTripDefaultPosition = {ROADMAP_INITIAL_LONGITUDE, ROADMAP_INITIAL_LATITUDE}; + +static const char *roadmap_trip_current() { + return roadmap_config_get (&RoadMapConfigTripName); +} + +static void roadmap_trip_set_current(const char *name) { + roadmap_config_set (&RoadMapConfigTripName, name); +} + +static const char *roadmap_trip_route_current() { + return roadmap_config_get (&RoadMapConfigTripRouteName); +} + +static void roadmap_trip_set_route_current(const char *name) { + roadmap_config_set (&RoadMapConfigTripRouteName, name); +} + /** * @brief * @param modified @@ -1213,6 +1233,7 @@ { RoadMapRouteInProgress = 0; RoadMapCurrentRoute = NULL; + roadmap_trip_set_route_current(NULL); roadmap_trip_unset_route_focii (); roadmap_dialog_hide (name); RoadMapTripRefresh = 1; @@ -1238,6 +1259,7 @@ if (route == RoadMapCurrentRoute) { RoadMapRouteInProgress = 0; RoadMapCurrentRoute = NULL; + roadmap_trip_set_route_current(NULL); roadmap_trip_unset_route_focii (); RoadMapTripRefresh = 1; } @@ -1307,6 +1329,7 @@ if (route != RoadMapCurrentRoute) { RoadMapCurrentRoute = route; + roadmap_trip_set_route_current(route->rte_name); RoadMapRouteIsReversed = 0; RoadMapRouteInProgress = 0; roadmap_trip_set_route_focii (); @@ -1534,6 +1557,7 @@ roadmap_trip_set_modified(1); RoadMapCurrentRoute = new_route; + roadmap_trip_set_route_current(NULL); RoadMapRouteIsReversed = 0; roadmap_trip_set_route_focii (); @@ -1636,6 +1660,7 @@ route_add_wpt_tail (&RoadMapTripQuickRoute, dest_wpt); RoadMapCurrentRoute = &RoadMapTripQuickRoute; + roadmap_trip_set_route_current(NULL); RoadMapRouteIsReversed = 0; RoadMapRouteInProgress = 1; @@ -2833,10 +2858,6 @@ } -static const char *roadmap_trip_current() { - return roadmap_config_get (&RoadMapConfigTripName); -} - /** * @brief start a new trip * Save the current one if there are unsaved changes @@ -2853,7 +2874,7 @@ roadmap_trip_set_modified(0); - roadmap_config_set (&RoadMapConfigTripName, ""); + roadmap_trip_set_current(""); roadmap_main_title(""); @@ -2908,7 +2929,7 @@ if (roadmap_trip_save_file (filename)) { if ( RoadMapTripUntitled ) { filename = roadmap_trip_path_relative_to_trips(filename); - roadmap_config_set (&RoadMapConfigTripName, filename); + roadmap_trip_set_current(filename); roadmap_main_title(TRIP_TITLE_FMT, roadmap_path_skip_directories(filename)); RoadMapTripUntitled = 0; } @@ -3046,8 +3067,7 @@ ROADMAP_LIST_MOVE(&RoadMapTripRouteHead, &tmp_route_list); ROADMAP_LIST_MOVE(&RoadMapTripTrackHead, &tmp_track_list); - roadmap_config_set (&RoadMapConfigTripName, - roadmap_trip_path_relative_to_trips(name)); + roadmap_trip_set_current(roadmap_trip_path_relative_to_trips(name)); roadmap_trip_set_modified(0); roadmap_main_title(TRIP_TITLE_FMT, roadmap_path_skip_directories(name)); RoadMapTripUntitled = 0; @@ -3061,17 +3081,35 @@ if (roadmap_list_count (&RoadMapTripRouteHead) + roadmap_list_count (&RoadMapTripTrackHead) > 1) { - /* Multiple choices? Present a dialog. */ - roadmap_trip_route_manage_dialog (); + + const char *routename = roadmap_trip_route_current(); + if (routename) { + RoadMapListItem *elem, *tmp; + ROADMAP_LIST_FOR_EACH (&RoadMapTripRouteHead, elem, tmp) { + route_head *rh = (route_head *) elem; + if ( rh->rte_name && rh->rte_name[0] && + !strcmp(routename, rh->rte_name)) { + RoadMapCurrentRoute = rh; + } + } + } + if (!RoadMapCurrentRoute) { + /* Multiple choices and no matching saved route name? + * Present a dialog. */ + roadmap_trip_route_manage_dialog (); + } } else { /* If there's only one route (or track), use it. */ if (!ROADMAP_LIST_EMPTY(&RoadMapTripRouteHead)) { RoadMapCurrentRoute = (route_head *)ROADMAP_LIST_FIRST(&RoadMapTripRouteHead); + roadmap_trip_set_route_current(RoadMapCurrentRoute->rte_name); } else if (!ROADMAP_LIST_EMPTY(&RoadMapTripTrackHead)) { RoadMapCurrentRoute = (route_head *)ROADMAP_LIST_FIRST(&RoadMapTripTrackHead); + roadmap_trip_set_route_current(NULL); } else { RoadMapCurrentRoute = NULL; + roadmap_trip_set_route_current(NULL); } } @@ -3183,7 +3221,7 @@ } if (roadmap_trip_save_file (name)) { - roadmap_config_set (&RoadMapConfigTripName, name); + roadmap_trip_set_current(name); roadmap_main_title(TRIP_TITLE_FMT, roadmap_path_skip_directories(name)); RoadMapTripUntitled = 0; } @@ -3332,6 +3370,7 @@ } RoadMapCurrentRoute = new_route; + roadmap_trip_set_route_current(new_route->rte_name); RoadMapRouteIsReversed = 0; RoadMapRouteInProgress = 0; roadmap_trip_set_route_focii (); @@ -3909,6 +3948,7 @@ } roadmap_config_declare ("session", &RoadMapConfigTripName, ""); + roadmap_config_declare ("session", &RoadMapConfigTripRouteName, ""); roadmap_config_declare ("session", &RoadMapConfigFocusName, "GPS"); roadmap_config_declare_distance @@ -4149,4 +4189,5 @@ roadmap_tripdb_complete (); #endif RoadMapCurrentRoute = (route_head *)ROADMAP_LIST_FIRST(&RoadMapTripRouteHead); + roadmap_trip_set_route_current(RoadMapCurrentRoute->rte_name); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2015-08-01 17:01:34
|
Revision: 2925 http://sourceforge.net/p/roadmap/code/2925 Author: pgf Date: 2015-08-01 17:01:32 +0000 (Sat, 01 Aug 2015) Log Message: ----------- roadmap_voice: just say "K" instead of kilometer or kilometers Modified Paths: -------------- trunk/roadmap/src/roadmap_voice.c Modified: trunk/roadmap/src/roadmap_voice.c =================================================================== --- trunk/roadmap/src/roadmap_voice.c 2015-08-01 17:01:29 UTC (rev 2924) +++ trunk/roadmap/src/roadmap_voice.c 2015-08-01 17:01:32 UTC (rev 2925) @@ -157,12 +157,11 @@ {"St", "street"}, /* special cases so we don't say "1 miles" */ - {" 1 Km", " 1 kilometer"}, {" 1 Mi", " 1 mile"}, {" 1 ft", " 1 foot"}, {" 1 m", " 1 meter"}, - {"Km", "K"}, + {"Km", "K"}, // "kilometer[s]" is much too mouthy. say "K" instead. {"Mi", "miles"}, {"ft", "feet"}, {"m", "meters"}, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |