-
Notifications
You must be signed in to change notification settings - Fork 0
/
line_writer.hpp
45 lines (38 loc) · 1017 Bytes
/
line_writer.hpp
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
#ifndef LINE_WRITER_HPP
#define LINE_WRITER_HPP
#include "poly_line.hpp"
#include <iostream>
#include <sstream>
#include <fstream>
#include <vector>
#include <iomanip>
class line_writer
{
public:
line_writer(std::ostream& output)
: output(output)
{
}
void write(const std::vector<poly_line>& lines)
{
for (const auto& l : lines)
{
write_line(l);
}
}
private:
void write_line(const poly_line& line)
{
const std::string temp_start = "<gml:LineString srsName=\"EPSG:54004\" xmlns:gml=\"http://www.opengis.net/gml\"><gml:coordinates decimal=\".\" cs=\",\" ts=\" \">";
const std::string temp_end = "</gml:coordinates></gml:LineString>";
output << line.id << ":" << temp_start;
output << std::setprecision(9);
for (const auto& c : line.coordinates)
{
output << c.x << "," << c.y << " ";
}
output << temp_end << std::endl;
}
std::ostream& output;
};
#endif