MCPcopy Create free account
hub / github.com/Project-OSRM/osrm-backend / AddLine

Method AddLine

src/tools/components.cpp:71–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69 }
70
71 void AddLine(const util::Coordinate from,
72 const util::Coordinate to,
73 const OSMNodeID from_id,
74 const OSMNodeID to_id,
75 const std::string &type)
76 {
77 const auto from_lon = static_cast<double>(util::toFloating(from.lon));
78 const auto from_lat = static_cast<double>(util::toFloating(from.lat));
79 const auto to_lon = static_cast<double>(util::toFloating(to.lon));
80 const auto to_lat = static_cast<double>(util::toFloating(to.lat));
81
82 static bool first = true;
83
84 if (!first)
85 {
86 out << ",";
87 }
88
89 out << "{\"type\":\"Feature\",\"properties\":{\"from\":" << from_id << ","
90 << "\"to\":" << to_id << ",\"type\":\"" << type
91 << "\"},\"geometry\":{\"type\":\"LineString\",\"coordinates\":[[" << from_lon << ","
92 << from_lat << "],[" << to_lon << "," << to_lat << "]]}}";
93
94 first = false;
95 }
96
97 ~FeatureWriter() { out << "]}" << std::flush; }
98

Callers 1

mainFunction · 0.80

Calls 1

toFloatingFunction · 0.85

Tested by

no test coverage detected