Permalink
Browse files

*** empty log message ***

  • Loading branch information...
1 parent 86ff47d commit 90b2070b982fd4abf353b7c53fc6be7c031497f5 @drolbr committed Apr 2, 2009
Showing with 29 additions and 16 deletions.
  1. +6 −5 file_types.h
  2. +22 −10 import_osm_nw.c
  3. +1 −1 konzept_vereinfachte_db.txt
View
@@ -1479,7 +1479,7 @@ struct Indexed_Ordered_Id_To_Many_Writer : Indexed_Ordered_Id_To_Many_Base< Stor
bool to_buf(uint8* buf, const Iterator& it)
{
- Storage::head_to_buf(buf, it->head);
+ Storage::head_to_buf(&(buf[0]), it->head);
uint pos(Storage::size_of_Head() + 1);
if (remaining_size == 0)
{
@@ -1492,7 +1492,7 @@ struct Indexed_Ordered_Id_To_Many_Writer : Indexed_Ordered_Id_To_Many_Base< Stor
uint i(0);
while (i < upper_limit)
{
- Storage::data_to_buf(buf, *dit);
+ Storage::data_to_buf(&(buf[pos]), *dit);
++dit;
pos += Storage::size_of_Data();
++i;
@@ -1503,6 +1503,7 @@ struct Indexed_Ordered_Id_To_Many_Writer : Indexed_Ordered_Id_To_Many_Base< Stor
return (remaining_size == 0);
}
+ typename Storage::Id id_of_buf(uint8* buf) const { return Storage::id_of_buf(buf); }
void index_to_buf(uint8* buf, const typename Storage::Index& i) const { Storage::index_to_buf(buf, i); }
private:
@@ -1627,7 +1628,7 @@ struct Indexed_Ordered_Id_To_Many_Updater : Indexed_Ordered_Id_To_Many_Base< Sto
if (it.current_it == 1)
return true;
- Storage::head_to_buf(buf, (*it).head);
+ Storage::head_to_buf(&(buf[0]), (*it).head);
uint pos(Storage::size_of_Head() + 1);
if (remaining_size == 0)
{
@@ -1640,7 +1641,7 @@ struct Indexed_Ordered_Id_To_Many_Updater : Indexed_Ordered_Id_To_Many_Base< Sto
uint i(0);
while (i < upper_limit)
{
- Storage::data_to_buf(buf, *dit);
+ Storage::data_to_buf(&(buf[pos]), *dit);
++dit;
pos += Storage::size_of_Data();
++i;
@@ -1655,7 +1656,7 @@ struct Indexed_Ordered_Id_To_Many_Updater : Indexed_Ordered_Id_To_Many_Base< Sto
uint8 keep_this_elem(uint8* buf)
{
typename Storage::Head h;
- Storage::head_from_buf(buf, h);
+ Storage::head_from_buf(&(buf[0]), h);
typename Container::const_iterator it(to_delete_.find(typename Storage::Basetype(h)));
if (it == to_delete_.end())
return 1;
View
@@ -446,8 +446,11 @@ void postprocess_ways_4()
close(ways_dat_fd);
}
-void localise_and_flush_ways(vector< Way_ >& ways)
+void localise_and_flush_ways
+ (vector< Way_ >& ways,
+ Indexed_Ordered_Id_To_Many_Writer< Way_Storage, vector< Way_ > >& writer)
{
+ //query used nodes
set< Node > used_nodes;
set< int32 > used_nodes_ids;
for (vector< Way_ >::const_iterator it(ways.begin()); it != ways.end(); ++it)
@@ -460,6 +463,7 @@ void localise_and_flush_ways(vector< Way_ >& ways)
select_by_id< Node_Id_Node_By_Id_Reader >(nodes_reader);
used_nodes_ids.clear();
+ //calculate for each ways its index
for (vector< Way_ >::iterator it(ways.begin()); it != ways.end(); ++it)
{
Way_::Index bitmask(0), position(0);
@@ -479,19 +483,17 @@ void localise_and_flush_ways(vector< Way_ >& ways)
bitmask |= (position ^ ll_idx(node_it->lat, node_it->lon));
}
- //TEMP
- cout<<bitmask<<'\t'<<hex<<position<<'\n';
-
while (bitmask)
{
bitmask = bitmask>>8;
position = (position>>8) | 0xff000000;
}
(*it).head.first = position;
-
- //TEMP
- cout<<dec<<(*it).head.second<<'\t'<<hex<<(*it).head.first<<'\n';
}
+
+ //write ways to file
+ sort(ways.begin(), ways.end());
+ flush_data(writer, ways.begin(), ways.end());
}
//-----------------------------------------------------------------------------
@@ -522,6 +524,7 @@ uint32* block_of_id;
vector< Way_ > ways_;
Way_ current_way(0, 0);
+Indexed_Ordered_Id_To_Many_Writer< Way_Storage, vector< Way_ > > ways_writer(ways_);
void start(const char *el, const char **attr)
{
@@ -670,14 +673,17 @@ void end(const char *el)
}
else if (!strcmp(el, "way"))
{
+ //TEMP
+ cout<<current_way.data.size()<<'\t'<<current_way.head.second<<'\n';
+
ways_.push_back(current_way);
current_way.data.clear();
- if (structure_count > 65536)
+ if (structure_count > 32*1024*1024)
{
- localise_and_flush_ways(ways_);
+ localise_and_flush_ways(ways_, ways_writer);
ways_.clear();
- exit(0);
+ structure_count = 0;
}
/* if (way_buf_pos < MAXWAYNODES)
@@ -742,6 +748,12 @@ int main(int argc, char *argv[])
{
//reading the main document
parse(stdin, start, end);
+
+ //TEMP
+ localise_and_flush_ways(ways_, ways_writer);
+ ways_.clear();
+ make_block_index(ways_writer);
+ make_id_index(ways_writer);
}
catch(File_Error e)
{
@@ -95,4 +95,4 @@ count_with_idx
zu den Wegen:
- füge die Wege einschließlich Knoten in eine Map< Way_ > ein
- erzeuge daraus die Node-Anfrage
-- leite aus dem Ergebnis die richtigen Ids für die Ways ab
+- leite aus dem Ergebnis die richtigen Indexe für die Ways ab

0 comments on commit 90b2070

Please sign in to comment.