return;
if (n->data!=NULL)
return;
-n->data=g_slice_new(node_data);
-n->data->name=NULL;
-n->data->url=NULL;
-n->data->desc=NULL;
-n->data->postal_code=NULL;
+n->data=g_slice_new0(node_data);
n->type=NODE_PLAIN;
noded_cnt++;
}
{
node *n=NULL;
-n=g_slice_new(node);
+n=g_slice_new0(node);
g_assert(n);
n->id=id;
n->lat=lat;
n->lon=lon;
-n->data=(node_data *)NULL;
return n;
}
if (w->data!=NULL)
return;
-w->data=g_slice_new(way_data);
-w->data->name=NULL;
-w->data->names=NULL;
-w->data->ref=NULL;
-w->data->int_ref=NULL;
-w->data->postal_code=NULL;
-w->data->layer=0;
-w->data->speed=0;
+w->data=g_slice_new0(way_data);
}
static void
{
way *w;
-w=g_slice_new(way);
+w=g_slice_new0(way);
g_assert(w);
w->id=id;
-w->nodes=NULL;
w->type=WAY_UNWAYED;
-w->data=NULL;
-w->ncnt=0;
-w->flags=0;
/* Add to list of ways */
return w;
}
}
+#define GET_NODE_KEY(key, nfield) { \
+ gchar *_kv; \
+ _kv=g_hash_table_lookup(osm_node_tags, key); \
+ if (_kv) { \
+ if (!nfield) { \
+ nfield=g_strstrip(g_utf8_normalize(_kv, -1, G_NORMALIZE_ALL_COMPOSE)); \
+ } else { \
+ gchar *_tmp=nfield; \
+ gchar *_norm=g_utf8_normalize(_kv, -1, G_NORMALIZE_ALL_COMPOSE); \
+ nfield=g_strdup_printf("%s %s", _tmp, g_strstrip(_norm)); \
+ g_free(_tmp); \
+ g_free(_norm); \
+ } \
+ } \
+}
+
+
static void
_osm_tag_end(void *userData, const char *name)
{
* - Places (for is_in)
* - ...
*/
- if ((osm_node_check_box(cnode->lat, cnode->lon)==FALSE) &&
- (cnode->type<NODE_PLACE_START)) {
+ if ((osm_node_check_box(cnode->lat, cnode->lon)==FALSE) && (cnode->type<NODE_PLACE_START)) {
osm_free_node_data(cnode);
osm_free_node(cnode);
g_hash_table_destroy(osm_node_tags);
v=g_hash_table_lookup(osm_node_tags, "name");
if (v)
cnode->data->name=g_strstrip(g_utf8_normalize(v, -1, G_NORMALIZE_ALL_COMPOSE));
- v=g_hash_table_lookup(osm_node_tags, "note");
- if (v)
- cnode->data->desc=g_strstrip(g_strdup(v));
- v=g_hash_table_lookup(osm_node_tags, "postal_code");
- if (v)
- cnode->data->postal_code=g_strstrip(g_strdup(v));
+
+ GET_NODE_KEY("description", cnode->data->desc);
+ GET_NODE_KEY("note", cnode->data->desc);
+ GET_NODE_KEY("postal_code", cnode->data->postal_code);
+ GET_NODE_KEY("address", cnode->data->desc);
/* Links */
v=g_hash_table_lookup(osm_node_tags, "url");