forked from tudelft3d/3dfier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBridge.cpp
127 lines (107 loc) · 4.22 KB
/
Bridge.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
3dfier: takes 2D GIS datasets and "3dfies" to create 3D city models.
Copyright (C) 2015-2018 3D geoinformation research group, TU Delft
This file is part of 3dfier.
3dfier is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
3dfier is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with 3difer. If not, see <http://www.gnu.org/licenses/>.
For any information or further details about the use of 3dfier, contact
Hugo Ledoux
Faculty of Architecture & the Built Environment
Delft University of Technology
Julianalaan 134, Delft 2628BL, the Netherlands
*/
#include "Bridge.h"
float Bridge::_heightref;
bool Bridge::_flatten;
Bridge::Bridge(char *wkt, std::string layername, AttributeMap attributes, std::string pid, float heightref, bool flatten)
: Boundary3D(wkt, layername, attributes, pid) {
_heightref = heightref;
_flatten = flatten;
}
TopoClass Bridge::get_class() {
return BRIDGE;
}
bool Bridge::is_hard() {
return true;
}
void Bridge::cleanup_elevations() {
TopoFeature::cleanup_elevations();
}
std::string Bridge::get_mtl() {
return "usemtl Bridge";
}
bool Bridge::add_elevation_point(Point2 &p, double z, float radius, int lasclass, bool within) {
return Boundary3D::add_elevation_point(p, z, radius, lasclass, within);
}
bool Bridge::lift() {
lift_each_boundary_vertices(_heightref);
return true;
}
bool Bridge::get_flatten() {
return _flatten;
}
void Bridge::get_cityjson(nlohmann::json& j, std::unordered_map<std::string,unsigned long> &dPts) {
nlohmann::json f;
f["type"] = "Bridge";
f["attributes"];
get_cityjson_attributes(f, _attributes);
nlohmann::json g;
this->get_cityjson_geom(g, dPts);
f["geometry"].push_back(g);
j["CityObjects"][this->get_id()] = f;
}
void Bridge::get_citygml(std::wostream& of) {
of << "<cityObjectMember>";
of << "<bri:Bridge gml:id=\"" << this->get_id() << "\">";
get_citygml_attributes(of, _attributes);
of << "<bri:lod1MultiSurface>";
of << "<gml:MultiSurface>";
for (auto& t : _triangles)
get_triangle_as_gml_surfacemember(of, t);
for (auto& t : _triangles_vw)
get_triangle_as_gml_surfacemember(of, t, true);
of << "</gml:MultiSurface>";
of << "</bri:lod1MultiSurface>";
of << "</bri:Bridge>";
of << "</cityObjectMember>";
}
void Bridge::get_citygml_imgeo(std::wostream& of) {
of << "<cityObjectMember>";
of << "<bri:BridgeConstructionElement gml:id=\"" << this->get_id() << "\">";
get_imgeo_object_info(of, this->get_id());
of << "<bri:lod1Geometry>";
of << "<gml:MultiSurface>";
for (auto& t : _triangles)
get_triangle_as_gml_surfacemember(of, t);
for (auto& t : _triangles_vw)
get_triangle_as_gml_surfacemember(of, t, true);
of << "</gml:MultiSurface>";
of << "</bri:lod1Geometry>";
std::string attribute;
if (get_attribute("bgt-type", attribute)) {
of << "<bri:function codeSpace=\"http://www.geostandaarden.nl/imgeo/def/2.1#TypeOverbruggingsdeel\">" << attribute << "</bri:function>";
}
else if (get_attribute("bgt_type", attribute)) {
of << "<bri:function codeSpace=\"http://www.geostandaarden.nl/imgeo/def/2.1#TypeOverbruggingsdeel\">" << attribute << "</bri:function>";
}
if (get_attribute("hoortbijtypeoverbrugging", attribute)) {
of << "<imgeo:hoortBijTypeOverbrugging codeSpace=\"http://www.geostandaarden.nl/imgeo/def/2.1#TypeOverbrugging\">" << attribute << "</imgeo:hoortBijTypeOverbrugging>";
}
if (get_attribute("overbruggingisbeweegbaar", attribute)) {
of << "<imgeo:overbruggingIsBeweegbaar>" << attribute << "</imgeo:overbruggingIsBeweegbaar>";
}
of << "</bri:BridgeConstructionElement>";
of << "</cityObjectMember>";
}
bool Bridge::get_shape(OGRLayer* layer, bool writeAttributes, const AttributeMap& extraAttributes) {
return TopoFeature::get_multipolygon_features(layer, "Bridge", writeAttributes, extraAttributes);
}