Changeset View
Changeset View
Standalone View
Standalone View
tools/vectorosm-tilecreator/VectorClipper.h
Context not available. | |||||
17 | #include <GeoDataLatLonBox.h> | 17 | #include <GeoDataLatLonBox.h> | ||
---|---|---|---|---|---|
18 | #include "GeoDataPlacemark.h" | 18 | #include "GeoDataPlacemark.h" | ||
19 | #include "GeoDataLinearRing.h" | 19 | #include "GeoDataLinearRing.h" | ||
20 | #include "GeoDataBuilding.h" | ||||
21 | #include "GeoDataMultiGeometry.h" | ||||
20 | #include <TileId.h> | 22 | #include <TileId.h> | ||
21 | #include <GeoSceneMercatorTileProjection.h> | 23 | #include <GeoSceneMercatorTileProjection.h> | ||
22 | #include <OsmObjectManager.h> | 24 | #include <OsmObjectManager.h> | ||
Context not available. | |||||
50 | void clipString(const GeoDataPlacemark *placemark, const ClipperLib::Path &tileBoundary, qreal minArea, | 52 | void clipString(const GeoDataPlacemark *placemark, const ClipperLib::Path &tileBoundary, qreal minArea, | ||
51 | GeoDataDocument* document, QSet<qint64> &osmIds) | 53 | GeoDataDocument* document, QSet<qint64> &osmIds) | ||
52 | { | 54 | { | ||
53 | const T* ring = static_cast<const T*>(placemark->geometry()); | 55 | bool isBuilding = false; | ||
56 | T* ring; | ||||
57 | if (const auto building = geodata_cast<GeoDataBuilding>(placemark->geometry())) { | ||||
58 | ring = geodata_cast<T>(&building->multiGeometry()->at(0)); | ||||
59 | isBuilding = true; | ||||
60 | } else { | ||||
61 | GeoDataPlacemark* copyPlacemark = new GeoDataPlacemark(*placemark); | ||||
62 | ring = geodata_cast<T>(copyPlacemark->geometry()); | ||||
63 | } | ||||
54 | bool const isClosed = ring->isClosed() && canBeArea(placemark->visualCategory()); | 64 | bool const isClosed = ring->isClosed() && canBeArea(placemark->visualCategory()); | ||
55 | if (isClosed && minArea > 0.0 && area(*static_cast<const GeoDataLinearRing*>(ring)) < minArea) { | 65 | if (isClosed && minArea > 0.0 && area(*static_cast<const GeoDataLinearRing*>(ring)) < minArea) { | ||
56 | return; | 66 | return; | ||
Context not available. | |||||
92 | ++index; | 102 | ++index; | ||
93 | } | 103 | } | ||
94 | 104 | | |||
95 | newPlacemark->setGeometry(newRing); | 105 | if (isBuilding) { | ||
106 | const auto building = geodata_cast<GeoDataBuilding>(placemark->geometry()); | ||||
107 | GeoDataBuilding* newBuilding = new GeoDataBuilding(*building); | ||||
108 | newBuilding->multiGeometry()->clear(); | ||||
109 | newBuilding->multiGeometry()->append(newRing); | ||||
110 | newPlacemark->setGeometry(newBuilding); | ||||
111 | } else { | ||||
112 | newPlacemark->setGeometry(newRing); | ||||
113 | } | ||||
96 | if (placemark->osmData().id() > 0) { | 114 | if (placemark->osmData().id() > 0) { | ||
97 | newPlacemark->osmData().addTag(QStringLiteral("mx:oid"), QString::number(placemark->osmData().id())); | 115 | newPlacemark->osmData().addTag(QStringLiteral("mx:oid"), QString::number(placemark->osmData().id())); | ||
98 | } | 116 | } | ||
Context not available. |