if (sqlite3_prepare_v2(db, "select w.wid,w.type,w.flags,w.speed,n.nid,n.rlat,n.rlon,nn.f,nn.t,n.f,n.l "
"from way as w, nodes as n, way_n2n as nn where w.wid=nn.wid and nn.f=n.nid and nn.t=?",
- -1, &sql.select_node_next, NULL)!=SQLITE_OK)
+ -1, &sql.select_node_prev, NULL)!=SQLITE_OK)
return FALSE;
return TRUE;
n->lat=sqlite3_column_int(sql.select_place, 2);
n->lon=sqlite3_column_int(sql.select_place, 3);
n->type=sqlite3_column_int(sql.select_place, 4);
- n->isin=sqlite3_column_int(sql.select_place, 5);
+ n->isin_p=sqlite3_column_int(sql.select_place, 5);
+/* n->isin_c=sqlite3_column_int(sql.select_place, 6); */
return TRUE;
}
return FALSE;
}
n=osm_place_new();
-n->isin=n->lat=n->lon=n->dist=0;
+n->isin_p=n->lat=n->lon=n->dist=0;
if (SQLITE_ROW == sqlite3_step(sql.select_near_place)) {
const gchar *place;
guint32 dist;
n->lat=sqlite3_column_int(sql.select_near_place, 2);
n->lon=sqlite3_column_int(sql.select_near_place, 3);
n->id=sqlite3_column_int(sql.select_near_place, 4);
- n->isin=sqlite3_column_int(sql.select_near_place, 5);
+ n->isin_p=sqlite3_column_int(sql.select_near_place, 5);
+/* n->isin_c=sqlite3_column_int(sql.select_near_place, 6); */
n->type=type;
osm_place_cache_add(n);
/*****************************************************************************/
+GSList *
+osm_get_route_node(guint nid, osm_node_direction d)
+{
+GSList *r=NULL;
+osm_way *w;
+guint wc=0;
+sqlite3_stmt *psql;
+
+switch (d) {
+ case OSM_NODE_NEXT:
+ psql=sql.select_node_next;
+ break;
+ case OSM_NODE_PREV:
+ psql=sql.select_node_prev;
+ break;
+ default:
+ g_assert_not_reached();
+ break;
+}
+
+sqlite3_reset(psql);
+sqlite3_clear_bindings(psql);
+
+if (SQLITE_OK != sqlite3_bind_int(psql, 1, nid)) {
+ g_printerr("Failed to bind values for route node\n");
+ return NULL;
+}
+
+while (SQLITE_ROW == sqlite3_step(psql)) {
+ gdouble lat, lon;
+
+ wc++;
+ w=g_slice_new0(osm_way);
+ w->id=sqlite3_column_int(psql, 0);
+ w->type=sqlite3_column_int(psql, 1);
+ w->flags=sqlite3_column_int(psql, 2);
+ w->speed=sqlite3_column_int(psql, 3);
+
+ lat=sqlite3_column_double(psql, 5);
+ lon=sqlite3_column_double(psql, 6);
+
+ w->f=sqlite3_column_int(psql, 7);
+ w->t=sqlite3_column_int(psql, 8);
+#if 0
+ w->node=
+ w->node->flags=sqlite3_column_int(psql, 9);
+ w->node->links=sqlite3_column_int(psql, 10);
+#endif
+
+ r=g_slist_prepend(r, w);
+}
+
+return r;
+}
+
+
+/*****************************************************************************/
gboolean
osm_way_distance(gint lat, gint lon, osm_way_node *f, osm_way_node *t, gdouble *d)
{
gboolean fs;
fs=osm_find_nearest_place(NODE_PLACE_SUBURB, lat, lon, &map_loc->secondary);
- if (fs==TRUE && map_loc->secondary && map_loc->secondary->isin!=0) {
- if (osm_place_get(map_loc->secondary->isin, lat, lon, &(map_loc->primary))==FALSE) {
+ if (fs==TRUE && map_loc->secondary && map_loc->secondary->isin_p!=0) {
+ if (osm_place_get(map_loc->secondary->isin_p, lat, lon, &(map_loc->primary))==FALSE) {
if (osm_find_nearest_place(NODE_PLACE_CITY, lat, lon, &map_loc->primary)==TRUE)
g_printf("Near city: %s\n", map_loc->primary->name);
else if (osm_find_nearest_place(NODE_PLACE_TOWN, lat, lon, &map_loc->primary)==TRUE)
} else {
g_printf("In: %s\n", map_loc->primary ? map_loc->primary->name : "?");
}
- } else if (map_loc->street && map_loc->street->isin!=0) {
- if (osm_place_get(map_loc->street->isin, lat, lon, &map_loc->primary)==FALSE) {
+ } else if (map_loc->street && map_loc->street->isin_p!=0) {
+ if (osm_place_get(map_loc->street->isin_p, lat, lon, &map_loc->primary)==FALSE) {
g_printf("Street location not know.\n");
} else {
g_printf("Street is in: %s\n", map_loc->primary ? map_loc->primary->name : "?");