CARLA
Loading...
Searching...
No Matches
OsmIngest.h
Go to the documentation of this file.
1// Copyright (c) 2026 Computer Vision Center (CVC) at the Universitat Autonoma
2// de Barcelona (UAB).
3//
4// This work is licensed under the terms of the MIT license.
5// For a copy, see <https://opensource.org/licenses/MIT>.
6
7#pragma once
8
9#include <map>
10#include <optional>
11#include <string>
12#include <vector>
13
14#include "Model.h"
15
16namespace twinmodel {
17
18 struct OsmNode {
19 long long id = 0;
20 double lat = 0.0;
21 double lon = 0.0;
23 };
24
25 struct OsmWay {
26 long long id = 0;
27 std::vector<long long> nodes;
29 };
30
31 struct OsmMember {
32 std::string type;
33 long long ref = 0;
34 std::string role;
35 };
36
37 struct OsmRelation {
38 long long id = 0;
39 std::vector<OsmMember> members;
41 };
42
43 struct BoundingBox {
44 double south = 0.0;
45 double west = 0.0;
46 double north = 0.0;
47 double east = 0.0;
48 };
49
50 struct OsmData {
51 std::map<long long, OsmNode> nodes;
52 std::vector<OsmWay> ways;
53 std::vector<OsmRelation> relations;
54 std::optional<BoundingBox> bbox;
55
56 /// Extent of the nodes themselves, used when the file carries no <bounds>
57 /// or the bounds are smaller than the ways crossing them.
58 BoundingBox NodeExtent() const;
59 };
60
61 /// Parse an OpenStreetMap XML document. Throws std::runtime_error when the
62 /// document cannot be parsed or carries no nodes.
63 OsmData ParseOsmXml(const std::string &xml);
64
65} // namespace twinmodel
OsmData ParseOsmXml(const std::string &xml)
Parse an OpenStreetMap XML document.
Definition OsmIngest.cpp:47
std::map< std::string, std::string > Tags
Definition Model.h:18
std::vector< OsmRelation > relations
Definition OsmIngest.h:53
std::vector< OsmWay > ways
Definition OsmIngest.h:52
BoundingBox NodeExtent() const
Extent of the nodes themselves, used when the file carries no <bounds> or the bounds are smaller than...
Definition OsmIngest.cpp:32
std::map< long long, OsmNode > nodes
Definition OsmIngest.h:51
std::optional< BoundingBox > bbox
Definition OsmIngest.h:54
std::string type
Definition OsmIngest.h:32
std::string role
Definition OsmIngest.h:34
std::vector< OsmMember > members
Definition OsmIngest.h:39
std::vector< long long > nodes
Definition OsmIngest.h:27