Changeset View
Changeset View
Standalone View
Standalone View
tools/vectorosm-tilecreator/VectorClipper.cpp
Context not available. | |||||
76 | clipString<GeoDataLineString>(placemark, clip, minArea, tile, osmIds); | 76 | clipString<GeoDataLineString>(placemark, clip, minArea, tile, osmIds); | ||
---|---|---|---|---|---|
77 | } else if (geodata_cast<GeoDataLinearRing>(geometry)) { | 77 | } else if (geodata_cast<GeoDataLinearRing>(geometry)) { | ||
78 | clipString<GeoDataLinearRing>(placemark, clip, minArea, tile, osmIds); | 78 | clipString<GeoDataLinearRing>(placemark, clip, minArea, tile, osmIds); | ||
79 | } else if (const auto building = geodata_cast<GeoDataBuilding>(geometry)) { | ||||
80 | if (geodata_cast<GeoDataPolygon>(&building->multiGeometry()->at(0))) { | ||||
81 | clipPolygon(placemark, clip, minArea, tile, osmIds); | ||||
82 | } else if (geodata_cast<GeoDataLinearRing>(&building->multiGeometry()->at(0))) { | ||||
83 | clipString<GeoDataLinearRing>(placemark, clip, minArea, tile, osmIds); | ||||
84 | } | ||||
79 | } else { | 85 | } else { | ||
80 | tile->append(placemark->clone()); | 86 | tile->append(placemark->clone()); | ||
81 | osmIds << placemark->osmData().id(); | 87 | osmIds << placemark->osmData().id(); | ||
Context not available. | |||||
224 | void VectorClipper::clipPolygon(const GeoDataPlacemark *placemark, const ClipperLib::Path &tileBoundary, qreal minArea, | 230 | void VectorClipper::clipPolygon(const GeoDataPlacemark *placemark, const ClipperLib::Path &tileBoundary, qreal minArea, | ||
225 | GeoDataDocument *document, QSet<qint64> &osmIds) | 231 | GeoDataDocument *document, QSet<qint64> &osmIds) | ||
226 | { | 232 | { | ||
227 | const GeoDataPolygon* polygon = static_cast<const GeoDataPolygon*>(placemark->geometry()); | 233 | bool isBuilding = false; | ||
234 | GeoDataPolygon* polygon; | ||||
235 | if (const auto building = geodata_cast<GeoDataBuilding>(placemark->geometry())) { | ||||
236 | polygon = geodata_cast<GeoDataPolygon>(&building->multiGeometry()->at(0)); | ||||
237 | isBuilding = true; | ||||
238 | } else { | ||||
239 | GeoDataPlacemark* copyPlacemark = new GeoDataPlacemark(*placemark); | ||||
240 | polygon = geodata_cast<GeoDataPolygon>(copyPlacemark->geometry()); | ||||
241 | } | ||||
242 | | ||||
228 | if (minArea > 0.0 && area(polygon->outerBoundary()) < minArea) { | 243 | if (minArea > 0.0 && area(polygon->outerBoundary()) < minArea) { | ||
229 | return; | 244 | return; | ||
230 | } | 245 | } | ||
Context not available. | |||||
265 | 280 | | |||
266 | GeoDataPolygon* newPolygon = new GeoDataPolygon; | 281 | GeoDataPolygon* newPolygon = new GeoDataPolygon; | ||
267 | newPolygon->setOuterBoundary(outerRing); | 282 | newPolygon->setOuterBoundary(outerRing); | ||
268 | newPlacemark->setGeometry(newPolygon); | 283 | if (isBuilding) { | ||
284 | const auto building = geodata_cast<GeoDataBuilding>(placemark->geometry()); | ||||
285 | GeoDataBuilding* newBuilding = new GeoDataBuilding(*building); | ||||
286 | newBuilding->multiGeometry()->clear(); | ||||
287 | newBuilding->multiGeometry()->append(newPolygon); | ||||
288 | newPlacemark->setGeometry(newBuilding); | ||||
289 | } else { | ||||
290 | newPlacemark->setGeometry(newPolygon); | ||||
291 | } | ||||
269 | if (placemarkOsmData.id() > 0) { | 292 | if (placemarkOsmData.id() > 0) { | ||
270 | newPlacemarkOsmData.addTag(QStringLiteral("mx:oid"), QString::number(placemarkOsmData.id())); | 293 | newPlacemarkOsmData.addTag(QStringLiteral("mx:oid"), QString::number(placemarkOsmData.id())); | ||
271 | } | 294 | } | ||
Context not available. |