summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshat Tandon <akshat.tandon@research.iiit.ac.in>2016-07-22 02:30:06 (GMT)
committerAkshat Tandon <akshat.tandon@research.iiit.ac.in>2016-07-22 02:31:30 (GMT)
commitd67eb06fc35d6678e84d5e022a1365c8c7c0af2b (patch)
tree70c68b3210f161fcf844d2a772d6622945b18b0f
parent65c4af4a2a456767df247574b4803095c558a0bf (diff)
Modified vector rendering support for bathymetry
Now bathymetry is considered as a single GeoDataFeature and depending on the elvation info, it is rendered accordingly. Reviewers: nienhueser, rahn Differential Revision: https://phabricator.kde.org/D2228
-rw-r--r--src/lib/marble/StyleBuilder.cpp36
-rw-r--r--src/lib/marble/geodata/graphicsitem/GeoPolygonGraphicsItem.cpp34
-rw-r--r--src/lib/marble/geodata/graphicsitem/GeoPolygonGraphicsItem.h1
-rw-r--r--src/lib/marble/layers/GeometryLayer.cpp4
-rw-r--r--src/plugins/runner/osm/OsmRelation.cpp10
-rw-r--r--tools/shp2osm/polyshp2osm.py2
6 files changed, 80 insertions, 7 deletions
diff --git a/src/lib/marble/StyleBuilder.cpp b/src/lib/marble/StyleBuilder.cpp
index 7d11483..26ada26 100644
--- a/src/lib/marble/StyleBuilder.cpp
+++ b/src/lib/marble/StyleBuilder.cpp
@@ -722,7 +722,7 @@ void StyleBuilder::Private::initializeDefaultStyles()
m_defaultStyle[GeoDataFeature::Landmass] = StyleBuilder::Private::createWayStyle( "#F1EEE8", "#F1EEE8", true, true );
m_defaultStyle[GeoDataFeature::UrbanArea] = StyleBuilder::Private::createWayStyle( "#E6E3DD", "#E6E3DD", true, true );
m_defaultStyle[GeoDataFeature::InternationalDateLine] = StyleBuilder::Private::createStyle( 1.0, 0.0, "#000000", "#000000", false, true, Qt::SolidPattern, Qt::SolidLine, Qt::FlatCap, false );
- m_defaultStyle[GeoDataFeature::Bathymetry] = StyleBuilder::Private::createWayStyle( "#a5c9c9", "#a5c9c9", true, true );
+ m_defaultStyle[GeoDataFeature::Bathymetry] = StyleBuilder::Private::createWayStyle( waterColor, waterColor, true, true );
m_defaultStyle[GeoDataFeature::AdminLevel1] = StyleBuilder::Private::createStyle(0.0, 0.0, "#DF9CCF", "#DF9CCF", false, true, Qt::SolidPattern, Qt::CustomDashLine, Qt::FlatCap, false, QVector< qreal >() << 0.3 << 0.3 );
m_defaultStyle[GeoDataFeature::AdminLevel2] = StyleBuilder::Private::createStyle(2.0, 0.0, "#DF9CCF", "#DF9CCF", false, true, Qt::SolidPattern, Qt::SolidLine, Qt::FlatCap, false, QVector< qreal >() << 0.3 << 0.3 );
@@ -888,12 +888,16 @@ GeoDataStyle::ConstPtr StyleBuilder::createStyle(const StyleParameters &paramete
}
}
else if (visualCategory == GeoDataFeature::Bathymetry) {
- if( osmData.containsTagKey("depth") ){
- // Style according to depth
-
+ if (osmData.containsTagKey("ele")) {
+ QString elevation = osmData.tagValue("ele");
+ if (elevation == "4000") {
+ polyStyle.setColor("#a5c9c9");
+ lineStyle.setColor("#a5c9c9");
+ adjustStyle = true;
+ }
}
}
- else if(visualCategory == GeoDataFeature::AmenityGraveyard || visualCategory == GeoDataFeature::LanduseCemetery) {
+ else if (visualCategory == GeoDataFeature::AmenityGraveyard || visualCategory == GeoDataFeature::LanduseCemetery) {
if( osmData.containsTag("religion","jewish") ){
polyStyle.setTexturePath(MarbleDirs::path("bitmaps/osmcarto/patterns/grave_yard_jewish.png"));
adjustStyle = true;
@@ -1000,6 +1004,28 @@ GeoDataStyle::ConstPtr StyleBuilder::createStyle(const StyleParameters &paramete
}
style = newStyle;
+ } else if (placemark->geometry()->nodeType() == GeoDataTypes::GeoDataPolygonType) {
+ GeoDataPolyStyle polyStyle = style->polyStyle();
+ GeoDataLineStyle lineStyle = style->lineStyle();
+ bool adjustStyle = false;
+ if (visualCategory == GeoDataFeature::Bathymetry) {
+ if (osmData.containsTagKey("ele")) {
+ QString elevation = osmData.tagValue("ele");
+ if (elevation == "4000") {
+ polyStyle.setColor("#a5c9c9");
+ lineStyle.setColor("#a5c9c9");
+ adjustStyle = true;
+ }
+ }
+ }
+
+ if (adjustStyle) {
+ GeoDataStyle::Ptr newStyle(new GeoDataStyle(*style));
+ newStyle->setPolyStyle(polyStyle);
+ newStyle->setLineStyle(lineStyle);
+ style = newStyle;
+ }
+
}
return style;
diff --git a/src/lib/marble/geodata/graphicsitem/GeoPolygonGraphicsItem.cpp b/src/lib/marble/geodata/graphicsitem/GeoPolygonGraphicsItem.cpp
index 28051ac..5d1df9b 100644
--- a/src/lib/marble/geodata/graphicsitem/GeoPolygonGraphicsItem.cpp
+++ b/src/lib/marble/geodata/graphicsitem/GeoPolygonGraphicsItem.cpp
@@ -46,6 +46,12 @@ GeoPolygonGraphicsItem::GeoPolygonGraphicsItem(const GeoDataFeature *feature, co
paintLayers << QString("Polygon/Building/roof");
setPaintLayers(paintLayers);
}
+ else if (visualCategory == GeoDataFeature::Bathymetry) {
+ int elevation = extractBathymetryElevation(feature);
+ setZValue(this->zValue() + elevation);
+ const QString paintLayer = QString("Polygon/%1").arg(StyleBuilder::visualCategoryName(visualCategory));
+ setPaintLayers(QStringList() << paintLayer);
+ }
else
{
const QString paintLayer = QString("Polygon/%1").arg(StyleBuilder::visualCategoryName(visualCategory));
@@ -72,6 +78,12 @@ GeoPolygonGraphicsItem::GeoPolygonGraphicsItem(const GeoDataFeature *feature, co
paintLayers << QString("Polygon/Building/roof");
setPaintLayers(paintLayers);
}
+ else if (visualCategory == GeoDataFeature::Bathymetry) {
+ int elevation = extractBathymetryElevation(feature);
+ setZValue(this->zValue() + elevation);
+ const QString paintLayer = QString("Polygon/%1").arg(StyleBuilder::visualCategoryName(visualCategory));
+ setPaintLayers(QStringList() << paintLayer);
+ }
else
{
const QString paintLayer = QString("Polygon/%1").arg(StyleBuilder::visualCategoryName(visualCategory));
@@ -79,6 +91,28 @@ GeoPolygonGraphicsItem::GeoPolygonGraphicsItem(const GeoDataFeature *feature, co
}
}
+int GeoPolygonGraphicsItem::extractBathymetryElevation(const GeoDataFeature *feature)
+{
+ const GeoDataFeature::GeoDataVisualCategory visualCategory = feature->visualCategory();
+ if (visualCategory != GeoDataFeature::Bathymetry) {
+ return 0;
+ }
+
+ int elevation = 0;
+
+ if (feature->nodeType() == GeoDataTypes::GeoDataPlacemarkType) {
+ const GeoDataPlacemark *placemark = static_cast<const GeoDataPlacemark *>(feature);
+
+ if (placemark->osmData().containsTagKey("ele")) {
+ elevation = placemark->osmData().tagValue("ele").toInt();
+ }
+ }
+
+ return elevation;
+
+
+}
+
bool GeoPolygonGraphicsItem::isBuilding(GeoDataFeature::GeoDataVisualCategory visualCategory)
{
switch (visualCategory) {
diff --git a/src/lib/marble/geodata/graphicsitem/GeoPolygonGraphicsItem.h b/src/lib/marble/geodata/graphicsitem/GeoPolygonGraphicsItem.h
index cf2c100..4a77411 100644
--- a/src/lib/marble/geodata/graphicsitem/GeoPolygonGraphicsItem.h
+++ b/src/lib/marble/geodata/graphicsitem/GeoPolygonGraphicsItem.h
@@ -48,6 +48,7 @@ private:
void paintRoof( GeoPainter* painter, const ViewportParams *viewport );
QPointF buildingOffset(const QPointF &point, const ViewportParams *viewport, bool* isCameraAboveBuilding=0) const;
+ int extractBathymetryElevation(const GeoDataFeature *feature);
static double extractBuildingHeight(const GeoDataFeature *feature);
static QString extractBuildingLabel(const GeoDataFeature *feature);
static QVector<NamedEntry> extractNamedEntries(const GeoDataFeature *feature);
diff --git a/src/lib/marble/layers/GeometryLayer.cpp b/src/lib/marble/layers/GeometryLayer.cpp
index a36c067..947ddfe 100644
--- a/src/lib/marble/layers/GeometryLayer.cpp
+++ b/src/lib/marble/layers/GeometryLayer.cpp
@@ -242,7 +242,9 @@ void GeometryLayerPrivate::createGraphicsItemFromGeometry(const GeoDataGeometry*
const GeoDataPolygon *poly = static_cast<const GeoDataPolygon*>( object );
item = new GeoPolygonGraphicsItem( placemark, poly );
- item->setZValue(poly->renderOrder());
+ if (item->zValue() == 0) {
+ item->setZValue(poly->renderOrder());
+ }
}
else if ( object->nodeType() == GeoDataTypes::GeoDataMultiGeometryType )
{
diff --git a/src/plugins/runner/osm/OsmRelation.cpp b/src/plugins/runner/osm/OsmRelation.cpp
index 2193899..6a2a88f 100644
--- a/src/plugins/runner/osm/OsmRelation.cpp
+++ b/src/plugins/runner/osm/OsmRelation.cpp
@@ -114,6 +114,16 @@ void OsmRelation::create(GeoDataDocument *document, const OsmWays &ways, const O
// @todo: How to get the reference here?
// placemark->osmData().addMemberReference(-1, );
+ if (placemark->visualCategory() == GeoDataFeature::Bathymetry) {
+ // In case of a bathymetry store elevation info since it is required during styling
+ // The ele=* tag is present in the outermost way
+ OsmPlacemarkData outerWayData = ways[*outerWays.begin()].osmData();
+ if (outerWayData.containsTagKey("ele")) {
+ QString value = outerWayData.tagValue("ele");
+ placemark->osmData().addTag("ele", value);
+ }
+ }
+
QStringList const innerRoles = QStringList() << "inner";
QSet<qint64> innerWays;
QList<GeoDataLinearRing> inner = rings(innerRoles, ways, nodes, usedNodes, innerWays);
diff --git a/tools/shp2osm/polyshp2osm.py b/tools/shp2osm/polyshp2osm.py
index fa9e8cf..9b88472 100644
--- a/tools/shp2osm/polyshp2osm.py
+++ b/tools/shp2osm/polyshp2osm.py
@@ -274,7 +274,7 @@ def feature_class(data):
'Claim': [('boundary', 'administrative'), ('admin_level', '4')],
'Airport': [('aeroway', 'aerodrome')],
'Date line': [('marble_line', 'date')],
- 'Bathymetry': [('marble:feature', 'bathymetry'), ('depth', data['depth'])]
+ 'Bathymetry': [('marble:feature', 'bathymetry'), ('ele', data['depth'])]
}
if 'featurecla' in data:
if data['featurecla'] in feat_dict: