This repository has been archived by the owner on Dec 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.cpp
112 lines (83 loc) · 3.18 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include <examples_common.h>
#include <autoware_vector_map/io/gpkg_interface.h>
#include <autoware_vector_map/bridge/boost/geometry_registration.h>
#include <autoware_vector_map/util/to_debug_string.h>
namespace autoware_vector_map {
void printTitle(const char* title) { std::cout << "### " << title << " ###" << std::endl; }
void example(const char* vector_map_path) {
io::GpkgInterface gpkg_interface(vector_map_path);
{
printTitle("getFeatureById");
using Feature = Lane;
for (Id id : {-1, 0, 1, 3, 1000}) {
const auto feature = gpkg_interface.getFeatureById<Feature>(id);
if (feature) {
std::cout << util::toDebugString(*feature) << std::endl;
} else {
std::cout << "feature not exist: " << id << std::endl;
}
}
}
{
printTitle("getFeaturesByIds");
using Feature = LaneSection;
const std::vector<Id> ids{-1, 0, 2, 4, 1000};
const auto features = gpkg_interface.getFeaturesByIds<Feature>(ids);
for (const auto& feature : features) {
std::cout << util::toDebugString(feature) << std::endl;
}
}
{
printTitle("getAllFeatures");
using Feature = Crosswalk;
const auto features = gpkg_interface.getAllFeatures<Feature>();
for (const auto& feature : features) {
std::cout << util::toDebugString(feature) << std::endl;
}
}
{
printTitle("findFeaturesByRange");
using Feature = Lane;
const Point3d p(80721.15, 7393.34, 0);
const double range = 5.0;
const auto features = gpkg_interface.findFeaturesByRange<Feature>(p, range);
for (const auto& feature : features) {
std::cout << util::toDebugString(feature) << std::endl;
}
}
{
printTitle("getRelatedFeaturesById");
using Relationship = LaneConnection;
const auto lane = *gpkg_interface.getFeatureById<Lane>(1);
const auto features =
gpkg_interface.getRelatedFeaturesById<Relationship, RelationSide::Left>(lane.id);
for (const auto& feature : features) {
std::cout << util::toDebugString(feature) << std::endl;
}
}
{
printTitle("getRelatedFeaturesById(with predicate)");
using Relationship = AdjacentLane;
const auto lane = *gpkg_interface.getFeatureById<Lane>(30);
const auto features1 = gpkg_interface.getRelatedFeaturesById<Relationship, RelationSide::Left>(
lane.id, [](const Relationship& r) { return r.type == "left"; });
for (const auto& feature : features1) {
std::cout << util::toDebugString(feature) << std::endl;
}
const auto features2 = gpkg_interface.getRelatedFeaturesById<Relationship, RelationSide::Left>(
lane.id, [](const Relationship& r) { return r.type == "right"; });
for (const auto& feature : features2) {
std::cout << util::toDebugString(feature) << std::endl;
}
}
{
printTitle("boost::geometry integration");
const auto lane_1 = *gpkg_interface.getFeatureById<Lane>(1);
const auto lane_2 = *gpkg_interface.getFeatureById<Lane>(2);
std::cout << boost::geometry::distance(lane_1.geometry.at(0), lane_2.geometry) << std::endl;
}
}
} // namespace autoware_vector_map
int main(int argc, char* argv[]) {
autoware_vector_map::example(helper::getExampleFilePath().c_str());
}