[Marble-commits] KDE/kdeedu/marble/src

Andrew Manson g.real.ate at gmail.com
Tue Jul 21 15:27:17 CEST 2009


SVN commit 1000505 by mansona:

Adding the ability to render Osm Ways directly onto the map. 



 M  +5 -0      lib/geodata/graphicsitem/GeoLineStringGraphicsItem.cpp  
 M  +1 -0      lib/geodata/graphicsitem/GeoLineStringGraphicsItem.h  
 M  +5 -0      lib/geodata/graphicsitem/GeoPointGraphicsItem.cpp  
 M  +1 -0      lib/geodata/graphicsitem/GeoPointGraphicsItem.h  
 M  +1 -1      lib/geodata/parser/GeoDataParser.cpp  
 M  +4 -4      plugins/render/osmannotate/osm/OsmNdTagHandler.cpp  
 M  +10 -0     plugins/render/osmannotate/osm/OsmNodeGraphicsItem.cpp  
 M  +4 -0      plugins/render/osmannotate/osm/OsmNodeGraphicsItem.h  
 M  +7 -0      plugins/render/osmannotate/osm/OsmNodeTagHandler.cpp  
 M  +4 -0      plugins/render/osmannotate/osm/OsmNodeTagHandler.h  
 M  +19 -0     plugins/render/osmannotate/osm/OsmWayGraphicsItem.cpp  
 M  +3 -0      plugins/render/osmannotate/osm/OsmWayGraphicsItem.h  
 M  +3 -0      plugins/render/osmannotate/osm/OsmWayTagHandler.cpp  


--- trunk/KDE/kdeedu/marble/src/lib/geodata/graphicsitem/GeoLineStringGraphicsItem.cpp #1000504:1000505
@@ -25,6 +25,11 @@
     m_lineString = GeoDataLineString( lineString );
 }
 
+void GeoLineStringGraphicsItem::append( const GeoDataCoordinates& coordinates)
+{
+    m_lineString.append( coordinates );
+}
+
 void GeoLineStringGraphicsItem::paint( GeoPainter* painter, ViewportParams* viewport,
                                        const QString& renderPos, GeoSceneLayer* layer )
 {
--- trunk/KDE/kdeedu/marble/src/lib/geodata/graphicsitem/GeoLineStringGraphicsItem.h #1000504:1000505
@@ -24,6 +24,7 @@
     GeoLineStringGraphicsItem();
 
     void setLineString( const GeoDataLineString& lineString );
+    void append( const GeoDataCoordinates& coordinates );
 
     virtual void paint( GeoPainter* painter, ViewportParams *viewport,
                         const QString &renderPos, GeoSceneLayer *layer );
--- trunk/KDE/kdeedu/marble/src/lib/geodata/graphicsitem/GeoPointGraphicsItem.cpp #1000504:1000505
@@ -25,6 +25,11 @@
     m_point = GeoDataPoint( point );
 }
 
+GeoDataPoint GeoPointGraphicsItem::point()
+{
+    return GeoDataPoint(m_point);
+}
+
 void GeoPointGraphicsItem::paint( GeoPainter* painter, ViewportParams* viewport,
                                   const QString& renderPos, GeoSceneLayer* layer )
 {
--- trunk/KDE/kdeedu/marble/src/lib/geodata/graphicsitem/GeoPointGraphicsItem.h #1000504:1000505
@@ -24,6 +24,7 @@
     GeoPointGraphicsItem();
 
     void setPoint( const GeoDataPoint& point );
+    GeoDataPoint point();
     
     virtual void paint( GeoPainter* painter, ViewportParams *viewport,
                         const QString &renderPos, GeoSceneLayer *layer );
--- trunk/KDE/kdeedu/marble/src/lib/geodata/parser/GeoDataParser.cpp #1000504:1000505
@@ -63,7 +63,7 @@
         return isValidElement(kml::kmlTag_kml);
     case GeoData_OSM:
         //does not have a namespace
-        return true;
+        return isValidElement("osm");
     default:
         Q_ASSERT(false);
         return false;
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/osm/OsmNdTagHandler.cpp #1000504:1000505
@@ -33,13 +33,13 @@
     //FIXME: problem with the stack implementation
 
     //this should be "way"
-    qDebug() << Q_FUNC_INFO;
-    qDebug() << "parent element name:" << parent.first.first;
+//    qDebug() << Q_FUNC_INFO;
+//    qDebug() << "parent element name:" << parent.first.first;
     Q_ASSERT( parent.first.first.compare("way") == 0 );
 
     //this should be set because we know that the containing
     // <way> element did not return 0
-    qDebug() << " parent associated node pointer:" << parent.associatedNode();
+//    qDebug() << " parent associated node pointer:" << parent.associatedNode();
 
     Q_ASSERT( parent.associatedNode() );
 
@@ -52,7 +52,7 @@
     Q_ASSERT( way );
 
     //the line that crashes
-//    way->addNodeReferenceId( parser.attribute("ref").toInt() );
+    way->addNodeReferenceId( parser.attribute("ref").toInt() );
 
     return 0;
 
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/osm/OsmNodeGraphicsItem.cpp #1000504:1000505
@@ -36,5 +36,15 @@
 
 }
 
+void OsmNodeGraphicsItem::setId( int id )
+{
+    m_id = id;
+}
 
+int OsmNodeGraphicsItem::id()
+{
+    return m_id;
 }
+
+
+}
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/osm/OsmNodeGraphicsItem.h #1000504:1000505
@@ -29,9 +29,13 @@
     virtual void paint( GeoPainter* painter, ViewportParams *viewport,
                         const QString &renderPos, GeoSceneLayer *layer );
 
+    void setId( int id );
+    int id();
 
+
 private:
     QPen m_pen;
+    int m_id;
 };
 
 }
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/osm/OsmNodeTagHandler.cpp #1000504:1000505
@@ -14,12 +14,16 @@
 #include "OsmElementDictionary.h"
 #include "OsmNodeGraphicsItem.h"
 
+#include <QtCore/QMap>
+
 namespace Marble
 {
 
 namespace osm
 {
 
+QMap<int, OsmNodeGraphicsItem*> OsmNodeTagHandler::nodeRef;
+
 static GeoTagHandlerRegistrar s_handlerbounds( GeoTagHandler::QualifiedName(osmTag_node, ""),
                                                new OsmNodeTagHandler() );
 
@@ -33,7 +37,10 @@
     qreal lat = parser.attribute("lat").toDouble();
 
     item->setPoint( GeoDataPoint(lon, lat, 0, GeoDataCoordinates::Degree ) );
+    item->setId( parser.attribute("id").toInt() );
 
+    nodeRef.insert( item->id(), item );
+
     parser.activeModel()->append( item );
 
     return 0;
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/osm/OsmNodeTagHandler.h #1000504:1000505
@@ -17,6 +17,8 @@
 namespace Marble
 {
 
+class OsmNodeGraphicsItem;
+
 namespace osm
 {
 
@@ -24,6 +26,8 @@
 {
 public:
     virtual GeoNode* parse(GeoParser&) const;
+
+    static QMap<int, OsmNodeGraphicsItem*> nodeRef;
 };
 
 }
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/osm/OsmWayGraphicsItem.cpp #1000504:1000505
@@ -10,6 +10,13 @@
 
 #include "OsmWayGraphicsItem.h"
 
+#include "GeoPainter.h"
+#include "OsmNodeGraphicsItem.h"
+#include "OsmNodeTagHandler.h"
+
+#include <QtCore/QDebug>
+#include <QtCore/QMap>
+
 namespace Marble
 {
 
@@ -21,6 +28,18 @@
 void OsmWayGraphicsItem::addNodeReferenceId( int reference )
 {
     m_nodeIdList.append( reference );
+    if( osm::OsmNodeTagHandler::nodeRef.contains( reference ) ) {
+        append( osm::OsmNodeTagHandler::nodeRef.value( reference )->point() );
+    }
 }
 
+void OsmWayGraphicsItem::paint( GeoPainter* painter, ViewportParams* viewport,
+                                const QString& renderPos, GeoSceneLayer* layer )
+{
+    painter->save();
+    painter->setPen( Qt::black );
+    painter->drawPolyline( m_lineString );
+    painter->restore();
 }
+
+}
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/osm/OsmWayGraphicsItem.h #1000504:1000505
@@ -30,6 +30,9 @@
      */
     void addNodeReferenceId( int reference );
 
+    virtual void paint( GeoPainter* painter, ViewportParams *viewport,
+                        const QString &renderPos, GeoSceneLayer *layer );
+
 private:
     QList<int> m_nodeIdList;
 };
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/osm/OsmWayTagHandler.cpp #1000504:1000505
@@ -28,6 +28,9 @@
 {
     GeoNode* result;
     OsmWayGraphicsItem* way = new OsmWayGraphicsItem();
+
+    parser.activeModel()->append(way);
+
     result = reinterpret_cast<GeoNode*>(way);
     Q_ASSERT( result );
     return result;


More information about the Marble-commits mailing list