return osm_tag_value(ib, "name");
}
+osmid
+boundary_relid(struct boundary *b)
+{
+ long long *id;
+ if (!b)
+ return 0;
+ if (!b->ib)
+ return 0;
+ id=item_bin_get_attr(b->ib, attr_osm_relationid, NULL);
+ if (id)
+ return *id;
+ return 0;
+}
static void
process_boundaries_member(void *func_priv, void *relation_priv, struct item_bin *member, void *member_priv)
{
struct country_table *country=country_from_iso2(iso);
if (!country)
osm_warning("relation",item_bin_get_relationid(ib),0,"Country Boundary contains unknown ISO3166-1 value '%s'\n",iso);
+ else
+ osm_info("relation",item_bin_get_relationid(ib),0,"Country Boundary for '%s'\n",iso);
boundary->country=country;
} else
osm_warning("relation",item_bin_get_relationid(ib),0,"Country Boundary doesn't contain an ISO3166-1 tag\n");
fprintf(stderr,"%shttp://www.openstreetmap.org/browse/%s/"LONGLONG_FMT" %s",cont ? "":"OSM Warning:",type,id,str);
}
+void
+osm_info(char *type, long long id, int cont, char *fmt, ...)
+{
+ char str[4096];
+ va_list ap;
+ va_start(ap, fmt);
+ vsnprintf(str, sizeof(str), fmt, ap);
+ va_end(ap);
+ fprintf(stderr,"%shttp://www.openstreetmap.org/browse/%s/"LONGLONG_FMT" %s",cont ? "":"OSM Info:",type,id,str);
+}
+
static void
attr_strings_clear(void)
{
item_bin=init_item(item_bin->type);
item_bin_add_coord(item_bin, &ni->c, 1);
item_bin_add_attr_string(item_bin, attr_osm_is_in, is_in_buffer);
+ item_bin_add_attr_longlong(item_bin, attr_osm_nodeid, osmid_attr_value);
item_bin_add_attr_string(item_bin, attr_town_postal, postal);
item_bin_add_attr_string(item_bin, attr_county_name, attr_strings[attr_string_county_name]);
item_bin_add_attr_string(item_bin, attr_town_name, attr_strings[attr_string_label]);
}
static struct country_table *
-osm_process_town_by_is_in(char *is_in)
+osm_process_town_by_is_in(struct item_bin *ib,char *is_in)
{
struct country_table *result=NULL, *lookup;
char *tok,*dup=g_strdup(is_in),*buf=dup;
lookup=g_hash_table_lookup(country_table_hash,tok);
if (lookup) {
if (result && result->countryid != lookup->countryid) {
- osm_warning("node",nodeid,0,"conflict for %s %s country %d vs %d\n", attr_strings[attr_string_label], debug_attr_buffer, lookup->countryid, result->countryid);
+ osm_warning("node",item_bin_get_nodeid(ib),0,"conflict for %s %s country %d vs %d\n", attr_strings[attr_string_label], debug_attr_buffer, lookup->countryid, result->countryid);
conflict=1;
}
result=lookup;
}
static struct country_table *
-osm_process_town_by_boundary(GList *bl, struct coord *c)
+osm_process_town_by_boundary(GList *bl, struct item_bin *ib, struct coord *c)
{
GList *l,*matches=boundary_find_matches(bl, c);
- struct country_table *match=NULL;
+ struct boundary *match=NULL;
l=matches;
while (l) {
struct boundary *b=l->data;
if (b->country) {
- if (match)
- printf("conflict %d vs %d\n",b->country->countryid,match->countryid);
- match=b->country;
+ if (match) {
+ osm_warning("node",item_bin_get_nodeid(ib),0,"node (0x%x,0x%x) country ", c->x, c->y);
+ osm_warning("relation",boundary_relid(match),1,"country %d vs ",match->country->countryid);
+ osm_warning("relation",boundary_relid(b),1,"country %d\n",b->country->countryid);
+ }
+ match=b;
}
l=g_list_next(l);
}
- return match;
+ if (match)
+ return match->country;
+ else
+ return NULL;
}
void
struct country_table *result=NULL;
char *is_in=item_bin_get_attr(ib, attr_osm_is_in, NULL);
if (experimental)
- result=osm_process_town_by_boundary(bl, c);
+ result=osm_process_town_by_boundary(bl, ib, c);
if (!result)
- result=osm_process_town_by_is_in(is_in);
+ result=osm_process_town_by_is_in(ib, is_in);
if (!result && unknown_country)
result=osm_process_town_unknown_country();
if (result) {
g_free(name);
}
if (result->file) {
+ long long *nodeid;
if (is_in)
item_bin_remove_attr(ib, is_in);
+ nodeid=item_bin_get_attr(ib, attr_osm_nodeid, NULL);
+ if (nodeid)
+ item_bin_remove_attr(ib, nodeid);
item_bin_write_match(ib, attr_town_name, attr_town_name_match, result->file);
}
}