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 | building->multiGeometry()->clear(); | ||
52 | QVector<GeoDataLinearRing> const & innerBoundaries = prevPolygon->innerBoundaries(); | 52 | building->multiGeometry()->append(ring); | ||
53 | for(int i = 0; i < innerBoundaries.size(); i++) { | 53 | placemark->setGeometry(new GeoDataBuilding(*building)); | ||
54 | prevRing = &innerBoundaries[i]; | 54 | } else if (const auto prevPolygon = geodata_cast<GeoDataPolygon>(&building->multiGeometry()->at(0))) { | ||
55 | GeoDataLinearRing reducedInnerRing; | 55 | GeoDataPolygon* poly = reducedPolygon(*prevPolygon, placemark, visualCategory); | ||
56 | reduce(*prevRing, placemark->osmData().memberReference(i), visualCategory, &reducedInnerRing); | 56 | building->multiGeometry()->clear(); | ||
57 | reducedPolygon->appendInnerBoundary(reducedInnerRing); | 57 | building->multiGeometry()->append(poly); | ||
58 | placemark->setGeometry(new GeoDataBuilding(*building)); | ||||
58 | } | 59 | } | ||
59 | placemark->setGeometry(reducedPolygon); | | |||
60 | } | 60 | } | ||
61 | } | 61 | } | ||
62 | } | 62 | } | ||
Context not available. | |||||
187 | osmData.addTag(QStringLiteral("mx:bp"), value.mid(1)); | 187 | osmData.addTag(QStringLiteral("mx:bp"), value.mid(1)); | ||
188 | } | 188 | } | ||
189 | 189 | | |||
190 | GeoDataLinearRing *NodeReducer::reducedRing(const GeoDataLinearRing& prevRing, | ||||
191 | GeoDataPlacemark* placemark, | ||||
192 | const GeoDataPlacemark::GeoDataVisualCategory& visualCategory) | ||||
193 | { | ||||
194 | GeoDataLinearRing* reducedRing = new GeoDataLinearRing; | ||||
195 | reduce(prevRing, placemark->osmData(), visualCategory, reducedRing); | ||||
196 | return reducedRing; | ||||
197 | } | ||||
198 | | ||||
199 | GeoDataPolygon *NodeReducer::reducedPolygon(const GeoDataPolygon& prevPolygon, | ||||
200 | GeoDataPlacemark* placemark, | ||||
201 | const GeoDataPlacemark::GeoDataVisualCategory& visualCategory) | ||||
202 | { | ||||
203 | GeoDataPolygon* reducedPolygon = new GeoDataPolygon; | ||||
204 | GeoDataLinearRing const * prevRing = &(prevPolygon.outerBoundary()); | ||||
205 | GeoDataLinearRing reducedRing; | ||||
206 | reduce(*prevRing, placemark->osmData().memberReference(-1), visualCategory, &reducedRing); | ||||
207 | reducedPolygon->setOuterBoundary(reducedRing); | ||||
208 | QVector<GeoDataLinearRing> const & innerBoundaries = prevPolygon.innerBoundaries(); | ||||
209 | for(int i = 0; i < innerBoundaries.size(); i++) { | ||||
210 | prevRing = &innerBoundaries[i]; | ||||
211 | GeoDataLinearRing reducedInnerRing; | ||||
212 | reduce(*prevRing, placemark->osmData().memberReference(i), visualCategory, &reducedInnerRing); | ||||
213 | reducedPolygon->appendInnerBoundary(reducedInnerRing); | ||||
214 | } | ||||
215 | return reducedPolygon; | ||||
216 | } | ||||
217 | | ||||
190 | } | 218 | } | ||
Context not available. |