Changeset View
Changeset View
Standalone View
Standalone View
src/lib/marble/geodata/data/GeoDataBuilding.cpp
Context not available. | |||||
104 | return &d->m_multiGeometry; | 104 | return &d->m_multiGeometry; | ||
---|---|---|---|---|---|
105 | } | 105 | } | ||
106 | 106 | | |||
107 | const GeoDataLatLonAltBox &GeoDataBuilding::latLonAltBox() const | ||||
108 | { | ||||
109 | // @TODO: This is temporary, for only when we have just one child | ||||
nienhueser: Wouldn't hurt to also have
```
Q_ASSERT(d->m_multiGeometry.size() == 1);
``` | |||||
110 | Q_ASSERT(d->m_multiGeometry.size() == 1); | ||||
111 | return d->m_multiGeometry.at(0).latLonAltBox(); | ||||
112 | } | ||||
113 | | ||||
114 | QString GeoDataBuilding::name() const | ||||
115 | { | ||||
116 | return d->m_name; | ||||
117 | } | ||||
118 | | ||||
119 | void GeoDataBuilding::setName(const QString& name) | ||||
120 | { | ||||
121 | d->m_name = name; | ||||
122 | } | ||||
123 | | ||||
124 | QVector<GeoDataBuilding::NamedEntry> GeoDataBuilding::entries() const | ||||
125 | { | ||||
126 | return d->m_entries; | ||||
127 | } | ||||
128 | | ||||
129 | void GeoDataBuilding::setEntries(const QVector<GeoDataBuilding::NamedEntry> &entries) | ||||
130 | { | ||||
131 | d->m_entries = entries; | ||||
132 | } | ||||
133 | | ||||
134 | double GeoDataBuilding::parseBuildingHeight(const QString& buildingHeight) | ||||
135 | { | ||||
136 | double height = 8.0; | ||||
137 | | ||||
138 | // check first for unitless value | ||||
139 | bool converted; | ||||
140 | double extractedHeight = buildingHeight.toDouble(&converted); | ||||
141 | if (converted) { | ||||
142 | return extractedHeight; | ||||
143 | } | ||||
144 | | ||||
145 | if (buildingHeight.endsWith(QChar('m')) || | ||||
146 | buildingHeight.endsWith(QLatin1String("meter")) || | ||||
147 | buildingHeight.endsWith(QLatin1String("meters")) || | ||||
148 | buildingHeight.endsWith(QLatin1String("metre")) || | ||||
149 | buildingHeight.endsWith(QLatin1String("metres"))) { | ||||
I think this violates "The default unit is meters", see https://wiki.openstreetmap.org/wiki/Key:height#Height_of_buildings nienhueser: I think this violates "The default unit is meters", see https://wiki.openstreetmap.org/wiki/Key… | |||||
150 | QString const heightValue = QString(buildingHeight).remove(QStringLiteral("meters")) | ||||
151 | .remove(QStringLiteral("meter")).remove(QStringLiteral("metres")) | ||||
152 | .remove(QStringLiteral("metre")).remove(QChar('m')).trimmed(); | ||||
153 | bool extracted; | ||||
154 | double extractedHeight = heightValue.toDouble(&extracted); | ||||
155 | if (extracted) { | ||||
156 | height = extractedHeight; | ||||
157 | } | ||||
158 | } else { // feet and inches | ||||
159 | double extractedHeight = 0.0; // in inches, converted to meters in the end | ||||
160 | if (buildingHeight.contains(QChar('\''))) { | ||||
161 | double heightInches = 0.0; | ||||
162 | QStringList const feetInches = buildingHeight.split(QChar('\'')); | ||||
163 | bool okFeet; | ||||
164 | double feet = feetInches[0].trimmed().toDouble(&okFeet); | ||||
165 | if (okFeet) { | ||||
166 | heightInches = feet * FT2IN; | ||||
167 | } | ||||
168 | if (!feetInches[1].isEmpty()) { // has inches as unit as well | ||||
169 | bool okInches; | ||||
170 | double inches = QString(feetInches[1]).remove(QChar('\"')).trimmed().toDouble(&okInches); | ||||
171 | if (okInches) { | ||||
See Dennis' comment below: MarbleGlobal.h also features FT2M to convert feet to meters. rahn: See Dennis' comment below: MarbleGlobal.h also features FT2M to convert feet to meters. | |||||
172 | heightInches += inches; | ||||
173 | } | ||||
174 | } | ||||
175 | extractedHeight = heightInches; | ||||
nienhueser: Please use IN2M (from MarbleGlobal.h) instead of 0.0254 | |||||
176 | } else if (buildingHeight.endsWith(QLatin1String("feet"))) { | ||||
177 | bool ok; | ||||
178 | double feet = QString(buildingHeight).remove(QStringLiteral("feet")).trimmed().toDouble(&ok); | ||||
179 | if (ok) { | ||||
180 | extractedHeight = feet * FT2IN; | ||||
181 | } | ||||
182 | } | ||||
183 | if (extractedHeight > 0.0) { | ||||
184 | height = extractedHeight * IN2M; // convert inches to meters | ||||
185 | } | ||||
186 | } | ||||
187 | | ||||
188 | return height; | ||||
189 | } | ||||
190 | | ||||
107 | } | 191 | } | ||
Context not available. |
Wouldn't hurt to also have