Skip to content

Commit

Permalink
Fix C based tagtransform for non-hstore mode
Browse files Browse the repository at this point in the history
Reported in github issue osm2pgsql-dev#35

The previous fix b80cb3e did not fully fix everything.
(hopefully this time it will)

There are still some differences (with respect to tag copying from member ways of
multipolygon relations) to the original code, but they should all be either improvements,
or the correct behaviour is ambivalent.
  • Loading branch information
apmon committed Jun 1, 2013
1 parent 2eb0dcc commit 02d6ac6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion output-pgsql.c
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ static int pgsql_out_relation(osmid_t id, struct keyval *rel_tags, int member_co
free(members_superseeded);
return 0;
}

/* Split long linear ways after around 1 degree or 100km (polygons not effected) */
if (Options->projection == PROJ_LATLONG)
split_at = 1;
Expand Down
26 changes: 16 additions & 10 deletions tagtransform.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,21 +170,22 @@ static unsigned int tagtransform_c_filter_basic_tags(enum OsmType type,
int i, filter = 1;
int flags = 0;
int add_area_tag = 0;
enum OsmType export_type;

const char *area;
struct keyval *item;
struct keyval temp;
initList(&temp);

if (type == OSMTYPE_RELATION) {export_type = OSMTYPE_WAY;} else {export_type = type;}

/* We used to only go far enough to determine if it's a polygon or not, but now we go through and filter stuff we don't need */
if (type == OSMTYPE_RELATION) {
filter = 0;
}
while ((item = popItem(tags)) != NULL ) {
if (type == OSMTYPE_RELATION && !strcmp("type", item->key)) {
pushItem(&temp, item);
item = NULL;
break;
filter = 0;
continue;
}
/* Allow named islands to appear as polygons */
if (!strcmp("natural", item->key)
Expand All @@ -200,16 +201,16 @@ static unsigned int tagtransform_c_filter_basic_tags(enum OsmType type,
continue;
}

for (i = 0; i < exportListCount[type]; i++) {
if (wildMatch(exportList[type][i].name, item->key)) {
if (exportList[type][i].flags & FLAG_DELETE) {
for (i = 0; i < exportListCount[export_type]; i++) {
if (wildMatch(exportList[export_type][i].name, item->key)) {
if (exportList[export_type][i].flags & FLAG_DELETE) {
freeItem(item);
item = NULL;
break;
}

filter = 0;
flags |= exportList[type][i].flags;
flags |= exportList[export_type][i].flags;

pushItem(&temp, item);
item = NULL;
Expand All @@ -218,7 +219,7 @@ static unsigned int tagtransform_c_filter_basic_tags(enum OsmType type,
}

/** if tag not found in list of exports: */
if (i == exportListCount[type]) {
if (i == exportListCount[export_type]) {
if (options->enable_hstore) {
/* with hstore, copy all tags... */
pushItem(&temp, item);
Expand Down Expand Up @@ -347,7 +348,6 @@ static unsigned int tagtransform_lua_filter_rel_member_tags(struct keyval *rel_t

*roads = lua_tointeger(L, -1);
lua_pop(L,1);
printf("roads: %i\n", *roads);
*make_polygon = lua_tointeger(L, -1);
lua_pop(L,1);
*make_boundary = lua_tointeger(L,-1);
Expand Down Expand Up @@ -561,6 +561,12 @@ static unsigned int tagtransform_c_filter_rel_member_tags(
return 1;
}

if (!listHasData(&tags)) {
resetList(&tags);
resetList(&poly_tags);
return 1;
}

/* If we are creating a multipolygon then we
mark each member so that we can skip them during iterate_ways
but only if the polygon-tags look the same as the outer ring */
Expand Down

0 comments on commit 02d6ac6

Please sign in to comment.