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:07:27
|
Revision: 2974
http://sourceforge.net/p/roadmap/code/2974
Author: pgf
Date: 2015-10-20 15:07:25 +0000 (Tue, 20 Oct 2015)
Log Message:
-----------
buildmap_osm_text: add check for relations already handled by neighbors
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:07:22 UTC (rev 2973)
+++ trunk/roadmap/src/buildmap_osm_text.c 2015-10-20 15:07:25 UTC (rev 2974)
@@ -188,24 +188,24 @@
static void
buildmap_osm_text_point_add(nodeid_t id, int point)
{
- if (nPoints == nPointsAlloc) {
- if (Points)
- nPointsAlloc *= 2;
- else
- nPointsAlloc = 10000;
- if (PointsHash == NULL)
- PointsHash = roadmap_hash_new("PointsHash", nPointsAlloc);
- else
- roadmap_hash_resize(PointsHash, nPointsAlloc);
+ if (nPoints == nPointsAlloc) {
+ 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);
+ roadmap_hash_add(PointsHash, id, nPoints);
- Points[nPoints].id = id;
- Points[nPoints++].point = point;
+ Points[nPoints].id = id;
+ Points[nPoints++].point = point;
}
/**
@@ -216,14 +216,14 @@
static int
buildmap_osm_text_point_get(nodeid_t id)
{
- int i;
+ int i;
- 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;
- return -1;
+ 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;
+ return -1;
}
static int maxRelTable = 0;
@@ -364,7 +364,7 @@
/*
- * @brief creates our .ways table, later used by our neighbors so they
+ * @brief creates our .cov table, later used by our neighbors so they
* know which ways are already being taken care of by us.
*/
void
@@ -372,30 +372,40 @@
{
char nfn[1024];
char *p;
- FILE *fp;
+ FILE *fp = 0;
wayinfo *wp;
+ relinfo *rp;
+ relinfo delim;
strcpy(nfn, outfile);
p = strrchr(nfn, '.');
if (p) *p = '\0';
- strcat(nfn, ".ways");
+ strcat(nfn, ".cov");
- if (!nWayTable) {
- unlink(nfn);
- return;
+ fp = roadmap_file_fopen (path, nfn, "w");
+ if (!fp) buildmap_fatal(0, "can't open %s/%s to write ways", path, nfn);
+
+ if (nWayTable) {
+ for (wp = WayTable; wp < &WayTable[nWayTable]; wp++) {
+ if (wp->id) {
+ fwrite(wp, sizeof(wp->id), 1, fp);
+ }
+ }
}
- fp = roadmap_file_fopen (path, nfn, "w");
+ delim.id = ~0;
+ fwrite(&delim, sizeof(rp->id), 1, fp);
- /* write out the list. it's already sorted */
- for (wp = WayTable; wp < &WayTable[nWayTable]; wp++) {
- if (wp->id)
- {
- fwrite(wp, sizeof(wp->id), 1, fp);
+ if (nRelTable) {
+ for (rp = RelTable; rp < &RelTable[nRelTable]; rp++) {
+ if (rp->id) {
+ fwrite(rp, sizeof(rp->id), 1, fp);
+ }
}
}
fclose(fp);
+
}
@@ -478,42 +488,70 @@
/**
- * @brief neighbor_ways keeps track of ways our neighbors are already
+ * @brief neighbor_coverage keeps track of ways our neighbors are already
* taking care of.
*/
-struct neighbor_ways {
+struct neighbor_coverage {
int tileid; // these are the ways for this tileid
RoadMapFileContext fc; // file context for the mmap
- int count; // how many ways
- const unsigned *wayids; // the way ids for that tileid.
- // (also serves as the "populated" flag.)
-} Neighbor_Ways[8];
+ int waycount; // how many ways
+ const wayid_t *wayids; // the way ids for that tileid.
+ int relcount; // how many relations
+ const relid_t *relids; // the relations ids for that tileid.
+} Neighbor_Coverage[8];
/*
* @brief memory maps the way list for the give tileid, if it exists
*/
void
-buildmap_osm_text_load_neighbor_ways(int neighbor,
- struct neighbor_ways *neighbor_ways)
+buildmap_osm_text_load_neighbor_coverage(int neighbor,
+ struct neighbor_coverage *neighbor_coverage)
{
- const char *waysmap;
+ const wayid_t *covmap;
RoadMapFileContext fc;
+ const wayid_t *idp;
+ int fs = 0;
- waysmap = roadmap_file_map(BuildMapResult,
- roadmap_osm_filename(0, 1, neighbor, ".ways"), "r", &fc);
- if (waysmap) {
- neighbor_ways->tileid = neighbor;
- neighbor_ways->fc = fc;
- neighbor_ways->count = roadmap_file_size(fc) / sizeof(unsigned);
+ covmap = (wayid_t *)roadmap_file_map(BuildMapResult,
+ roadmap_osm_filename(0, 1, neighbor, ".cov"), "r", &fc);
+ if (covmap)
+ fs = roadmap_file_size(fc) / sizeof(wayid_t);
+
+ neighbor_coverage->tileid = neighbor;
+
+ if (!covmap || fs <= 1) {
+ if (covmap) roadmap_file_unmap (&fc);
+ neighbor_coverage->fc = fc;
+ neighbor_coverage->waycount = 0;
+ neighbor_coverage->relcount = 0;
+ return;
}
- neighbor_ways->wayids = (unsigned *)waysmap;
+
+ idp = covmap;
+ while (*idp != (wayid_t)~0) {
+ idp++;
+ if ((idp - covmap) == fs) // didn't find delimiter
+ break;
+ }
+
+ neighbor_coverage->waycount = idp - covmap;
+ if (neighbor_coverage->waycount)
+ neighbor_coverage->wayids = covmap;
+ else
+ neighbor_coverage->wayids = 0;
+
+ neighbor_coverage->relcount = fs - neighbor_coverage->waycount - 1;
+ if (neighbor_coverage->relcount > 0)
+ neighbor_coverage->relids = (relid_t *)(idp + 1);
+ else
+ neighbor_coverage->relids = 0;
}
void
-buildmap_osm_text_unload_neighbor_ways(int i)
+buildmap_osm_text_unload_neighbor_coverage(int i)
{
- roadmap_file_unmap (&Neighbor_Ways[i].fc);
- Neighbor_Ways[i].wayids = 0;
+ roadmap_file_unmap (&Neighbor_Coverage[i].fc);
+ Neighbor_Coverage[i].waycount = Neighbor_Coverage[i].relcount = 0;
}
/*
@@ -523,7 +561,7 @@
void
buildmap_osm_text_neighbor_way_maps(int tileid)
{
- struct neighbor_ways new_neighbor_ways[8];
+ struct neighbor_coverage new_neighbor_coverage[8];
int neighbor_tile;
int i, j;
@@ -535,28 +573,28 @@
/* if we already have that neighbor's ways, reuse */
for (j = 0; j < 8; j++) {
- if (Neighbor_Ways[j].tileid == neighbor_tile) {
- new_neighbor_ways[i] = Neighbor_Ways[j];
- Neighbor_Ways[j].wayids = 0;
+ if (Neighbor_Coverage[j].tileid == neighbor_tile) {
+ new_neighbor_coverage[i] = Neighbor_Coverage[j];
+ Neighbor_Coverage[i].waycount = Neighbor_Coverage[i].relcount = 0;
break;
}
}
/* didn't find it -- fetch the neighbor's ways */
if (j == 8) {
- buildmap_osm_text_load_neighbor_ways(neighbor_tile,
- &new_neighbor_ways[i]);
+ buildmap_osm_text_load_neighbor_coverage(neighbor_tile,
+ &new_neighbor_coverage[i]);
}
}
/* release any old way lists we're not reusing */
for (i = 0; i < 8; i++)
- if (Neighbor_Ways[i].wayids)
- buildmap_osm_text_unload_neighbor_ways(i);
+ if (Neighbor_Coverage[i].waycount || Neighbor_Coverage[i].relcount )
+ buildmap_osm_text_unload_neighbor_coverage(i);
/* our new set of reused or freshly loaded way lists into place */
for (i = 0; i < 8; i++)
- Neighbor_Ways[i] = new_neighbor_ways[i];
+ Neighbor_Coverage[i] = new_neighbor_coverage[i];
}
@@ -564,17 +602,18 @@
* @brief check to see if the given way exists in any of
* our neighbors.
*/
-int
-buildmap_osm_text_check_neighbors(wayid_t wayid)
+static int
+buildmap_osm_text_check_neighbor_way(wayid_t wayid)
{
int i;
wayid_t *r;
for (i = 0; i < 8; i++) {
- if (Neighbor_Ways[i].wayids) {
- r = bsearch(&wayid, Neighbor_Ways[i].wayids,
- Neighbor_Ways[i].count, sizeof(*(Neighbor_Ways[i].wayids)),
- qsort_compare_unsigneds);
+ if (Neighbor_Coverage[i].waycount) {
+ r = bsearch(&wayid, Neighbor_Coverage[i].wayids,
+ Neighbor_Coverage[i].waycount,
+ sizeof(*(Neighbor_Coverage[i].wayids)),
+ qsort_compare_osm_ids);
if (r)
return 1;
}
@@ -582,6 +621,29 @@
return 0;
}
+/*
+ * @brief check to see if the given relation exists in any of
+ * our neighbors.
+ */
+static int
+buildmap_osm_text_check_neighbor_relation(relid_t relid)
+{
+ int i;
+ relid_t *r;
+
+ for (i = 0; i < 8; i++) {
+ if (Neighbor_Coverage[i].relcount) {
+ r = bsearch(&relid, Neighbor_Coverage[i].relids,
+ Neighbor_Coverage[i].relcount,
+ sizeof(*(Neighbor_Coverage[i].relids)),
+ qsort_compare_osm_ids);
+ if (r)
+ return 1;
+ }
+ }
+ return 0;
+}
+
/**
* @brief this structure keeps shape data for a postprocessing step
*/
@@ -814,7 +876,7 @@
/* 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)) {
+ if (is_tile && buildmap_osm_text_check_neighbor_way(way->id) && !has_relation_layer) {
buildmap_verbose("dropping way %lld because a neighbor "
"already has it", way->id);
return READOSM_OK;
@@ -1144,7 +1206,7 @@
}
static int
-parse_relation(const void *user_data, const readosm_relation * relation)
+parse_relation(const void *is_tile, const readosm_relation * relation)
{
const readosm_tag *tag;
const readosm_member *member;
@@ -1161,6 +1223,15 @@
if (relation->member_count == 0)
return READOSM_OK;
+ /* if we're processing a quadtile, don't include any
+ * relations that our neighbors already include */
+ if (is_tile && buildmap_osm_text_check_neighbor_relation(relation->id)) {
+ buildmap_verbose("dropping relation %lld because a neighbor "
+ "already has it", relation->id);
+ return READOSM_OK;
+ }
+
+
for (i = 0; i < relation->tag_count; i++)
{
tag = relation->tags + i;
@@ -1479,9 +1550,7 @@
/* pass 1:
* record entire interesting relations, including layer and name, and
- * record the ways and nodes they refer to. record the relation
- * id along with the way or node, so they can find the relation's
- * layer and name.
+ * record the ways and nodes they refer to.
*/
buildmap_readosm_pass(1, fn, tileid);
@@ -1491,22 +1560,23 @@
/* pass 2:
* record interesting ways, including layer and and name. if there's
- * no layer, and relation id is present, fetch layer from there.
-FIXME: how is naming done? bbox of entire relation? assigned to biggest
- member? at what point do i have all the information present to calculate
- this?
- * record the nodes referred to by all recorded ways
+ * FIXME: how is naming done? bbox of entire relation? assigned
+ * to biggest member? at what point do i have all the information
+ * present to calculate this?
*/
buildmap_readosm_pass(2, fn, tileid);
+
+ /* we've added to the WayTable, so need to sort again, and bump
+ * the number of searchable ways.
+ */
qsort(WayTable, nWayTable, sizeof(*WayTable), qsort_compare_osm_ids);
nSearchableWays = nWayTable;
- // remove_duplicates(WayTable, &nWayTable);
qsort(NodeTable, nNodeTable, sizeof(*NodeTable), qsort_compare_unsigneds);
/* pass 3:
* save interesting nodes, either previously recorded,
- * or interesting by themselves.
+ * or which are interesting by themselves.
* save recorded ways
* save recorded relations. assign relation's layer and/or name to
* some or all of the related ways.
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:07:24
|
Revision: 2973
http://sourceforge.net/p/roadmap/code/2973
Author: pgf
Date: 2015-10-20 15:07:22 +0000 (Tue, 20 Oct 2015)
Log Message:
-----------
buildmap_osm_text.c: first working relation/multipolygon code
the multipolygon algorithm is a bit too simplistic, but the simplest
cases work.
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:07:19 UTC (rev 2972)
+++ trunk/roadmap/src/buildmap_osm_text.c 2015-10-20 15:07:22 UTC (rev 2973)
@@ -83,10 +83,35 @@
* NB: the way->id and node->id elements passed in from readosm
* are already long longs.
*/
-typedef unsigned nodeid_t;
-typedef unsigned wayid_t;
+typedef unsigned osm_id_t;
+typedef osm_id_t nodeid_t;
+typedef osm_id_t wayid_t;
+typedef osm_id_t relid_t;
+struct relinfo {
+ relid_t id; // must be first
+ int layer;
+ int flags;
+ char *name;
+};
+typedef struct relinfo relinfo;
+struct wayinfo {
+ wayid_t id; // must be first
+ int lineid;
+ int layer;
+ int flags;
+ char *name;
+ unsigned relation_id;
+ int relation_layer;
+ int relation_flags;
+ nodeid_t from;
+ nodeid_t to;
+ int ring;
+};
+typedef struct wayinfo wayinfo;
+
+
/**
* @brief some global variables
*/
@@ -94,7 +119,7 @@
static int LineId = 0;
static int l_shoreline, l_boundary;
-static int nWays, nNodes;
+static int nRels, nWays, nNodes;
/**
* @brief add string to dictionary, taking note of null inputs
@@ -122,6 +147,21 @@
return 0;
}
+int
+qsort_compare_osm_ids(const void *id1, const void *id2)
+{
+ wayinfo *w1, *w2;
+ w1 = (wayinfo *)id1;
+ w2 = (wayinfo *)id2;
+ if (w1->id < w2->id)
+ return -1;
+ else if (w1->id > w2->id)
+ return 1;
+ else
+ return 0;
+}
+
+
/**
* @brief incoming lat/lon nodes are translated to roadmap points,
* and a hash is maintained
@@ -186,22 +226,67 @@
return -1;
}
+static int maxRelTable = 0;
+int nRelTable = 0;
+relinfo *RelTable = NULL;
-static int maxWayTable = 0;
-int nWayTable = 0;
-wayid_t *WayTable = NULL;
+/**
+ * @brief we mark a relation as interesting by adding it to RelTable. this
+ * is later sorted, and we can use it later to quickly check if
+ * we thought it was interesing.
+ * @param relid
+ */
+static void
+saveInterestingRelation(relid_t id, char *name,
+ int layer, int flags)
+{
+ relinfo *rp;
-wayid_t *WayTableCopy = NULL;
+ if (nRelTable == maxRelTable) {
+ if (RelTable)
+ maxRelTable *= 2;
+ else
+ maxRelTable = 1000;
+ RelTable = (relinfo *) realloc(RelTable,
+ sizeof(relinfo) * maxRelTable);
+ buildmap_check_allocated(RelTable);
+ }
-static void
-copyWayTable(void)
+ rp = &RelTable[nRelTable];
+ memset(rp, 0, sizeof(*rp));
+
+ rp->id = id;
+ rp->name = name;
+ rp->layer = layer;
+ rp->flags = flags;
+
+ nRelTable++;
+}
+
+/**
+ * @brief after RelTable has been sorted, see if this relation is interesting
+ * @param relid
+ * @return whether we thought relation was interesting when we found it
+ */
+static relinfo *
+isRelationInteresting(relid_t relid)
{
- WayTableCopy = (wayid_t *) malloc(sizeof(wayid_t) * nWayTable);
- buildmap_check_allocated(WayTableCopy);
- memcpy(WayTableCopy, WayTable, nWayTable * sizeof(wayid_t));
+ relinfo *r, rel;
+ rel.id = relid;
+ r = (relinfo *)bsearch(&rel, RelTable, nRelTable,
+ sizeof(*RelTable), qsort_compare_osm_ids);
+ return r;
}
+
+
+static int maxWayTable = 0;
+int nWayTable = 0;
+int nSearchableWays = 0;
+wayinfo *WayTable = NULL;
+
+
/**
* @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
@@ -209,20 +294,45 @@
* @param wayid
*/
static void
-saveInterestingWay(wayid_t wayid)
+saveInterestingWay(wayid_t id, const readosm_way *way,
+ char *name,
+ int layer, int flags,
+ int relation_layer, int relation_flags,
+ relid_t rel_id)
{
+ wayinfo *wp;
if (nWayTable == maxWayTable) {
if (WayTable)
maxWayTable *= 2;
else
maxWayTable = 1000;
- WayTable = (wayid_t *) realloc(WayTable,
- sizeof(wayid_t) * maxWayTable);
+ WayTable = (wayinfo *) realloc(WayTable,
+ sizeof(wayinfo) * maxWayTable);
buildmap_check_allocated(WayTable);
}
- WayTable[nWayTable] = wayid;
+ wp = &WayTable[nWayTable];
+ memset(wp, 0, sizeof(*wp));
+
+ wp->id = id;
+ wp->name = name;
+ if (layer) {
+ wp->layer = layer;
+ wp->flags = flags;
+ }
+ if (rel_id) {
+ wp->relation_id = rel_id;
+ wp->relation_layer = relation_layer;
+ wp->relation_flags = relation_flags;
+ }
+
+ if (way) {
+ wp->from = way->node_refs[0];
+ wp->to = way->node_refs[way->node_ref_count-1];
+ }
+
+
nWayTable++;
}
@@ -231,13 +341,21 @@
* @param wayid
* @return whether we thought way was interesting when we found it
*/
-static wayid_t *
+static wayinfo *
isWayInteresting(wayid_t wayid)
{
- wayid_t *r;
- r = (wayid_t *)bsearch(&wayid, WayTable, nWayTable,
- sizeof(*WayTable), qsort_compare_unsigneds);
- return r;
+ wayinfo *r, w;
+ w.id = wayid;
+ r = (wayinfo *)bsearch(&w, WayTable, nSearchableWays,
+ sizeof(*WayTable), qsort_compare_osm_ids);
+
+ if (r && r->layer )
+ return r;
+
+ if (r && r->relation_layer)
+ return r;
+
+ return NULL;
}
static int maxNodeTable = 0;
@@ -255,7 +373,7 @@
char nfn[1024];
char *p;
FILE *fp;
- wayid_t *wp;
+ wayinfo *wp;
strcpy(nfn, outfile);
p = strrchr(nfn, '.');
@@ -269,11 +387,11 @@
fp = roadmap_file_fopen (path, nfn, "w");
- /* write out the list. it's already sorted, and unwanted entries
- * have been zeroed. */
- for (wp = WayTableCopy; wp < &WayTableCopy[nWayTable]; wp++) {
- if (*wp) {
- fwrite(wp, sizeof(wayid_t), 1, fp);
+ /* write out the list. it's already sorted */
+ for (wp = WayTable; wp < &WayTable[nWayTable]; wp++) {
+ if (wp->id)
+ {
+ fwrite(wp, sizeof(wp->id), 1, fp);
}
}
@@ -367,7 +485,7 @@
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.
+ const unsigned *wayids; // the way ids for that tileid.
// (also serves as the "populated" flag.)
} Neighbor_Ways[8];
@@ -386,16 +504,16 @@
if (waysmap) {
neighbor_ways->tileid = neighbor;
neighbor_ways->fc = fc;
- neighbor_ways->count = roadmap_file_size(fc) / sizeof(wayid_t);
+ neighbor_ways->count = roadmap_file_size(fc) / sizeof(unsigned);
}
- neighbor_ways->ways = (wayid_t *)waysmap;
+ neighbor_ways->wayids = (unsigned *)waysmap;
}
void
buildmap_osm_text_unload_neighbor_ways(int i)
{
roadmap_file_unmap (&Neighbor_Ways[i].fc);
- Neighbor_Ways[i].ways = 0;
+ Neighbor_Ways[i].wayids = 0;
}
/*
@@ -419,7 +537,7 @@
for (j = 0; j < 8; j++) {
if (Neighbor_Ways[j].tileid == neighbor_tile) {
new_neighbor_ways[i] = Neighbor_Ways[j];
- Neighbor_Ways[j].ways = 0;
+ Neighbor_Ways[j].wayids = 0;
break;
}
}
@@ -433,7 +551,7 @@
/* release any old way lists we're not reusing */
for (i = 0; i < 8; i++)
- if (Neighbor_Ways[i].ways)
+ if (Neighbor_Ways[i].wayids)
buildmap_osm_text_unload_neighbor_ways(i);
/* our new set of reused or freshly loaded way lists into place */
@@ -449,20 +567,19 @@
int
buildmap_osm_text_check_neighbors(wayid_t wayid)
{
- int i;
- wayid_t *r;
+ int i;
+ wayid_t *r;
- for (i = 0; i < 8; i++) {
- if (Neighbor_Ways[i].ways) {
- r = bsearch(&wayid, Neighbor_Ways[i].ways,
- Neighbor_Ways[i].count,
- sizeof(*(Neighbor_Ways[i].ways)),
- qsort_compare_unsigneds);
- if (r)
- return 1;
- }
+ for (i = 0; i < 8; i++) {
+ if (Neighbor_Ways[i].wayids) {
+ r = bsearch(&wayid, Neighbor_Ways[i].wayids,
+ Neighbor_Ways[i].count, sizeof(*(Neighbor_Ways[i].wayids)),
+ qsort_compare_unsigneds);
+ if (r)
+ return 1;
}
- return 0;
+ }
+ return 0;
}
/**
@@ -540,41 +657,7 @@
"READOSM_ABORT"
};
-/**
- * @brief callback for initial node parsing, called via readosm_parse()
- */
-static int
-parse_node(const void *is_tile, 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(node->id);
- }
-
- return READOSM_OK;
-}
-
/**
* @brief convert from 12.3456789 to 12345679. note the rounding.
*/
@@ -593,7 +676,7 @@
* @brief callback for final node parsing, called via readosm_parse()
*/
static int
-parse_node_finalize(const void *is_tile, const readosm_node * node)
+parse_node_final(const void *is_tile, const readosm_node * node)
{
const readosm_tag *tag;
const char *name = NULL, *place = NULL;
@@ -602,9 +685,9 @@
RoadMapString s;
int i;
int lat, lon;
+ // int places = 0;
- if (!isNodeInteresting(node->id))
- return READOSM_OK;
+ nNodes++;
for (i = 0; i < node->tag_count; i++)
{
@@ -615,9 +698,23 @@
&flags, &layer)) {
if (flags & PLACE)
place = tag->value;
+ // fprintf(stderr, "t/v %s/%s, got place %d: %s %s\n",
+ // tag->key, tag->value, places, place, name);
+ // places++;
}
}
+ /* unnamed, not a place, and not referenced by a way. skip it */
+ i = isNodeInteresting(node->id);
+ if (!name && (flags != PLACE) && !isNodeInteresting(node->id)) {
+ // fprintf(stderr, "dropping node %s, flags %d, interesting %d\n",
+ // name, flags, i);
+ return READOSM_OK;
+ }
+ // fprintf(stderr, "keeping node %s, flags %d, place %s\n",
+ // name, flags, place);
+
+
/* 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
@@ -650,6 +747,42 @@
}
/**
+ * @brief combine OSM's "name" and "ref" tags into a name we can label with.
+ */
+const char *
+road_name(const char *name, const char *ref)
+{
+ const char *n;
+ char *d;
+ const char *s;
+ static char compound_name[1024];
+
+ if (ref) {
+ n = d = compound_name;
+ 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++;
+ }
+ *d = '\0';
+
+ if (name) {
+ // sprintf(d, ", %s", name);
+ sprintf(d, "%s%s", ENDASHSEP, name);
+ }
+ } else {
+ n = name;
+ }
+ return n;
+}
+
+/**
* @brief callback for initial way parsing, called via readosm_parse()
*/
static int
@@ -660,12 +793,24 @@
int adminlevel = 0;
int is_building = 0, is_territorial = 0, is_coast = 0; // booleans
int layer = 0, flags = 0;
+ const char *name = 0, *ref = 0;
+ wayinfo *wp;
+ int has_relation_layer, has_relation_flags;
int i;
nWays++;
- if (way->node_ref_count == 0)
+ /* if this way was referred to in a relation, fetch what we
+ * found then. */
+ wp = isWayInteresting(way->id);
+ if (wp) {
+ has_relation_layer = wp->relation_layer;
+ has_relation_flags = wp->relation_flags;
+ }
+
+ if (way->node_ref_count < 2) {
return READOSM_OK;
+ }
/* if we're processing a quadtile, don't include any
* ways that our neighbors already include */
@@ -675,11 +820,14 @@
return READOSM_OK;
}
- for (i = 0; i < way->tag_count; i++)
- {
+ for (i = 0; i < way->tag_count; i++) {
tag = way->tags + i;
- if (strcasecmp(tag->key, "building") == 0) {
+ if (strcasecmp(tag->key, "name") == 0) {
+ name = tag->value;
+ } else if (strcasecmp(tag->key, "ref") == 0) {
+ ref = tag->value;
+ } else if (strcasecmp(tag->key, "building") == 0) {
is_building = 1;
#ifdef BUILDMAP_NAVIGATION_SUPPORT
} else if (strcasecmp(tag->key, "oneway") == 0) {
@@ -710,7 +858,7 @@
} else if (amenity) {
buildmap_osm_get_layer(PLACE, "amenity", amenity, &flags, &layer);
} else {
- return READOSM_OK;
+ goto out;
}
}
@@ -721,7 +869,7 @@
/* national == 2, state == 4, ignore lesser boundaries */
/* also ignore territorial (marine) borders */
if (adminlevel > 4 || is_territorial) {
- return READOSM_OK;
+ goto out;
}
#if LATER /* we don't actually have the points yet in pass 1 */
else if (adminlevel > 2) {
@@ -733,7 +881,7 @@
* discard state boundaries as well. */
if (fromlon > -32 || fromlat < 17) {
/* east of the azores or south of mexico */
- return READOSM_OK;
+ goto out;
}
}
#endif
@@ -742,8 +890,39 @@
}
}
- if (layer) {
- saveInterestingWay(way->id);
+ if (flags & PLACE) {
+ if (!tourism && !amenity)
+ flags &= ~PLACE;
+ if (way->node_refs[0] == way->node_refs[way->node_ref_count-1])
+ flags |= AREA;
+ }
+ if (flags & AREA) {
+ if (way->node_refs[0] != way->node_refs[way->node_ref_count-1])
+ flags &= ~AREA;
+ /* see http://wiki.openstreetmap.org/wiki/The_Future_of_Areas
+ * for why the above conditions are simplistic */
+ }
+
+
+out:
+ if (layer || has_relation_layer) {
+ const char *n = road_name(name, ref);
+
+ if (wp) {
+ if (n)
+ wp->name = strdup(n);
+ if (layer) {
+ wp->layer = layer;
+ wp->flags = flags;
+ } else {
+ wp->layer = has_relation_layer;
+ wp->flags = has_relation_flags;
+ }
+ wp->from = way->node_refs[0];
+ wp->to = way->node_refs[way->node_ref_count-1];
+ } else {
+ saveInterestingWay( way->id, way, n ? strdup(n) : 0, layer, flags, 0, 0, 0);
+ }
for (i = 0; i < way->node_ref_count; i++)
saveInterestingNode(way->node_refs[i]);
}
@@ -751,68 +930,151 @@
return READOSM_OK;
}
-/**
- * @brief callback for final way parsing, called via readosm_parse()
- */
-static int
-parse_way_finalize(const void *is_tile, const readosm_way *way)
+void add_line_shapes(const readosm_way *way, int from, int to)
{
- 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;
+ /*
+ * 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.
+ */
+ int *lonsbuf, *latsbuf;
int i, j;
- if (!isWayInteresting(way->id))
- return READOSM_OK;
+ lonsbuf = calloc(to - from + 1, sizeof(way->node_refs[0]));
+ latsbuf = calloc(to - from + 1, sizeof(way->node_refs[0]));
- if (way->node_ref_count == 0)
- return READOSM_OK;
+ for (i = 0, j = from; j <= to; i++, j++) {
- for (i = 0; i < way->tag_count; i++)
- {
- tag = way->tags + i;
+ 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);
- 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;
- }
+ /* Keep info for the shapes */
+ lonsbuf[i] = lon;
+ latsbuf[i] = lat;
- // 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);
+ buildmap_square_adjust_limits(lon, lat);
}
- if ( layer == 0) {
- wayid_t *wp;
- buildmap_debug("discarding way %lld, not interesting (%s)", way->id, name);
- wp = isWayInteresting(way->id);
- if (wp) {
- WayTableCopy[wp-WayTable] = 0;
- }
- return READOSM_OK;
+ if (nShapes == nShapesAlloc) {
+ /* Allocate additional space (in big
+ * chunks) when needed */
+ if (shapes)
+ nShapesAlloc *= 2;
+ else
+ nShapesAlloc = 1000;
+ shapes = realloc(shapes,
+ 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[nShapes].lons = lonsbuf;
+ shapes[nShapes].lats = latsbuf;
+ shapes[nShapes].count = to - from + 1;
+ shapes[nShapes].lineid = LineId;
+
+ nShapes++;
+}
+
+int
+add_shaped_line(const readosm_way *way, int rms_name, int layer, int polygon)
+{
+ RoadMapString rms_dirp, rms_dirs, rms_type;
+ int from_point, to_point, mid_point, line, street;
+
rms_dirp = str2dict(DictionaryPrefix, "");
rms_dirs = str2dict(DictionarySuffix, "");
rms_type = str2dict(DictionaryType, "");
- rms_name = 0;
- if ((flags & PLACE) && (tourism || amenity)) {
+
+ /* 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]);
+
+ if (from_point == to_point && way->node_ref_count > 1) {
+ /* the line code really doesn't want circular ways -- i.e.,
+ * lines where from and to are the same. split those cases
+ * into two lines.
+ */
+
+ int mid_count = way->node_ref_count / 2;
+ mid_point = buildmap_osm_text_point_get(way->node_refs[mid_count]);
+
+ /* first half */
+ LineId++;
+ line = buildmap_line_add(LineId, layer,
+ from_point, mid_point, ROADMAP_LINE_DIRECTION_BOTH);
+ street = buildmap_street_add(layer,
+ rms_dirp, rms_name, rms_type,
+ rms_dirs, line);
+ buildmap_range_add_no_address(line, street);
+
+ add_line_shapes(way, 0, mid_count);
+
+ if (polygon)
+ buildmap_polygon_add_line (0, PolygonId, LineId, POLYGON_SIDE_RIGHT);
+
+ /* second half */
+ LineId++;
+ line = buildmap_line_add(LineId, layer,
+ mid_point, to_point, ROADMAP_LINE_DIRECTION_BOTH);
+ street = buildmap_street_add(layer,
+ rms_dirp, rms_name, rms_type,
+ rms_dirs, line);
+ buildmap_range_add_no_address(line, street);
+
+ add_line_shapes(way, mid_count, way->node_ref_count-1);
+
+ if (polygon)
+ buildmap_polygon_add_line (0, PolygonId, LineId, POLYGON_SIDE_RIGHT);
+
+ } else {
+ LineId++;
+ line = buildmap_line_add(LineId,
+ layer, from_point, to_point, ROADMAP_LINE_DIRECTION_BOTH);
+
+ street = buildmap_street_add(layer,
+ rms_dirp, rms_name, rms_type,
+ rms_dirs, line);
+ buildmap_range_add_no_address(line, street);
+
+ add_line_shapes(way, 0, way->node_ref_count-1);
+ if (polygon)
+ buildmap_polygon_add_line (0, PolygonId, LineId, POLYGON_SIDE_RIGHT);
+ }
+ return LineId;
+}
+/**
+ * @brief callback for final way parsing, called via readosm_parse()
+ */
+static int
+parse_way_final(const void *is_tile, const readosm_way *way)
+{
+ wayinfo *wp;
+ int j;
+ RoadMapString rms_name;
+
+ wp = isWayInteresting(way->id);
+ if (!wp)
+ return READOSM_OK;
+
+ if (way->node_ref_count == 0)
+ return READOSM_OK;
+
+ rms_name = str2dict(DictionaryStreet, wp->name);
+
+ if (wp->flags & PLACE) {
/* 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
@@ -839,164 +1101,253 @@
/* this code looks like buildmap_osm_text_node_finish() */
point = buildmap_point_add(lon, lat);
- if (layer) {
+ if (wp->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",
+ s = str2dict (DictionaryCity, wp->name);
+ p = buildmap_place_add(s, wp->layer, point);
+ // buildmap_debug( "wayplace: finishing %f %f %s (%d) %s layer: %d",
+ buildmap_debug( "wayplace: finishing %f %f (%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);
+ // tourism ? tourism : amenity, p, wp->name, wp->layer);
+ p, wp->name, wp->layer);
+ }
+
+ if (wp->relation_layer && (wp->relation_flags & AREA)) {
+ goto add_as_poly;
+ } else if (wp->relation_layer) {
+ goto add_as_way;
}
-
- } 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 */
-
+ } else if (wp->flags & AREA) {
+ add_as_poly:
/*
* Detect an AREA -> create a polygon
*/
PolygonId++;
- rms_name = str2dict(DictionaryStreet, name);
- buildmap_polygon_add_landmark (PolygonId, layer, rms_name);
+ buildmap_polygon_add_landmark (PolygonId, wp->layer, rms_name);
buildmap_polygon_add(PolygonId, 0, PolygonId);
- 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]);
+ wp->lineid = add_shaped_line(way, rms_name, wp->layer, 1);
+ } else {
+ add_as_way:
+ /* Street name */
+ // buildmap_debug ("Way %lld [%s] ref [%s]", way->id,
+ buildmap_debug ("Way %lld [%s]", way->id,
+ wp->name ? wp->name : "");
- LineId++;
- buildmap_line_add
- (LineId, layer, prevpoint, point,
- ROADMAP_LINE_DIRECTION_BOTH);
- buildmap_polygon_add_line (0, PolygonId, LineId, POLYGON_SIDE_RIGHT);
+ wp->lineid = add_shaped_line(way, rms_name,
+ wp->layer ? wp->layer: wp->relation_layer, 0);
+ }
+ return READOSM_OK;
+}
+
+static int
+parse_relation(const void *user_data, const readosm_relation * relation)
+{
+ const readosm_tag *tag;
+ const readosm_member *member;
+ const char *name = 0;
+ int is_multipolygon = 0;
+ int layer = 0, flags = 0;
+ int waslayer;
+ int is_building = 0;
+ const char *tourism = NULL, *amenity = NULL;
+ int i;
+
+ nRels++;
+
+ if (relation->member_count == 0)
+ return READOSM_OK;
+
+ for (i = 0; i < relation->tag_count; i++)
+ {
+ tag = relation->tags + i;
+
+ if (strcasecmp(tag->key, "type") == 0) {
+ if (strcasecmp(tag->value, "multipolygon") == 0) {
+ is_multipolygon = 1;
}
- } 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)
- */
+ } else if (strcasecmp(tag->key, "name") == 0) {
+ name = tag->value;
+ buildmap_info("warning: relation has name %s", name);
+ } else if (strcasecmp(tag->key, "building") == 0) {
+ is_building = 1;
+ } else if (strcasecmp(tag->key, "tourism") == 0) {
+ tourism = tag->value;
+ } else if (strcasecmp(tag->key, "amenity") == 0) {
+ amenity = tag->value;
+#if 0
+ } else if (strcasecmp(tag->key, "natural") == 0 &&
+ strcasecmp(tag->key, "coastline") == 0) {
+ is_coast = 1;
+#endif
+ }
+
+ waslayer = layer;
+ buildmap_osm_get_layer(PLACE, tag->key, tag->value, &flags, &layer);
+ if (!waslayer && layer)
+ buildmap_info("relation %u has layer %s/%s", relation->id, tag->key, tag->value);
+ }
- int *lonsbuf, *latsbuf;
+ /* 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;
+ }
+ }
- /* Street name */
- buildmap_debug ("Way %lld [%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++;
+ if (is_multipolygon && layer) {
+ for (i = 0; i < relation->member_count; i++)
+ {
+ member = relation->members + i;
+ switch(member->member_type) {
+ case READOSM_MEMBER_WAY:
+ if (!isWayInteresting(member->id)) {
+ saveInterestingWay(member->id, 0, 0, 0, 0, layer, flags, relation->id);
+ qsort(WayTable, nWayTable, sizeof(*WayTable), qsort_compare_osm_ids);
+ nSearchableWays = nWayTable;
}
- n = compound_name;
- *d = '\0';
+ break;
- if (name) {
- // sprintf(d, ", %s", name);
- sprintf(d, "%s%s", ENDASHSEP, name);
- }
- } else {
- n = name;
+ case READOSM_MEMBER_NODE:
+ case READOSM_MEMBER_RELATION:
+ default:
+ break;
}
- rms_name = str2dict(DictionaryStreet, n);
+ }
+ // buildmap_info("warning: save interesting relation %s", name);
+ saveInterestingRelation(relation->id, name ? strdup(name) : 0, layer, flags);
+ }
- 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]);
+ return READOSM_OK;
+}
- line = buildmap_line_add(LineId,
- layer, from_point, to_point, is_oneway);
+static void add_multipolygon(wayinfo **wayinfos, relinfo *rp, int layer, int rms_name, int count)
+{
+ wayinfo *wp, *wp2;
+ nodeid_t from = 0, to = 0;
+ int ring = 0;
+ int i, j;
- street = buildmap_street_add(layer,
- rms_dirp, rms_name, rms_type,
- rms_dirs, line);
- buildmap_range_add_no_address(line, street);
+ buildmap_info("relation %d adding multipolygon", rp->id);
+ // for (wp = wayinfos; wp < wayinfos + count; wp++) {
+ for (i = 0; i < count; i++) {
+ wp = wayinfos[i];
+ if (wp->ring) continue;
+ wp->ring = ++ring;
- /*
- * 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.
- */
+ PolygonId++;
+ buildmap_info("adding polygon %d ring %d", PolygonId, ring);
+ buildmap_polygon_add_landmark (PolygonId, layer, rms_name);
+ buildmap_polygon_add(PolygonId, 0, PolygonId);
+ buildmap_info("adding first line %d (way %d) to polygon %d", wp->lineid, wp->id, PolygonId);
+ buildmap_polygon_add_line (0, PolygonId, wp->lineid, POLYGON_SIDE_RIGHT);
+ buildmap_info(" from %d to %d", wp->from, wp->to);
- lonsbuf = calloc(way->node_ref_count, sizeof(way->node_refs[0]));
- latsbuf = calloc(way->node_ref_count, sizeof(way->node_refs[0]));
+ from = wp->from;
+ to = wp->to;
+ if (to == from)
+ continue;
- 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);
+ for (j = i; j < count; ) {
+ wp2 = wayinfos[j];
+ if (wp2->ring) {
+ j++;
+ continue;
}
- if (nShapes == nShapesAlloc) {
- /* Allocate additional space (in big
- * chunks) when needed */
- if (shapes)
- nShapesAlloc *= 2;
- else
- nShapesAlloc = 1000;
- shapes = realloc(shapes,
- nShapesAlloc * sizeof(struct shapeinfo));
- buildmap_check_allocated(shapes);
+ if (wp2->from == to) {
+ wp2->ring = ring;
+ buildmap_info("adding right line %d (way %d) to polygon %d", wp2->lineid, wp2->id, PolygonId);
+ buildmap_info(" from %d to %d", wp2->from, wp2->to);
+ buildmap_polygon_add_line (0, PolygonId, wp2->lineid,
+ POLYGON_SIDE_RIGHT);
+ to = wp2->to;
+ j = i;
+ } else if (wp2->to == to) {
+ wp2->ring = ring;
+ buildmap_info("adding left line %d (way %d) to polygon %d", wp2->lineid, wp2->id, PolygonId);
+ buildmap_info(" from %d to %d", wp2->from, wp2->to);
+ buildmap_polygon_add_line (0, PolygonId, wp2->lineid,
+ POLYGON_SIDE_LEFT);
+ to = wp2->from;
+ j = i;
+ } else {
+ /* no match */
+ j++;
+ continue;
}
-
- buildmap_debug("lineid %d way->node_ref_count %d",
- LineId, way->node_ref_count);
- /* Keep info for the shapes */
- shapes[nShapes].lons = lonsbuf;
- shapes[nShapes].lats = latsbuf;
- shapes[nShapes].count = way->node_ref_count;
- shapes[nShapes].lineid = LineId;
-
- nShapes++;
+ if (to == from) { /* done with this ring */
+ break;
+ }
+ }
}
- return READOSM_OK;
+ /* clear the ring indicators, in case these ways are part
+ * of another multipolygon, later. */
+ for (i = 0; i < count; i++) {
+ wp = wayinfos[i];
+ wp->ring = 0;
+ }
}
-#if NEEDED
static int
-parse_relation(const void *user_data, const readosm_relation * relation)
+parse_relation_final(const void *user_data, const readosm_relation * relation)
{
+ relinfo *rp;
+ wayinfo *wp, **wayinfos;
+ const readosm_member *member;
+ int i, wc;
+ RoadMapString rms_name;
+
+ rp = isRelationInteresting(relation->id);
+ if (!rp)
+ return READOSM_OK;
+
+ buildmap_info("warning: relation %s is interesting", rp->name);
+
+ // note: assumes this is a multipolygon relation
+
+ PolygonId++;
+
+ rms_name = str2dict(DictionaryStreet, rp->name);
+
+ wayinfos = calloc(relation->member_count, sizeof(*wayinfos));
+ buildmap_check_allocated(wayinfos);
+
+ wc = 0;
+ for (i = 0; i < relation->member_count; i++)
+ {
+ member = relation->members + i;
+ switch(member->member_type) {
+ case READOSM_MEMBER_WAY:
+ if (strcmp(member->role, "outer") != 0 &&
+ strcmp(member->role, "") != 0) {
+ continue;
+ }
+ wp = isWayInteresting(member->id);
+ if (!wp->lineid) buildmap_fatal(0, "found null lineid");
+ wayinfos[wc++] = wp;
+ break;
+
+ case READOSM_MEMBER_NODE:
+ case READOSM_MEMBER_RELATION:
+ default:
+ break;
+ }
+ }
+
+ add_multipolygon(wayinfos, rp, rp->layer, rms_name, wc);
+
+ free(wayinfos);
return READOSM_OK;
}
-#endif
static int text_file_is_pipe;
FILE *buildmap_osm_text_fopen(char *fn)
@@ -1057,11 +1408,14 @@
switch (pass) {
case 1: ret = readosm_parse(handle, is_tile,
- parse_node, parse_way, NULL);
+ NULL, NULL, parse_relation);
break;
case 2: ret = readosm_parse(handle, is_tile,
- parse_node_finalize, parse_way_finalize, NULL);
+ NULL, parse_way, NULL);
break;
+ case 3: ret = readosm_parse(handle, is_tile,
+ parse_node_final, parse_way_final, parse_relation_final);
+ break;
}
if (ret != READOSM_OK) {
buildmap_fatal(0, "buildmap_osm_text pass %d: %s",
@@ -1113,32 +1467,56 @@
l_shoreline = buildmap_layer_get("shore");;
l_boundary = buildmap_layer_get("boundaries");;
+ nRels = 0;
nWays = 0;
nNodes = 0;
nShapes = 0;
nWayTable = 0;
+ nSearchableWays = 0;
nNodeTable = 0;
PolygonId = 0;
LineId = 0;
- /* pass 1: look at all ways and nodes, decide if they're interesting */
+ /* pass 1:
+ * record entire interesting relations, including layer and name, and
+ * record the ways and nodes they refer to. record the relation
+ * id along with the way or node, so they can find the relation's
+ * layer and name.
+ */
buildmap_readosm_pass(1, fn, tileid);
- qsort(WayTable, nWayTable, sizeof(*WayTable), qsort_compare_unsigneds);
+ qsort(RelTable, nRelTable, sizeof(*RelTable), qsort_compare_osm_ids);
+ qsort(WayTable, nWayTable, sizeof(*WayTable), qsort_compare_osm_ids);
+ nSearchableWays = nWayTable;
+
+ /* pass 2:
+ * record interesting ways, including layer and and name. if there's
+ * no layer, and relation id is present, fetch layer from there.
+FIXME: how is naming done? bbox of entire relation? assigned to biggest
+ member? at what point do i have all the information present to calculate
+ this?
+ * record the nodes referred to by all recorded ways
+ */
+ buildmap_readosm_pass(2, fn, tileid);
+ qsort(WayTable, nWayTable, sizeof(*WayTable), qsort_compare_osm_ids);
+ nSearchableWays = nWayTable;
+ // remove_duplicates(WayTable, &nWayTable);
+
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 3:
+ * save interesting nodes, either previously recorded,
+ * or interesting by themselves.
+ * save recorded ways
+ * save recorded relations. assign relation's layer and/or name to
+ * some or all of the related ways.
+ */
+ buildmap_readosm_pass(3, fn, tileid);
- /* pass 2: look at ways again, and finalize */
- buildmap_readosm_pass(2, fn, tileid);
-
buildmap_osm_text_ways_shapeinfo();
- buildmap_info("Ways %d, interesting %d",
- nWays, nWayTable);
+ buildmap_info("Relations %d", nRels);
+ 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);
}
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:07:21
|
Revision: 2972
http://sourceforge.net/p/roadmap/code/2972
Author: pgf
Date: 2015-10-20 15:07:19 +0000 (Tue, 20 Oct 2015)
Log Message:
-----------
buildmap_osm: switch from xapi compatibility to raw overpass api
we need to be able to do recursive requests, in order to fetch
entire relations at once. xapi compatiblity can't do that.
a visible side-effect of this is that xapi expressed bounding
boxes as w,s,e,n, whereas overpass uses the s,w,n,e ordering.
since i don't think there are any dependencies on the ordering,
i've changed buildmap_osm_main.c to be compatible.
and some whitespace cleanup in buildmap_osm_main.c
Modified Paths:
--------------
trunk/roadmap/src/buildmap_osm_main.c
trunk/roadmap/src/rdm_osm_fetch_tile
Modified: trunk/roadmap/src/buildmap_osm_main.c
===================================================================
--- trunk/roadmap/src/buildmap_osm_main.c 2015-10-20 15:07:16 UTC (rev 2971)
+++ trunk/roadmap/src/buildmap_osm_main.c 2015-10-20 15:07:19 UTC (rev 2972)
@@ -214,20 +214,20 @@
bits = tileid2bits(tileid);
buildmap_verbose("buildmap_osm_process_one_tile: tileid 0x%x, bits %d",
- tileid, bits);
+ tileid, bits);
roadmap_osm_tileid_to_bbox(tileid, edges);
- /* w, s, e, n */
+ /* s, w, n, e */
bbp = bbox;
bbp += sprintf(bbp, "%s,",
- roadmap_math_to_floatstring(0, edges->west, MILLIONTHS));
- bbp += sprintf(bbp, "%s,",
- roadmap_math_to_floatstring(0, edges->south, MILLIONTHS));
- bbp += sprintf(bbp, "%s,",
- roadmap_math_to_floatstring(0, edges->east, MILLIONTHS));
- bbp += sprintf(bbp, "%s",
- roadmap_math_to_floatstring(0, edges->north, MILLIONTHS));
-
+ roadmap_math_to_floatstring(0, edges->south, MILLIONTHS));
+ bbp += sprintf(bbp, "%s,",
+ roadmap_math_to_floatstring(0, edges->west, MILLIONTHS));
+ bbp += sprintf(bbp, "%s,",
+ roadmap_math_to_floatstring(0, edges->north, MILLIONTHS));
+ bbp += sprintf(bbp, "%s",
+ roadmap_math_to_floatstring(0, edges->east, MILLIONTHS));
+
/* create all parents of our file */
parent = roadmap_path_parent(BuildMapResult,
roadmap_osm_filename(0, 1, tileid, ".osm.gz"));
@@ -238,12 +238,12 @@
roadmap_osm_filename(0, 1, tileid, ".osm.gz"));
snprintf(cmd, sizeof(cmd), "%s %s"
- "--bits %d --bbox %s --xmlfile %s",
- fetcher, BuildMapReDownload ? "--force " : "",
+ "--bits %d --bbox %s --xmlfile %s",
+ fetcher, BuildMapReDownload ? "--force " : "",
bits, bbox, xmlfile);
ret = system(cmd);
- if ((WEXITSTATUS(ret) != 0) ||
+ if ((WEXITSTATUS(ret) != 0) ||
(WIFSIGNALED(ret) &&
(WTERMSIG(ret) == SIGINT || WTERMSIG(ret) == SIGQUIT))) {
ret = -1;
@@ -325,7 +325,7 @@
return ret2;
return ret;
-
+
}
int qsort_compare_tiles(const void *t1, const void *t2)
@@ -622,15 +622,15 @@
buildmap_db_sort();
if (buildmap_is_verbose()) {
- roadmap_hash_summary();
- buildmap_db_summary();
+ roadmap_hash_summary();
+ buildmap_db_summary();
}
- buildmap_osm_save(tileid, 1);
- }
+ buildmap_osm_save(tileid, 1);
+ }
- buildmap_db_reset();
- roadmap_hash_reset();
+ buildmap_db_reset();
+ roadmap_hash_reset();
}
return ret < 0;
@@ -691,22 +691,22 @@
roadmap_osm_tileid_to_bbox(tileid, e);
printf("tileid:\t0x%08x\t%d\n", tileid, tileid);
- printf("true tileid:\t0x%08x\t%d\n",
+ printf("true tileid:\t0x%08x\t%d\n",
tileid2trutile(tileid), tileid2trutile(tileid));
printf("bits:\t%d\n", tileid2bits(tileid));
pos1.latitude = (e->north + e->south)/2;
pos1.longitude = (e->west + e->east)/2;
- printf("center:\t%s,%s\n",
+ printf("center:\t%s,%s\n",
roadmap_math_to_floatstring(lat, pos1.latitude, MILLIONTHS),
roadmap_math_to_floatstring(lon, pos1.longitude, MILLIONTHS));
- printf("north:\t%s\n",
+ printf("north:\t%s\n",
roadmap_math_to_floatstring(NULL, e->north, MILLIONTHS));
- printf("south:\t%s\n",
+ printf("south:\t%s\n",
roadmap_math_to_floatstring(NULL, e->south, MILLIONTHS));
- printf("east:\t%s\n",
+ printf("east:\t%s\n",
roadmap_math_to_floatstring(NULL, e->east, MILLIONTHS));
- printf("west:\t%s\n",
+ printf("west:\t%s\n",
roadmap_math_to_floatstring(NULL, e->west, MILLIONTHS));
roadmap_math_set_center (&pos1);
@@ -731,7 +731,7 @@
(NULL, roadmap_math_to_trip_distance_tenths
(roadmap_math_distance(&pos1, &pos2)) , TENTHS), roadmap_math_trip_unit());
}
-
+
return 0;
}
@@ -816,11 +816,11 @@
roadmap_osm_filename(filename, 1, n, ".rdm");
printf("%s ", filename);
roadmap_osm_tileid_to_bbox(n, edges);
- /* w, s, e, n */
+ /* s, w, n, e */
+ printf("%s,", roadmap_math_to_floatstring(0, edges->south, MILLIONTHS));
printf("%s,", roadmap_math_to_floatstring(0, edges->west, MILLIONTHS));
- printf("%s,", roadmap_math_to_floatstring(0, edges->south, MILLIONTHS));
- printf("%s,", roadmap_math_to_floatstring(0, edges->east, MILLIONTHS));
- printf("%s\n", roadmap_math_to_floatstring(0, edges->north, MILLIONTHS));
+ printf("%s,", roadmap_math_to_floatstring(0, edges->north, MILLIONTHS));
+ printf("%s\n", roadmap_math_to_floatstring(0, edges->east, MILLIONTHS));
}
}
@@ -843,7 +843,7 @@
int listonly;
int tileid;
char *class, *latlonarg, *fetcher, *inputfile;
-
+
progname = strrchr(argv[0], '/');
if (progname) progname++;
Modified: trunk/roadmap/src/rdm_osm_fetch_tile
===================================================================
--- trunk/roadmap/src/rdm_osm_fetch_tile 2015-10-20 15:07:16 UTC (rev 2971)
+++ trunk/roadmap/src/rdm_osm_fetch_tile 2015-10-20 15:07:19 UTC (rev 2972)
@@ -14,10 +14,32 @@
: args: $*
-server="www.overpass-api.de/api/xapi?*"
-#server="overpass.osm.rambler.ru/cgi/xapi?*"
+urlencode()
+{
+ sed -e 's/"/%22/g' \
+ -e 's/\//%2F/g' \
+ -e 's/\./%2E/g' \
+ -e 's/,/%2C/g' \
+ -e 's/:/%3A/g' \
+ -e 's/;/%3B/g' \
+ -e 's/</%3C/g' \
+ -e 's/>/%3E/g' \
+ -e 's/(/%28/g' \
+ -e 's/)/%29/g' \
+ -e 's/ /%20/g' \
+ -e 's/\&/%26/g'
+}
+make_url()
+{
+ #meta=" meta" # include metadata
+ query="(node($bbox);<;>;);out$meta;"
+ server=overpass-api.de/api/interpreter
+ echo http://$server?data=$(echo "$query" | urlencode)
+}
+
+
if ! opts="$(getopt -o b:B:x:f \
-l bits:,bbox:,xmlfile:,force -n $program -- $@)"
then
@@ -42,7 +64,7 @@
esac
done
-bbox="[bbox=$bbox]"
+#bbox="[bbox=$bbox]"
trap "rm -f $xmlfile.tmp" 0
@@ -83,8 +105,7 @@
*.gz) want_compressed=1 ;;
esac
-url="http://$server$bbox$query$me"
-
+url=$(make_url)
echo "Fetching from $url"
if [ "$want_compressed" ]
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:07:18
|
Revision: 2971
http://sourceforge.net/p/roadmap/code/2971
Author: pgf
Date: 2015-10-20 15:07:16 +0000 (Tue, 20 Oct 2015)
Log Message:
-----------
buildmap_osm_text.c: switch to using new readosm_fopen() API
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:07:13 UTC (rev 2970)
+++ trunk/roadmap/src/buildmap_osm_text.c 2015-10-20 15:07:16 UTC (rev 2971)
@@ -40,6 +40,7 @@
#include <string.h>
#include <stdarg.h>
#include <ctype.h>
+#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -997,6 +998,39 @@
}
#endif
+static int text_file_is_pipe;
+FILE *buildmap_osm_text_fopen(char *fn)
+{
+ FILE *fp;
+ int len;
+
+ len = strlen(fn);
+ errno = 0;
+ if (len > 3 && strcmp(&fn[len-3], ".gz") == 0) {
+ char command[1024];
+ sprintf(command, "gzip -d -c %s", fn);
+ fp = popen(command, "r");
+ text_file_is_pipe = 1;
+ } else {
+ fp = fopen(fn, "r");
+ text_file_is_pipe = 0;
+ }
+
+ if (fp == NULL) {
+ buildmap_fatal(0, "couldn't open \"%s\", %s", fn, strerror(errno));
+ return NULL;
+ }
+
+ return fp;
+}
+
+int buildmap_osm_text_fclose(FILE *fp)
+{
+ if (text_file_is_pipe)
+ return pclose(fp);
+ else
+ return fclose(fp);
+}
/**
* @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.
@@ -1006,13 +1040,15 @@
int ret;
const void *handle;
void *is_tile = 0;
+ FILE *fp;
if (tileid) is_tile = (void *)1;
buildmap_info("Starting pass %d", pass);
// buildmap_set_source("pass %d", pass);
- ret = readosm_open(fn, &handle);
+ fp = buildmap_osm_text_fopen(fn);
+ ret = readosm_fopen(fp, READOSM_OSM_FORMAT, &handle);
if (ret != READOSM_OK) {
buildmap_fatal(0, "buildmap_osm_text: couldn't open \"%s\", %s",
fn, readosm_errors[-ret]);
@@ -1039,6 +1075,11 @@
pass, readosm_errors[-ret]);
return;
}
+ if (buildmap_osm_text_fclose(fp)) {
+ buildmap_fatal(0, "buildmap_osm_text pass %d: %s",
+ pass, strerror(errno));
+ return;
+ }
}
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:07:15
|
Revision: 2970
http://sourceforge.net/p/roadmap/code/2970
Author: pgf
Date: 2015-10-20 15:07:13 +0000 (Tue, 20 Oct 2015)
Log Message:
-----------
buildmap_dictionary, buildmap_line: enhance progress messages
Modified Paths:
--------------
trunk/roadmap/src/buildmap_dictionary.c
trunk/roadmap/src/buildmap_line.c
Modified: trunk/roadmap/src/buildmap_dictionary.c
===================================================================
--- trunk/roadmap/src/buildmap_dictionary.c 2015-10-20 15:07:10 UTC (rev 2969)
+++ trunk/roadmap/src/buildmap_dictionary.c 2015-10-20 15:07:13 UTC (rev 2970)
@@ -821,7 +821,7 @@
return 1;
}
- buildmap_info ("saving dictionary...");
+ buildmap_info ("saving %d dictionary volumes...", DictionaryVolumeCount);
for (i = 0; i < DictionaryVolumeCount; i++) {
Modified: trunk/roadmap/src/buildmap_line.c
===================================================================
--- trunk/roadmap/src/buildmap_line.c 2015-10-20 15:07:10 UTC (rev 2969)
+++ trunk/roadmap/src/buildmap_line.c 2015-10-20 15:07:13 UTC (rev 2970)
@@ -243,11 +243,11 @@
this_line = Line[block] + offset;
if ((from < 0) || (to < 0)) {
- buildmap_fatal (0, "invalid points");
+ buildmap_fatal (0, "buildmap_line_add: invalid points");
}
if (layer <= 0) {
abort();
- buildmap_fatal (0, "invalid layer %d in line #%d", layer, tlid);
+ buildmap_fatal (0, "buildmap_line_add: invalid layer %d in line #%d", layer, tlid);
}
this_line->tlid = tlid;
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:07:12
|
Revision: 2969
http://sourceforge.net/p/roadmap/code/2969
Author: pgf
Date: 2015-10-20 15:07:10 +0000 (Tue, 20 Oct 2015)
Log Message:
-----------
gtk2/roadmap_canvas.c: don't draw very long lines and big polygons in chunks
this was introducing drawing errors in large polygons
Modified Paths:
--------------
trunk/roadmap/src/gtk2/roadmap_canvas.c
Modified: trunk/roadmap/src/gtk2/roadmap_canvas.c
===================================================================
--- trunk/roadmap/src/gtk2/roadmap_canvas.c 2015-10-20 15:07:07 UTC (rev 2968)
+++ trunk/roadmap/src/gtk2/roadmap_canvas.c 2015-10-20 15:07:10 UTC (rev 2969)
@@ -394,19 +394,19 @@
pango_layout_context_changed(RoadMapLayout);
}
+static GdkPoint *gdkPoints;
+static int ngdkPoints;
void roadmap_canvas_draw_multiple_points (int count, RoadMapGuiPoint *points) {
- GdkPoint gdkpoints[1024];
+ if (ngdkPoints < count) {
+ ngdkPoints = count;
+ gdkPoints = realloc(gdkPoints, ngdkPoints * sizeof(GdkPoint));
+ roadmap_check_allocated(gdkPoints);
+ }
- while (count > 1024) {
- roadmap_canvas_convert_points (gdkpoints, points, 1024);
- gdk_draw_points (RoadMapDrawingBuffer, RoadMapGc, gdkpoints, 1024);
- points += 1024;
- count -= 1024;
- }
- roadmap_canvas_convert_points (gdkpoints, points, count);
- gdk_draw_points (RoadMapDrawingBuffer, RoadMapGc, gdkpoints, count);
+ roadmap_canvas_convert_points (gdkPoints, points, count);
+ gdk_draw_points (RoadMapDrawingBuffer, RoadMapGc, gdkPoints, count);
}
void roadmap_canvas_draw_multiple_lines
@@ -414,27 +414,22 @@
int i;
int count_of_points;
- GdkPoint gdkpoints[1024];
for (i = 0; i < count; ++i) {
- count_of_points = *lines;
+ count_of_points = *lines;
+ if (ngdkPoints < count_of_points) {
+ ngdkPoints = count_of_points;
+ gdkPoints = realloc(gdkPoints, ngdkPoints * sizeof(GdkPoint));
+ roadmap_check_allocated(gdkPoints);
+ }
- while (count_of_points > 1024) {
- roadmap_canvas_convert_points (gdkpoints, points, 1024);
- gdk_draw_lines (RoadMapDrawingBuffer, RoadMapGc, gdkpoints, 1024);
+ roadmap_canvas_convert_points (gdkPoints, points, count_of_points);
+ gdk_draw_lines (RoadMapDrawingBuffer,
+ RoadMapGc, gdkPoints, count_of_points);
- /* We shift by 1023 only, because we must link the lines. */
- points += 1023;
- count_of_points -= 1023;
- }
-
- roadmap_canvas_convert_points (gdkpoints, points, count_of_points);
- gdk_draw_lines (RoadMapDrawingBuffer,
- RoadMapGc, gdkpoints, count_of_points);
-
- points += count_of_points;
- lines += 1;
+ points += count_of_points;
+ lines += 1;
}
}
@@ -445,28 +440,23 @@
int i;
int count_of_points;
- GdkPoint gdkpoints[1024];
for (i = 0; i < count; ++i) {
- count_of_points = *polygons;
+ count_of_points = *polygons;
+ if (ngdkPoints < count_of_points) {
+ ngdkPoints = count_of_points;
+ gdkPoints = realloc(gdkPoints, ngdkPoints * sizeof(GdkPoint));
+ }
+ roadmap_check_allocated(gdkPoints);
- while (count_of_points > 1024) {
- roadmap_canvas_convert_points (gdkpoints, points, 1024);
- gdk_draw_polygon (RoadMapDrawingBuffer,
- RoadMapGc, filled, gdkpoints, 1024);
+ roadmap_canvas_convert_points (gdkPoints, points, count_of_points);
+ gdk_draw_polygon (RoadMapDrawingBuffer,
+ RoadMapGc, filled, gdkPoints, count_of_points);
- /* We shift by 1023 only, because we must link the lines. */
- points += 1023;
- count_of_points -= 1023;
- }
+ polygons += 1;
+ points += count_of_points;
- roadmap_canvas_convert_points (gdkpoints, points, count_of_points);
- gdk_draw_polygon (RoadMapDrawingBuffer,
- RoadMapGc, filled, gdkpoints, count_of_points);
-
- polygons += 1;
- points += count_of_points;
}
}
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:07:09
|
Revision: 2968
http://sourceforge.net/p/roadmap/code/2968
Author: pgf
Date: 2015-10-20 15:07:07 +0000 (Tue, 20 Oct 2015)
Log Message:
-----------
agg_support/roadmap_canvas.cpp: compilation errors: fix typos
Modified Paths:
--------------
trunk/roadmap/src/agg_support/roadmap_canvas.cpp
Modified: trunk/roadmap/src/agg_support/roadmap_canvas.cpp
===================================================================
--- trunk/roadmap/src/agg_support/roadmap_canvas.cpp 2015-10-20 15:07:04 UTC (rev 2967)
+++ trunk/roadmap/src/agg_support/roadmap_canvas.cpp 2015-10-20 15:07:07 UTC (rev 2968)
@@ -332,7 +332,6 @@
void roadmap_canvas_draw_string (RoadMapGuiPoint *position,
int corner,
- int size,
const char *text) {
int text_width;
int text_ascent;
@@ -647,6 +646,7 @@
int width,
int angle, const char *text)
{
+ int size;
if (RoadMapCanvasFontLoaded != 1) return;
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:07:06
|
Revision: 2967
http://sourceforge.net/p/roadmap/code/2967
Author: pgf
Date: 2015-10-20 15:07:04 +0000 (Tue, 20 Oct 2015)
Log Message:
-----------
buildmap_metadata.c: don't reset metadata, so it can be used for all files
Modified Paths:
--------------
trunk/roadmap/src/buildmap_metadata.c
trunk/roadmap/src/roadmap_metadata.c
Modified: trunk/roadmap/src/buildmap_metadata.c
===================================================================
--- trunk/roadmap/src/buildmap_metadata.c 2015-10-20 15:07:01 UTC (rev 2966)
+++ trunk/roadmap/src/buildmap_metadata.c 2015-10-20 15:07:04 UTC (rev 2967)
@@ -47,6 +47,17 @@
#include "buildmap.h"
#include "buildmap_metadata.h"
+/* metadata is somewhat special, in that if we're creating more than
+ * one rdm file in a single invocation, the metadata will be the same
+ * for all those files. this only happens in buildmap_osm, and only
+ * when asked to create quadtiles to cover an entire region. in all
+ * other cases (i.e., when buildmap is creating from tiger data, or
+ * when buildmap_osm is creating a single country iso), the metadata
+ * will be used just once before we exit. so: we skip doing a reset
+ * of the metadata table, which allows it to be duplicated for all
+ * .rdm files created in a single invocation.
+ */
+#define DO_METADATA_RESET 0
#define BUILDMAP_MAX_VALUES 64
@@ -100,10 +111,8 @@
RoadMapString coded_name;
RoadMapString coded_value;
-
if (AttributeByName == NULL) buildmap_metadata_initialize();
-
/* First check if the attribute is already known. */
coded_category =
@@ -274,6 +283,7 @@
static void buildmap_metadata_reset (void) {
+#if DO_METADATA_RESET
int i;
for (i = 0; i < BUILDMAP_BLOCK; i++) {
@@ -287,6 +297,7 @@
roadmap_hash_delete (AttributeByName);
AttributeByName = NULL;
+#endif
}
Modified: trunk/roadmap/src/roadmap_metadata.c
===================================================================
--- trunk/roadmap/src/roadmap_metadata.c 2015-10-20 15:07:01 UTC (rev 2966)
+++ trunk/roadmap/src/roadmap_metadata.c 2015-10-20 15:07:04 UTC (rev 2967)
@@ -123,7 +123,7 @@
this->strings = roadmap_dictionary_open ("attributes");
if (this->strings == NULL) {
- roadmap_log (ROADMAP_FATAL, "cannot open dictionary");
+ roadmap_log (ROADMAP_FATAL, "cannot open 'attributes' dictionary");
}
}
}
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:07:03
|
Revision: 2966
http://sourceforge.net/p/roadmap/code/2966
Author: pgf
Date: 2015-10-20 15:07:01 +0000 (Tue, 20 Oct 2015)
Log Message:
-----------
buildmap_square.c: don't let extremely sparse squares cause crash
it actually feels like the math is a little sloppy -- the min/max
values are inclusive of all points in the square, yet we subtract
min from max when calculating size.
Modified Paths:
--------------
trunk/roadmap/src/buildmap_square.c
Modified: trunk/roadmap/src/buildmap_square.c
===================================================================
--- trunk/roadmap/src/buildmap_square.c 2015-10-20 15:06:58 UTC (rev 2965)
+++ trunk/roadmap/src/buildmap_square.c 2015-10-20 15:07:01 UTC (rev 2966)
@@ -197,7 +197,9 @@
minlatitude = SortMinLatitude;
count_longitude = (maxlongitude - minlongitude + 0x7fef) / 0x7ff0;
+ if (!count_longitude) count_longitude = 1;
count_latitude = (maxlatitude - minlatitude + 0x7fef) / 0x7ff0;
+ if (!count_latitude) count_latitude = 1;
SquareTableSize = count_longitude * count_latitude;
SquareCount = SquareTableSize;
@@ -212,7 +214,9 @@
buildmap_fatal (0, "buildmap_square: not enough data");
size_longitude = (maxlongitude - minlongitude) / count_longitude;
+ if (!size_longitude) size_longitude = 1;
size_latitude = (maxlatitude - minlatitude) / count_latitude;
+ if (!size_latitude) size_latitude = 1;
SortStepLongitude = size_longitude;
SortStepLatitude = size_latitude;
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:07:00
|
Revision: 2965
http://sourceforge.net/p/roadmap/code/2965
Author: pgf
Date: 2015-10-20 15:06:58 +0000 (Tue, 20 Oct 2015)
Log Message:
-----------
buildmap_osm_main.c: add --download option, to force new OSM download
this simply passes --force to rdm_fetch_osm_tile
Modified Paths:
--------------
trunk/roadmap/src/buildmap_osm_main.c
Modified: trunk/roadmap/src/buildmap_osm_main.c
===================================================================
--- trunk/roadmap/src/buildmap_osm_main.c 2015-10-20 15:06:55 UTC (rev 2964)
+++ trunk/roadmap/src/buildmap_osm_main.c 2015-10-20 15:06:58 UTC (rev 2965)
@@ -55,6 +55,7 @@
int BuildMapNoLongLines;
static int BuildMapReplaceAll = 0;
+static int BuildMapReDownload = 0;
static char *BuildMapFileName = 0;
char *BuildMapResult;
@@ -67,6 +68,8 @@
"The number of bits of quadtile address"},
{"replace", "r", opt_flag, "0",
"Rebuild .rdm files, reuse existing .osm if possible"},
+ {"download", "", opt_flag, "0",
+ "Force downloading a new copy of the OSM data"},
{"maps", "m", opt_string, "",
"Location for the generated map files"},
{"fetcher", "F", opt_string, "rdm_osm_fetch_tile",
@@ -234,9 +237,10 @@
xmlfile = roadmap_path_join(BuildMapResult,
roadmap_osm_filename(0, 1, tileid, ".osm.gz"));
- snprintf(cmd, sizeof(cmd), "%s "
+ snprintf(cmd, sizeof(cmd), "%s %s"
"--bits %d --bbox %s --xmlfile %s",
- fetcher, bits, bbox, xmlfile);
+ fetcher, BuildMapReDownload ? "--force " : "",
+ bits, bbox, xmlfile);
ret = system(cmd);
if ((WEXITSTATUS(ret) != 0) ||
@@ -859,6 +863,7 @@
opt_val("class", &class) ||
opt_val("bits", &osm_bits) ||
opt_val("replace", &BuildMapReplaceAll) ||
+ opt_val("download", &BuildMapReDownload) ||
opt_val("maps", &BuildMapResult) ||
opt_val("fetcher", &fetcher) ||
opt_val("tileid", &tileid) ||
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:57
|
Revision: 2964
http://sourceforge.net/p/roadmap/code/2964
Author: pgf
Date: 2015-10-20 15:06:55 +0000 (Tue, 20 Oct 2015)
Log Message:
-----------
rdm_osm_fetch_tile: add --force option, to force a new OSM download
Modified Paths:
--------------
trunk/roadmap/src/rdm_osm_fetch_tile
Modified: trunk/roadmap/src/rdm_osm_fetch_tile
===================================================================
--- trunk/roadmap/src/rdm_osm_fetch_tile 2015-10-20 15:06:52 UTC (rev 2963)
+++ trunk/roadmap/src/rdm_osm_fetch_tile 2015-10-20 15:06:55 UTC (rev 2964)
@@ -18,8 +18,8 @@
#server="overpass.osm.rambler.ru/cgi/xapi?*"
-if ! opts="$(getopt -o b:B:x: \
- -l bits:,bbox:,xmlfile: -n $program -- $@)"
+if ! opts="$(getopt -o b:B:x:f \
+ -l bits:,bbox:,xmlfile:,force -n $program -- $@)"
then
usage
fi
@@ -27,6 +27,7 @@
eval set -- "$opts"
xmlfile="-"
+force=;
while true
do
@@ -35,6 +36,7 @@
-b|--bits) bits=$2; shift 2 ;;
-B|--bbox) bbox=$2; shift 2 ;;
-x|--xmlfile) xmlfile=$2; shift 2 ;;
+ -f|--force) force=yes; shift 1 ;;
--) shift; break ;;
*) usage ;;
esac
@@ -44,12 +46,12 @@
trap "rm -f $xmlfile.tmp" 0
-if [ -e $xmlfile ]
+if [ ! "$force" -a -e $xmlfile ]
then
echo Already have $xmlfile
exit
fi
-if [ -e ${xmlfile%.gz} ]
+if [ ! "$force" -a -e ${xmlfile%.gz} ]
then
echo Already have uncompressed $xmlfile
exit
@@ -58,7 +60,7 @@
# normally the .osm.gz files are stored alongside the .rdm files.
# but for development, it can be convenient to be able to get the .osm from
# somewhere else on the local system.
-localstore=/usr/local/share/roadmap/newquads
+#localstore=/usr/local/share/roadmap/newquads
# isolate the qt19/.../file.osm.gz partial path
wantqtpath=qt$bits/${xmlfile##*/qt$bits}
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:54
|
Revision: 2963
http://sourceforge.net/p/roadmap/code/2963
Author: pgf
Date: 2015-10-20 15:06:52 +0000 (Tue, 20 Oct 2015)
Log Message:
-----------
roadmap_hash: change key values to unsigned
not sure this is strictly necessary, but buildmap_osm_text does
pass in some values that don't fit in an int.
Modified Paths:
--------------
trunk/roadmap/src/roadmap_hash.c
trunk/roadmap/src/roadmap_hash.h
Modified: trunk/roadmap/src/roadmap_hash.c
===================================================================
--- trunk/roadmap/src/roadmap_hash.c 2015-10-20 15:06:49 UTC (rev 2962)
+++ trunk/roadmap/src/roadmap_hash.c 2015-10-20 15:06:52 UTC (rev 2963)
@@ -94,7 +94,7 @@
* @param key
* @param index
*/
-void roadmap_hash_add (RoadMapHash *hash, int key, int index) {
+void roadmap_hash_add (RoadMapHash *hash, unsigned int key, int index) {
int hash_code = abs(key % ROADMAP_HASH_MODULO);
@@ -118,7 +118,7 @@
* @param hash
* @param key
*/
-int roadmap_hash_get_first (RoadMapHash *hash, int key) {
+int roadmap_hash_get_first (RoadMapHash *hash, unsigned int key) {
int hash_code = abs(key % ROADMAP_HASH_MODULO);
Modified: trunk/roadmap/src/roadmap_hash.h
===================================================================
--- trunk/roadmap/src/roadmap_hash.h 2015-10-20 15:06:49 UTC (rev 2962)
+++ trunk/roadmap/src/roadmap_hash.h 2015-10-20 15:06:52 UTC (rev 2963)
@@ -51,8 +51,8 @@
RoadMapHash *roadmap_hash_new (char *name, int size);
-void roadmap_hash_add (RoadMapHash *hash, int key, int index);
-int roadmap_hash_get_first (RoadMapHash *hash, int key);
+void roadmap_hash_add (RoadMapHash *hash, unsigned int key, int index);
+int roadmap_hash_get_first (RoadMapHash *hash, unsigned int key);
int roadmap_hash_get_next (RoadMapHash *hash, int index);
void roadmap_hash_resize (RoadMapHash *hash, int size);
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:51
|
Revision: 2962
http://sourceforge.net/p/roadmap/code/2962
Author: pgf
Date: 2015-10-20 15:06:49 +0000 (Tue, 20 Oct 2015)
Log Message:
-----------
buildmap_osm_text: fix issues resulting from node numbers outgrowing int
also, always map "interesting" places, even if they have no name.
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:46 UTC (rev 2961)
+++ trunk/roadmap/src/buildmap_osm_text.c 2015-10-20 15:06:49 UTC (rev 2962)
@@ -75,7 +75,13 @@
extern char *BuildMapResult;
-/* OSM has over 2G nodes already -- enough to overflow a 32 bit signed int */
+/* OSM has over 3G nodes already -- enough to overflow a 32 bit signed
+ * integer. nodeid_t should really be "long long". i think that may have
+ * repercussions for the roadmap_hash layer, though.
+ *
+ * NB: the way->id and node->id elements passed in from readosm
+ * are already long longs.
+ */
typedef unsigned nodeid_t;
typedef unsigned wayid_t;
@@ -122,8 +128,8 @@
static int nPointsAlloc = 0;
static int nPoints = 0;
static struct points {
- int id;
- int point;
+ nodeid_t id;
+ int point;
} *Points = 0;
RoadMapHash *PointsHash = NULL;
@@ -139,7 +145,7 @@
}
static void
-buildmap_osm_text_point_add(int id, int point)
+buildmap_osm_text_point_add(nodeid_t id, int point)
{
if (nPoints == nPointsAlloc) {
if (Points)
@@ -167,7 +173,7 @@
* @return the internal index
*/
static int
-buildmap_osm_text_point_get(int id)
+buildmap_osm_text_point_get(nodeid_t id)
{
int i;
@@ -562,7 +568,7 @@
if (name || (flags & PLACE)) {
buildmap_debug( "saving %s %s", place, name);
- saveInterestingNode((nodeid_t)(node->id));
+ saveInterestingNode(node->id);
}
return READOSM_OK;
@@ -628,13 +634,12 @@
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 [%d %d] %s (%d) %s layer: %d",
+ s = str2dict (DictionaryCity, name);
+ p = buildmap_place_add(s, layer, point);
+ buildmap_debug("finishing %lld %1.7f %1.7f %s (%d) %s layer: %d",
+ node->id,
node->latitude, node->longitude,
- lat, lon, place, p, name, layer);
+ place, p, name, layer);
} else {
buildmap_debug( "dropping %s %s", place, name);
}
@@ -664,7 +669,7 @@
/* 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 "
+ buildmap_verbose("dropping way %lld because a neighbor "
"already has it", way->id);
return READOSM_OK;
}
@@ -737,9 +742,9 @@
}
if (layer) {
- saveInterestingWay((wayid_t)(way->id));
+ saveInterestingWay(way->id);
for (i = 0; i < way->node_ref_count; i++)
- saveInterestingNode((nodeid_t)way->node_refs[i]);
+ saveInterestingNode(way->node_refs[i]);
}
return READOSM_OK;
@@ -792,7 +797,7 @@
if ( layer == 0) {
wayid_t *wp;
- buildmap_debug("discarding way %d, not interesting (%s)", way->id, name);
+ buildmap_debug("discarding way %lld, not interesting (%s)", way->id, name);
wp = isWayInteresting(way->id);
if (wp) {
WayTableCopy[wp-WayTable] = 0;
@@ -889,7 +894,7 @@
int *lonsbuf, *latsbuf;
/* Street name */
- buildmap_debug ("Way %d [%s] ref [%s]", way->id,
+ buildmap_debug ("Way %lld [%s] ref [%s]", way->id,
name ? name : "", ref ? ref : "");
if (ref) {
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:48
|
Revision: 2961
http://sourceforge.net/p/roadmap/code/2961
Author: pgf
Date: 2015-10-20 15:06:46 +0000 (Tue, 20 Oct 2015)
Log Message:
-----------
buildmap_osm_layers.h: add landuse: conservation
Modified Paths:
--------------
trunk/roadmap/src/buildmap_osm_layers.h
Modified: trunk/roadmap/src/buildmap_osm_layers.h
===================================================================
--- trunk/roadmap/src/buildmap_osm_layers.h 2015-10-20 15:06:43 UTC (rev 2960)
+++ trunk/roadmap/src/buildmap_osm_layers.h 2015-10-20 15:06:46 UTC (rev 2961)
@@ -106,6 +106,7 @@
value_info_t landuse_to_layer[] = {
{ 0, NULL, 0 },
{ "reservoir", &Lakes, AREA },
+ { "conservation", &Nature, AREA },
{ 0, NULL, 0 },
};
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:45
|
Revision: 2960
http://sourceforge.net/p/roadmap/code/2960
Author: pgf
Date: 2015-10-20 15:06:43 +0000 (Tue, 20 Oct 2015)
Log Message:
-----------
buildmap_osm_main: switch back to using .osm.gz files
local patch to libreadosm allows this
Modified Paths:
--------------
trunk/roadmap/src/buildmap_osm_main.c
Modified: trunk/roadmap/src/buildmap_osm_main.c
===================================================================
--- trunk/roadmap/src/buildmap_osm_main.c 2015-10-20 15:06:40 UTC (rev 2959)
+++ trunk/roadmap/src/buildmap_osm_main.c 2015-10-20 15:06:43 UTC (rev 2960)
@@ -227,12 +227,12 @@
/* create all parents of our file */
parent = roadmap_path_parent(BuildMapResult,
- roadmap_osm_filename(0, 1, tileid, ".osm"));
+ roadmap_osm_filename(0, 1, tileid, ".osm.gz"));
roadmap_path_create(parent);
roadmap_path_free(parent);
xmlfile = roadmap_path_join(BuildMapResult,
- roadmap_osm_filename(0, 1, tileid, ".osm"));
+ roadmap_osm_filename(0, 1, tileid, ".osm.gz"));
snprintf(cmd, sizeof(cmd), "%s "
"--bits %d --bbox %s --xmlfile %s",
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:42
|
Revision: 2959
http://sourceforge.net/p/roadmap/code/2959
Author: pgf
Date: 2015-10-20 15:06:40 +0000 (Tue, 20 Oct 2015)
Log Message:
-----------
buildmap_osm_text.c: fix float to int conversions
libreadosm transports lat/lon values as float. OSM currently
gives 7 digits after the decimal. we express lat/lon as integral
millionths of degress. the new converter converts as accurately
as possible.
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:37 UTC (rev 2958)
+++ trunk/roadmap/src/buildmap_osm_text.c 2015-10-20 15:06:40 UTC (rev 2959)
@@ -569,6 +569,20 @@
}
/**
+ * @brief convert from 12.3456789 to 12345679. note the rounding.
+ */
+int
+osmfloat_to_rdmint(double f)
+{
+ int i;
+ i = 10000000. * f;
+ if (i < 0)
+ return (i-5)/10;
+ else
+ return (i+5)/10;
+}
+
+/**
* @brief callback for final node parsing, called via readosm_parse()
*/
static int
@@ -580,6 +594,7 @@
int point;
RoadMapString s;
int i;
+ int lat, lon;
if (!isNodeInteresting(node->id))
return READOSM_OK;
@@ -602,10 +617,11 @@
* 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)
- );
+ lat = osmfloat_to_rdmint(node->latitude);
+ lon = osmfloat_to_rdmint(node->longitude);
+
+ point = buildmap_point_add(lon, lat);
+
buildmap_osm_text_point_add(node->id, point);
/* If it's a place, add it to the place table as well */
@@ -616,9 +632,9 @@
s = str2dict (DictionaryCity, (char *)name);
p = buildmap_place_add(s, layer, point);
}
- buildmap_debug( "finishing %1.7f %1.7f %s (%d) %s layer: %d",
+ buildmap_debug( "finishing %1.7f %1.7f [%d %d] %s (%d) %s layer: %d",
node->latitude, node->longitude,
- place, p, name, layer);
+ lat, lon, place, p, name, layer);
} else {
buildmap_debug( "dropping %s %s", place, name);
}
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:39
|
Revision: 2958
http://sourceforge.net/p/roadmap/code/2958
Author: pgf
Date: 2015-10-20 15:06:37 +0000 (Tue, 20 Oct 2015)
Log Message:
-----------
buildmap_polygon: properly report no. of polygons saved
Modified Paths:
--------------
trunk/roadmap/src/buildmap_polygon.c
Modified: trunk/roadmap/src/buildmap_polygon.c
===================================================================
--- trunk/roadmap/src/buildmap_polygon.c 2015-10-20 15:06:34 UTC (rev 2957)
+++ trunk/roadmap/src/buildmap_polygon.c 2015-10-20 15:06:37 UTC (rev 2958)
@@ -902,7 +902,8 @@
buildmap_db *head_table;
buildmap_db *line_table;
- buildmap_info ("saving %d polygons...", PolygonLineCount);
+ buildmap_info ("saving %d polygons with %d lines...",
+ PolygonCount, PolygonLineCount);
/* Create the new-style "polygons" (note new name) tables,
* based on lines, instead of points).
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:36
|
Revision: 2957
http://sourceforge.net/p/roadmap/code/2957
Author: pgf
Date: 2015-10-20 15:06:34 +0000 (Tue, 20 Oct 2015)
Log Message:
-----------
roadmap_label: more debug support for labels
Modified Paths:
--------------
trunk/roadmap/src/roadmap_label.c
Modified: trunk/roadmap/src/roadmap_label.c
===================================================================
--- trunk/roadmap/src/roadmap_label.c 2015-10-20 15:06:30 UTC (rev 2956)
+++ trunk/roadmap/src/roadmap_label.c 2015-10-20 15:06:34 UTC (rev 2957)
@@ -78,8 +78,9 @@
#include "roadmap_list.h"
#include "roadmap_label.h"
-#define POLY_OUTLINE 0
-#define LABEL_USING_LINEID 0
+#define DRAW_LABEL_BBOX 0 // show where label should go
+#define LABEL_USING_LINEID 0 // add the line id to the label
+#define ALLOW_LABEL_OVERLAP 0 // don't suppress labels due to overlap
#define MIN(a, b) (a) < (b) ? (a) : (b)
#define MAX(a, b) (a) > (b) ? (a) : (b)
@@ -323,6 +324,9 @@
cPtr->notext = 0;
cPtr->text = NULL;
+#if LABEL_USING_LINEID
+ cPtr->otext = NULL;
+#endif
cPtr->bbox.minx = 1;
cPtr->bbox.maxx = -1;
@@ -575,7 +579,7 @@
}
angles = angles && can_tilt;
-#if POLY_OUTLINE
+#if DRAW_LABEL_BBOX
{
int lines = 4;
RoadMapPen pen = roadmap_canvas_select_pen (RoadMapLabelPen);
@@ -640,7 +644,8 @@
/* if bounding boxes don't overlap, we're clear */
- if (roadmap_math_rectangle_overlap (&ocPtr->bbox, &cPtr->bbox)) {
+ if (!ALLOW_LABEL_OVERLAP &&
+ roadmap_math_rectangle_overlap (&ocPtr->bbox, &cPtr->bbox)) {
/* if labels are horizontal, bbox check is sufficient */
if(!angles) {
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:33
|
Revision: 2956
http://sourceforge.net/p/roadmap/code/2956
Author: pgf
Date: 2015-10-20 15:06:30 +0000 (Tue, 20 Oct 2015)
Log Message:
-----------
roadmap_screen: only draw debug square outlines once
Modified Paths:
--------------
trunk/roadmap/src/roadmap_screen.c
Modified: trunk/roadmap/src/roadmap_screen.c
===================================================================
--- trunk/roadmap/src/roadmap_screen.c 2015-10-20 15:06:27 UTC (rev 2955)
+++ trunk/roadmap/src/roadmap_screen.c 2015-10-20 15:06:30 UTC (rev 2956)
@@ -1468,7 +1468,9 @@
}
/* draw individual square outline (only with "--square") */
- if (pen_type == 0 && roadmap_is_visible (ROADMAP_SHOW_SQUARE)) {
+ if (pen_type == 0 &&
+ which == LINES &&
+ roadmap_is_visible (ROADMAP_SHOW_SQUARE)) {
roadmap_screen_draw_square_edges (square);
}
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:30
|
Revision: 2955
http://sourceforge.net/p/roadmap/code/2955
Author: pgf
Date: 2015-10-20 15:06:27 +0000 (Tue, 20 Oct 2015)
Log Message:
-----------
buildmap_place: fix indexing bugs in layer table creation
Modified Paths:
--------------
trunk/roadmap/src/buildmap_place.c
Modified: trunk/roadmap/src/buildmap_place.c
===================================================================
--- trunk/roadmap/src/buildmap_place.c 2015-10-20 15:06:24 UTC (rev 2954)
+++ trunk/roadmap/src/buildmap_place.c 2015-10-20 15:06:27 UTC (rev 2955)
@@ -393,7 +393,7 @@
buildmap_db *layer_table;
- buildmap_info ("saving places...");
+ buildmap_info ("saving %d places...", PlaceCount);
square_count = buildmap_square_get_count();
@@ -420,12 +420,14 @@
return 1;
}
if (square_current >= 0) {
+ if (layer_current <= 0) {
+ buildmap_error (0, "empty square %d has places?", square);
+ return 1;
+ }
layer_count += (layer_current + 1);
}
square_current = square;
-
-
layer_current = 0; /* Restart from first layer. */
}
@@ -505,13 +507,13 @@
/* Complete the previous square. */
- db_layer[layer_sublist+square_current] = i;
+ db_layer[layer_sublist+layer_current] = i;
db_square[square_current].first = layer_sublist;
db_square[square_current].count = layer_current;
/* Move on to the next square. */
- layer_sublist += layer_current;
+ layer_sublist += (layer_current+1);
if (layer_sublist >= layer_count) {
buildmap_error (0, "invalid place/bylayer count (1)");
return 1;
@@ -534,25 +536,14 @@
if (square_current >= 0) {
-#ifdef BEFORE
- db_layer[layer_sublist+square_current] = i;
+ db_layer[layer_sublist+layer_current] = i;
db_square[square_current].first = layer_sublist;
db_square[square_current].count = layer_current;
- if (layer_sublist+square_current+1 != layer_count) {
+ if (layer_sublist+layer_current+1 != layer_count) {
buildmap_error (0, "invalid place/bylayer count (2)");
return 1;
}
-#else // pgf changed -- the conditions here now match those in the loop above
- db_layer[layer_sublist+square_current] = i + 1;
- db_square[square_current].first = layer_sublist;
- db_square[square_current].count = layer_current;
-
- if (layer_sublist+layer_current >= layer_count) {
- buildmap_error (0, "invalid place/bylayer count (2)");
- return 1;
- }
-#endif
}
return 0;
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:27
|
Revision: 2954
http://sourceforge.net/p/roadmap/code/2954
Author: pgf
Date: 2015-10-20 15:06:24 +0000 (Tue, 20 Oct 2015)
Log Message:
-----------
roadmap_line/place_in_square: code clarification
switch to zero-based layer indexing sooner rather than later, to
make it much more clear what's going on.
Modified Paths:
--------------
trunk/roadmap/src/roadmap_line.c
trunk/roadmap/src/roadmap_place.c
Modified: trunk/roadmap/src/roadmap_line.c
===================================================================
--- trunk/roadmap/src/roadmap_line.c 2015-10-20 15:06:21 UTC (rev 2953)
+++ trunk/roadmap/src/roadmap_line.c 2015-10-20 15:06:24 UTC (rev 2954)
@@ -306,14 +306,16 @@
layer = roadmap_locator_layer_to_db(layer);
- if (layer <= 0 || layer > RoadMapLineActive->LineBySquare1[square].count) {
+ layer--; // switch to zero-based layer indexing
+
+ if (layer < 0 || layer >= RoadMapLineActive->LineBySquare1[square].count) {
return 0;
}
index = RoadMapLineActive->LineByLayer1
+ RoadMapLineActive->LineBySquare1[square].first;
- *first = index[layer-1];
- *last = index[layer] - 1;
+ *first = index[layer];
+ *last = index[layer+1] - 1;
return (*first <= *last);
}
Modified: trunk/roadmap/src/roadmap_place.c
===================================================================
--- trunk/roadmap/src/roadmap_place.c 2015-10-20 15:06:21 UTC (rev 2953)
+++ trunk/roadmap/src/roadmap_place.c 2015-10-20 15:06:24 UTC (rev 2954)
@@ -214,15 +214,17 @@
layer = roadmap_locator_layer_to_db(layer);
- if (layer <= 0 || layer > RoadMapPlaceActive->PlaceBySquare[square].count) {
+ layer--; // switch to zero-based layer indexing
+
+ if (layer < 0 || layer >= RoadMapPlaceActive->PlaceBySquare[square].count) {
return 0;
}
index = RoadMapPlaceActive->PlaceByLayer
+ RoadMapPlaceActive->PlaceBySquare[square].first;
- *first = index[layer-1];
- *last = index[layer] - 1;
+ *first = index[layer];
+ *last = index[layer+1] - 1;
return (*first <= *last);
}
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:24
|
Revision: 2953
http://sourceforge.net/p/roadmap/code/2953
Author: pgf
Date: 2015-10-20 15:06:21 +0000 (Tue, 20 Oct 2015)
Log Message:
-----------
dumpmap: add ability to dump raw children (with -d -v)
Modified Paths:
--------------
trunk/roadmap/src/dumpmap_main.c
Modified: trunk/roadmap/src/dumpmap_main.c
===================================================================
--- trunk/roadmap/src/dumpmap_main.c 2015-10-20 15:06:18 UTC (rev 2952)
+++ trunk/roadmap/src/dumpmap_main.c 2015-10-20 15:06:21 UTC (rev 2953)
@@ -50,6 +50,7 @@
static char *DumpMapShowVolume = "";
static char *DumpMapSearchStringOption = "";
+static void show_data(const char *data, int size);
/**
* Tree print module
@@ -83,6 +84,7 @@
int count;
int level;
roadmap_db *child;
+ char *data;
level = 2 * (roadmap_db_get_level (parent) - roadmap_db_get_level (root));
@@ -110,6 +112,11 @@
dumpmap_show_size (size);
fprintf(out, ")\n");
+ if (DumpMapVerbose) {
+ data = roadmap_db_get_data (child);
+ show_data(data, size);
+ fprintf(out, "\n");
+ }
}
}
}
@@ -379,15 +386,8 @@
* then it forgets about the database.
*/
-static void *dumpmap_hexadump_map (roadmap_db *root) {
-
+static void show_data(const char *data, int size) {
int i, j;
- int size;
- const char *data;
-
- size = roadmap_db_get_size (root);
- data = roadmap_db_get_data (root);
-
for (i = 0; i <= size - 16; i += 16) {
int j;
@@ -419,7 +419,18 @@
}
fprintf(out, "\n");
}
+}
+static void *dumpmap_hexadump_map (roadmap_db *root) {
+
+ int size;
+ const char *data;
+
+ size = roadmap_db_get_size (root);
+ data = roadmap_db_get_data (root);
+
+ show_data(data, size);
+
return "OK";
}
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:21
|
Revision: 2952
http://sourceforge.net/p/roadmap/code/2952
Author: pgf
Date: 2015-10-20 15:06:18 +0000 (Tue, 20 Oct 2015)
Log Message:
-----------
buildmap_line: remove redundant assignment
Modified Paths:
--------------
trunk/roadmap/src/buildmap_line.c
Modified: trunk/roadmap/src/buildmap_line.c
===================================================================
--- trunk/roadmap/src/buildmap_line.c 2015-10-20 15:06:15 UTC (rev 2951)
+++ trunk/roadmap/src/buildmap_line.c 2015-10-20 15:06:18 UTC (rev 2952)
@@ -607,7 +607,6 @@
j = SortedLine[i];
one_line = Line[j/BUILDMAP_BLOCK] + (j % BUILDMAP_BLOCK);
one_line->sorted = i;
- one_line->sorted = i;
}
SortedLine2 = malloc (LineCrossingCount * sizeof(int));
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:18
|
Revision: 2951
http://sourceforge.net/p/roadmap/code/2951
Author: pgf
Date: 2015-10-20 15:06:15 +0000 (Tue, 20 Oct 2015)
Log Message:
-----------
dumpmap: add character representaion to table dumps
Modified Paths:
--------------
trunk/roadmap/src/dumpmap_main.c
Modified: trunk/roadmap/src/dumpmap_main.c
===================================================================
--- trunk/roadmap/src/dumpmap_main.c 2015-10-20 15:06:12 UTC (rev 2950)
+++ trunk/roadmap/src/dumpmap_main.c 2015-10-20 15:06:15 UTC (rev 2951)
@@ -28,6 +28,7 @@
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
+#include <ctype.h>
#include "roadmap.h"
#include "roadmap_dbread.h"
@@ -380,7 +381,7 @@
static void *dumpmap_hexadump_map (roadmap_db *root) {
- int i;
+ int i, j;
int size;
const char *data;
@@ -396,14 +397,26 @@
for (j = 0; j < 16; ++j) {
fprintf(out, " %02x", 0xff & ((int)data[i+j]));
}
+ fprintf(out, " ");
+ for (j = 0; j < 16; ++j) {
+ int c = 0xff & ((int)data[i+j]);
+ fprintf(out, "%c", isprint(c) ? c : '.');
+ }
fprintf(out, "\n");
}
if (i < size) {
fprintf(out, "%08d ", i);
- for (; i < size; ++i) {
- fprintf(out, " %02x", 0xff & ((int)data[i]));
+ j = i;
+ for (; j < size; ++j) {
+ fprintf(out, " %02x", 0xff & ((int)data[j]));
}
+ fprintf(out, " ");
+ j = i;
+ for (; j < size; ++j) {
+ int c = 0xff & ((int)data[j]);
+ fprintf(out, "%c", isprint(c) ? c : '.');
+ }
fprintf(out, "\n");
}
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:15
|
Revision: 2950
http://sourceforge.net/p/roadmap/code/2950
Author: pgf
Date: 2015-10-20 15:06:12 +0000 (Tue, 20 Oct 2015)
Log Message:
-----------
roadmap_hash.c: clear statistics counters when initializing a hash
Modified Paths:
--------------
trunk/roadmap/src/roadmap_hash.c
Modified: trunk/roadmap/src/roadmap_hash.c
===================================================================
--- trunk/roadmap/src/roadmap_hash.c 2015-10-20 15:06:09 UTC (rev 2949)
+++ trunk/roadmap/src/roadmap_hash.c 2015-10-20 15:06:12 UTC (rev 2950)
@@ -71,6 +71,10 @@
hash->size = size;
hash->next = malloc (size * sizeof(int));
hash->values = NULL;
+ hash->count_add_first = 0;
+ hash->count_add_next = 0;
+ hash->count_get_first = 0;
+ hash->count_get_next = 0;
roadmap_check_allocated(hash->next);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|