/** * store the interim StringTable to the current pbf_primitive_block, map all interim string ids * to real StringTable ids and then store the current pbf_primitive_block into a Blob and clear * this struct and all related pointers and maps afterwards. */ void store_primitive_block() { if (Osmium::debug()) { std::cerr << "storing primitive block with " << primitive_block_contents << " items" << std::endl; } // store the interim StringTable into the protobuf object string_table.store_stringtable(pbf_primitive_block.mutable_stringtable()); // map all interim string ids to real ids map_string_ids(); // store the Blob store_blob("OSMData", pbf_primitive_block); // clear the PrimitiveBlock struct pbf_primitive_block.Clear(); // add empty StringTable entry at index 0 // StringTable index 0 is rserved as delimiter in the densenodes key/value list // this line also ensures that there's always a valid StringTable pbf_primitive_block.mutable_stringtable()->add_s(""); // set the granularity pbf_primitive_block.set_granularity(location_granularity()); pbf_primitive_block.set_date_granularity(date_granularity()); // clear the interim StringTable and its id map string_table.clear(); // reset the delta variables m_delta_id.clear(); m_delta_lat.clear(); m_delta_lon.clear(); m_delta_timestamp.clear(); m_delta_changeset.clear(); m_delta_uid.clear(); m_delta_user_sid.clear(); // reset the contents-counter to zero primitive_block_contents = 0; // reset the node/way/relation pointers to NULL pbf_nodes = NULL; pbf_ways = NULL; pbf_relations = NULL; }
/** * store the interim StringTable to the current pbf_primitive_block, map all interim string ids * to real StringTable ids and then store the current pbf_primitive_block into a Blob and clear * this struct and all related pointers and maps afterwards. */ void store_primitive_block() { if (debug && has_debug_level(1)) { std::cerr << "storing primitive block with " << primitive_block_contents << " items" << std::endl; } // set the granularity pbf_primitive_block.set_granularity(location_granularity()); pbf_primitive_block.set_date_granularity(date_granularity()); // store the interim StringTable into the protobuf object string_table.store_stringtable(pbf_primitive_block.mutable_stringtable()); // map all interim string ids to real ids map_string_ids(); // store the Blob store_blob("OSMData", pbf_primitive_block); // clear the PrimitiveBlock struct pbf_primitive_block.Clear(); // clear the interim StringTable and its id map string_table.clear(); // reset the delta variables m_delta_id.clear(); m_delta_lat.clear(); m_delta_lon.clear(); m_delta_timestamp.clear(); m_delta_changeset.clear(); m_delta_uid.clear(); m_delta_user_sid.clear(); // reset the contents-counter to zero primitive_block_contents = 0; primitive_block_size = 0; // reset the node/way/relation pointers to NULL pbf_nodes = NULL; pbf_ways = NULL; pbf_relations = NULL; }
/** * convert a double lat or lon value to an int, respecting the current blocks granularity */ int64_t lonlat2int(double lonlat) { return round(lonlat * OSMPBF::lonlat_resolution / location_granularity()); }