Ejemplo n.º 1
0
            /**
             * a helper function used in map_string_ids to map common interim string-ids of the
             * user name and all tags to real string ids.
             *
             * pbf_object_t is either OSMPBF::Node, OSMPBF::Way or OSMPBF::Relation.
             */
            template <class pbf_object_t> void map_common_string_ids(pbf_object_t* in) {
                // if the object has meta-info attached
                if (in->has_info()) {
                    // map the interim-id of the user name to a real id
                    OSMPBF::Info* info = in->mutable_info();
                    info->set_user_sid(string_table.map_string_id(info->user_sid()));
                }

                // iterate over all tags and map the interim-ids of the key and the value to real ids
                for (int i=0, l=in->keys_size(); i<l; i++) {
                    in->set_keys(i, string_table.map_string_id(in->keys(i)));
                    in->set_vals(i, string_table.map_string_id(in->vals(i)));
                }
            }
Ejemplo n.º 2
0
void
QcOsmPbfReader::read_relations(OSMPBF::PrimitiveGroup primitive_group)
{
  enter_relation_transactions();

  int number_of_relations = primitive_group.relations_size();
  for (int i = 0; i < number_of_relations; i++) {
    OSMPBF::Relation relation = primitive_group.relations(i);
    int64_t relation_id = relation.id();

    QVector<int32_t> roles_sid(relation.roles_sid_size());
    QVector<int64_t> member_ids(roles_sid.size());
    QVector<OSMPBF::Relation::MemberType> types(roles_sid.size());
    // QStringList roles;
    DeltaCodedInt64 member_id;
    for (int i = 0, l = relation.roles_sid_size(); i < l; i++) {
      int32_t role_sid = relation.roles_sid(i);
      roles_sid[i] = role_sid;
      member_ids[i] = member_id.update(relation.memids(i));
      types[i] = relation.types(i);
      // roles << m_string_table[role_sid];
    }

    // qDebug().nospace() << "relation" << i << relation_id << roles_sid << roles << member_ids << types;

    int number_of_attributes = relation.keys_size();
    QVector<KeyValPair> attributes(number_of_attributes);
    for (int i = 0; i < number_of_attributes; i++) {
      int32_t key_id = relation.keys(i);
      int32_t val_id = relation.vals(i);
      // qDebug() << "  key_val" << relation_id << m_string_table[key_id] << m_string_table[val_id];
      attributes[i] = KeyValPair(key_id, val_id);
    }

    yield_relation(relation_id, roles_sid, member_ids, types, attributes);

    if (m_read_metadatas and relation.has_info()) {
      // qDebug().nospace() << "        with meta-info";
      OSMPBF::Info info = relation.info();
      int32_t version = info.version();
      int64_t timestamp = to_timestamp(info.timestamp());
      int64_t changeset = info.changeset();
      int32_t uid = info.uid();
      int32_t user_sid = info.user_sid();
      // bool visible = info.visible();
      // qDebug() << "Meta information:" << version << timestamp << changeset << uid << user_sid;
      // yield_relation_metadata(way_id, version, timestamp, changeset, uid, user_sid);
    }
  }

  leave_relation_transactions();
}
Ejemplo n.º 3
0
void
QcOsmPbfReader::read_ways(OSMPBF::PrimitiveGroup primitive_group)
{
  enter_way_transactions();

  int number_of_ways = primitive_group.ways_size();
  for (int i = 0; i < number_of_ways; i++) {
    OSMPBF::Way way = primitive_group.ways(i);
    int64_t way_id = way.id();

    QVector<int64_t> node_ids(way.refs_size());
    int j = 0;
    DeltaCodedInt64 node_id;
    for (auto ref : way.refs()) {
      node_ids[j++] = node_id.update(ref);
    }

    // qDebug().nospace() << "way" << i << way_id << node_ids;

    int number_of_attributes = way.keys_size();
    QVector<KeyValPair> attributes(number_of_attributes);
    for (int i = 0; i < number_of_attributes; i++) {
      int32_t key_id = way.keys(i);
      int32_t val_id = way.vals(i);
      // qDebug() << "  key_val" << way_id << m_string_table[key_id] << m_string_table[val_id];
      attributes[i] = KeyValPair(key_id, val_id);
    }

    yield_way(way_id, node_ids, attributes);

    if (m_read_metadatas and way.has_info()) {
      // qDebug().nospace() << "        with meta-info";
      OSMPBF::Info info = way.info();
      int32_t version = info.version();
      int64_t timestamp = to_timestamp(info.timestamp());
      int64_t changeset = info.changeset();
      int32_t uid = info.uid();
      int32_t user_sid = info.user_sid();
      // bool visible = info.visible();
      // qDebug() << "Meta information:" << version << timestamp << changeset << uid << user_sid;
      // yield_way_metadata(way_id, version, timestamp, changeset, uid, user_sid);
    }
  }

  leave_way_transactions();
}
Ejemplo n.º 4
0
void
QcOsmPbfReader::read_nodes(OSMPBF::PrimitiveGroup primitive_group)
{
  enter_node_transactions();

  int number_of_nodes = primitive_group.nodes_size();
  for (int i = 0; i < number_of_nodes; i++) {
    OSMPBF::Node node = primitive_group.nodes(i);
    int64_t node_id = node.id();
    int64_t longitude = node.lon();
    int64_t latitude = node.lat();
    // qDebug() << "        node " << i << node_id << to_wgs(longitude, latitude);

    int number_of_attributes = node.keys_size();
    QVector<KeyValPair> attributes(number_of_attributes);
    for (int i = 0; i < number_of_attributes; i++) {
      int32_t key_id = node.keys(i);
      int32_t val_id = node.vals(i);
      // qDebug() << "key_val" << node_id << m_string_table[key_id] << m_string_table[val_id];
    }

    yield_node(node_id, longitude, latitude, attributes);

    if (m_read_metadatas and node.has_info()) {
      // qDebug().nospace() << "        with meta-info";
      OSMPBF::Info info = node.info();
      int32_t version = info.version();
      int64_t timestamp = to_timestamp(info.timestamp());
      int64_t changeset = info.changeset();
      int32_t uid = info.uid();
      int32_t user_sid = info.user_sid();
      // bool visible = info.visible();
      // qDebug() << "Meta information:" << version << timestamp << changeset << uid << user_sid;
      // yield_node_metadata(node_id, version, timestamp, changeset, uid, user_sid);
    }
  }

  leave_node_transactions();
}