Changeset View
Changeset View
Standalone View
Standalone View
tools/vectorosm-tilecreator/NodeReducer.cpp
Context not available. | |||||
11 | #include "GeoDataPlacemark.h" | 11 | #include "GeoDataPlacemark.h" | ||
---|---|---|---|---|---|
12 | #include "GeoDataLineString.h" | 12 | #include "GeoDataLineString.h" | ||
13 | #include "GeoDataPolygon.h" | 13 | #include "GeoDataPolygon.h" | ||
14 | #include "GeoDataBuilding.h" | ||||
15 | #include "GeoDataMultiGeometry.h" | ||||
14 | #include "GeoDataCoordinates.h" | 16 | #include "GeoDataCoordinates.h" | ||
15 | #include "MarbleMath.h" | 17 | #include "MarbleMath.h" | ||
16 | #include "NodeReducer.h" | 18 | #include "NodeReducer.h" | ||
Context not available. | |||||
40 | placemark->setGeometry(reducedLine); | 42 | placemark->setGeometry(reducedLine); | ||
41 | } else if (m_zoomLevel < 17) { | 43 | } else if (m_zoomLevel < 17) { | ||
42 | if (const auto prevRing = geodata_cast<GeoDataLinearRing>(geometry)) { | 44 | if (const auto prevRing = geodata_cast<GeoDataLinearRing>(geometry)) { | ||
43 | GeoDataLinearRing* reducedRing = new GeoDataLinearRing; | 45 | placemark->setGeometry(reducedRing(*prevRing, placemark, visualCategory)); | ||
44 | reduce(*prevRing, placemark->osmData(), visualCategory, reducedRing); | | |||
45 | placemark->setGeometry(reducedRing); | | |||
46 | } else if (const auto prevPolygon = geodata_cast<GeoDataPolygon>(geometry)) { | 46 | } else if (const auto prevPolygon = geodata_cast<GeoDataPolygon>(geometry)) { | ||
47 | GeoDataPolygon* reducedPolygon = new GeoDataPolygon; | 47 | placemark->setGeometry(reducedPolygon(*prevPolygon, placemark, visualCategory)); | ||
48 | GeoDataLinearRing const * prevRing = &(prevPolygon->outerBoundary()); | 48 | } else if (const auto building = geodata_cast<GeoDataBuilding>(geometry)) { | ||
49 | GeoDataLinearRing reducedRing; | 49 | if (const auto prevRing = geodata_cast<GeoDataLinearRing>(&building->multiGeometry()->at(0))) { | ||
50 | reduce(*prevRing, placemark->osmData().memberReference(-1), visualCategory, &reducedRing); | 50 | GeoDataLinearRing* ring = reducedRing(*prevRing, placemark, visualCategory); | ||
51 | reducedPolygon->setOuterBoundary(reducedRing); | 51 | GeoDataBuilding* newBuilding = new GeoDataBuilding(*building); | ||
52 | QVector<GeoDataLinearRing> const & innerBoundaries = prevPolygon->innerBoundaries(); | 52 | newBuilding->multiGeometry()->clear(); | ||
53 | for(int i = 0; i < innerBoundaries.size(); i++) { | 53 | newBuilding->multiGeometry()->append(ring); | ||
54 | prevRing = &innerBoundaries[i]; | 54 | placemark->setGeometry(newBuilding); | ||
55 | GeoDataLinearRing reducedInnerRing; | 55 | } else if (const auto prevPolygon = geodata_cast<GeoDataPolygon>(&building->multiGeometry()->at(0))) { | ||
56 | reduce(*prevRing, placemark->osmData().memberReference(i), visualCategory, &reducedInnerRing); | 56 | GeoDataPolygon* poly = reducedPolygon(*prevPolygon, placemark, visualCategory); | ||
57 | reducedPolygon->appendInnerBoundary(reducedInnerRing); | 57 | GeoDataBuilding* newBuilding = new GeoDataBuilding(*building); | ||
58 | newBuilding->multiGeometry()->clear(); | ||||
59 | newBuilding->multiGeometry()->append(poly); | ||||
60 | placemark->setGeometry(newBuilding); | ||||
58 | } | 61 | } | ||
59 | placemark->setGeometry(reducedPolygon); | | |||
60 | } | 62 | } | ||
61 | } | 63 | } | ||
62 | } | 64 | } | ||
Context not available. | |||||
187 | osmData.addTag(QStringLiteral("mx:bp"), value.mid(1)); | 189 | osmData.addTag(QStringLiteral("mx:bp"), value.mid(1)); | ||
188 | } | 190 | } | ||
189 | 191 | | |||
192 | GeoDataLinearRing *NodeReducer::reducedRing(const GeoDataLinearRing& prevRing, | ||||
193 | GeoDataPlacemark* placemark, | ||||
194 | const GeoDataPlacemark::GeoDataVisualCategory& visualCategory) | ||||
195 | { | ||||
196 | GeoDataLinearRing* reducedRing = new GeoDataLinearRing; | ||||
197 | reduce(prevRing, placemark->osmData(), visualCategory, reducedRing); | ||||
198 | return reducedRing; | ||||
199 | } | ||||
200 | | ||||
201 | GeoDataPolygon *NodeReducer::reducedPolygon(const GeoDataPolygon& prevPolygon, | ||||
202 | GeoDataPlacemark* placemark, | ||||
203 | const GeoDataPlacemark::GeoDataVisualCategory& visualCategory) | ||||
204 | { | ||||
205 | GeoDataPolygon* reducedPolygon = new GeoDataPolygon; | ||||
206 | GeoDataLinearRing const * prevRing = &(prevPolygon.outerBoundary()); | ||||
207 | GeoDataLinearRing reducedRing; | ||||
208 | reduce(*prevRing, placemark->osmData().memberReference(-1), visualCategory, &reducedRing); | ||||
209 | reducedPolygon->setOuterBoundary(reducedRing); | ||||
210 | QVector<GeoDataLinearRing> const & innerBoundaries = prevPolygon.innerBoundaries(); | ||||
211 | for(int i = 0; i < innerBoundaries.size(); i++) { | ||||
212 | prevRing = &innerBoundaries[i]; | ||||
213 | GeoDataLinearRing reducedInnerRing; | ||||
214 | reduce(*prevRing, placemark->osmData().memberReference(i), visualCategory, &reducedInnerRing); | ||||
215 | reducedPolygon->appendInnerBoundary(reducedInnerRing); | ||||
216 | } | ||||
217 | return reducedPolygon; | ||||
218 | } | ||||
219 | | ||||
190 | } | 220 | } | ||
Context not available. |