Changeset View
Changeset View
Standalone View
Standalone View
src/lib/marble/osm/OsmObjectManager.cpp
Show All 9 Lines | |||||
10 | 10 | | |||
11 | // Self | 11 | // Self | ||
12 | #include "OsmObjectManager.h" | 12 | #include "OsmObjectManager.h" | ||
13 | 13 | | |||
14 | // Marble | 14 | // Marble | ||
15 | #include "GeoDataPlacemark.h" | 15 | #include "GeoDataPlacemark.h" | ||
16 | #include "GeoDataLinearRing.h" | 16 | #include "GeoDataLinearRing.h" | ||
17 | #include "GeoDataPolygon.h" | 17 | #include "GeoDataPolygon.h" | ||
18 | #include "GeoDataBuilding.h" | ||||
19 | #include "GeoDataMultiGeometry.h" | ||||
18 | #include "osm/OsmPlacemarkData.h" | 20 | #include "osm/OsmPlacemarkData.h" | ||
19 | 21 | | |||
20 | namespace Marble { | 22 | namespace Marble { | ||
21 | 23 | | |||
22 | qint64 OsmObjectManager::m_minId = -1; | 24 | qint64 OsmObjectManager::m_minId = -1; | ||
23 | 25 | | |||
24 | void OsmObjectManager::initializeOsmData( GeoDataPlacemark* placemark ) | 26 | void OsmObjectManager::initializeOsmData( GeoDataPlacemark* placemark ) | ||
25 | { | 27 | { | ||
Show All 13 Lines | 38 | if (const auto lineString = geodata_cast<GeoDataLineString>(placemark->geometry())) { | |||
39 | 41 | | |||
40 | for ( ; it != end; ++it ) { | 42 | for ( ; it != end; ++it ) { | ||
41 | if (osmData.nodeReference(*it).isNull()) { | 43 | if (osmData.nodeReference(*it).isNull()) { | ||
42 | osmData.nodeReference(*it).setId(--m_minId); | 44 | osmData.nodeReference(*it).setId(--m_minId); | ||
43 | } | 45 | } | ||
44 | } | 46 | } | ||
45 | } | 47 | } | ||
46 | 48 | | |||
49 | const auto building = geodata_cast<GeoDataBuilding>(placemark->geometry()); | ||||
50 | | ||||
51 | GeoDataLinearRing* lineString; | ||||
52 | if (building) { | ||||
53 | lineString = geodata_cast<GeoDataLinearRing>(&building->multiGeometry()->at(0)); | ||||
54 | } else { | ||||
55 | lineString = geodata_cast<GeoDataLinearRing>(placemark->geometry()); | ||||
56 | } | ||||
47 | // Assigning osmData to each of the line's nodes ( if they don't already have data ) | 57 | // Assigning osmData to each of the line's nodes ( if they don't already have data ) | ||
48 | if (const auto lineString = geodata_cast<GeoDataLinearRing>(placemark->geometry())) { | 58 | if (lineString) { | ||
49 | for (auto it =lineString->constBegin(), end = lineString->constEnd(); it != end; ++it ) { | 59 | for (auto it =lineString->constBegin(), end = lineString->constEnd(); it != end; ++it ) { | ||
50 | if (osmData.nodeReference(*it).isNull()) { | 60 | if (osmData.nodeReference(*it).isNull()) { | ||
51 | osmData.nodeReference(*it).setId(--m_minId); | 61 | osmData.nodeReference(*it).setId(--m_minId); | ||
52 | } | 62 | } | ||
53 | } | 63 | } | ||
54 | } | 64 | } | ||
55 | 65 | | |||
66 | GeoDataPolygon* polygon; | ||||
67 | if (building) { | ||||
68 | polygon = geodata_cast<GeoDataPolygon>(&building->multiGeometry()->at(0)); | ||||
69 | } else { | ||||
70 | polygon = geodata_cast<GeoDataPolygon>(placemark->geometry()); | ||||
71 | } | ||||
56 | // Assigning osmData to each of the polygons boundaries, and to each of the | 72 | // Assigning osmData to each of the polygons boundaries, and to each of the | ||
57 | // nodes that are part of those boundaries ( if they don't already have data ) | 73 | // nodes that are part of those boundaries ( if they don't already have data ) | ||
58 | if (const auto polygon = geodata_cast<GeoDataPolygon>(placemark->geometry())) { | 74 | if (polygon) { | ||
59 | const GeoDataLinearRing &outerBoundary = polygon->outerBoundary(); | 75 | const GeoDataLinearRing &outerBoundary = polygon->outerBoundary(); | ||
60 | int index = -1; | 76 | int index = -1; | ||
61 | if ( isNull ) { | 77 | if ( isNull ) { | ||
62 | osmData.addTag(QStringLiteral("type"), QStringLiteral("multipolygon")); | 78 | osmData.addTag(QStringLiteral("type"), QStringLiteral("multipolygon")); | ||
63 | } | 79 | } | ||
64 | 80 | | |||
65 | // Outer boundary | 81 | // Outer boundary | ||
66 | OsmPlacemarkData &outerBoundaryData = osmData.memberReference( index ); | 82 | OsmPlacemarkData &outerBoundaryData = osmData.memberReference( index ); | ||
▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines |