[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/marble/marble-gsoc-2009/src
From:       Andrew Manson <g.real.ate () gmail ! com>
Date:       2009-07-01 0:34:04
Message-ID: 1246408444.277173.2754.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 989791 by mansona:

beging the implemtation of the OSM parser with a test load and render of only the
OSM bounding box. 



 M  +2 -0      lib/geodata/CMakeLists.txt  
 A             lib/geodata/handlers/osm (directory)  
 A             lib/geodata/handlers/osm/OsmBoundsTagHandler.cpp   [License: LGPL]
 A             lib/geodata/handlers/osm/OsmBoundsTagHandler.h   [License: LGPL]
 A             lib/geodata/handlers/osm/OsmElementDictionary.cpp   [License: LGPL]
 A             lib/geodata/handlers/osm/OsmElementDictionary.h   [License: LGPL]
 M  +6 -0      lib/geodata/parser/GeoDataParser.cpp  
 M  +2 -1      lib/geodata/parser/GeoDataParser.h  
 M  +10 -0     plugins/render/osmannotate/GeoWidgetBubble.cpp  
 M  +10 -0     plugins/render/osmannotate/GeoWidgetBubble.h  
 M  +59 -2     plugins/render/osmannotate/OsmAnnotatePlugin.cpp  
 M  +5 -0      plugins/render/osmannotate/OsmAnnotatePlugin.h  
 M  +1 -3      plugins/render/osmannotate/TextAnnotation.cpp  
 M  +10 -0     plugins/render/osmannotate/TextEditor.cpp  
 M  +10 -0     plugins/render/osmannotate/TextEditor.h  


--- branches/marble/marble-gsoc-2009/src/lib/geodata/CMakeLists.txt #989790:989791
@@ -8,6 +8,7 @@
 FILE( GLOB geodata_scene_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} \
geodata/scene/*.cpp )  FILE( GLOB geodata_handlers_dgml_SRCS RELATIVE \
${CMAKE_CURRENT_SOURCE_DIR} geodata/handlers/dgml/*.cpp )  FILE( GLOB \
geodata_handlers_kml_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} \
geodata/handlers/kml/*.cpp ) +FILE( GLOB geodata_handlers_osm_SRCS RELATIVE \
${CMAKE_CURRENT_SOURCE_DIR} geodata/handlers/osm/*.cpp )  
 FILE( GLOB geodata_data_HDRS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} geodata/data/*.h )
 
@@ -41,6 +42,7 @@
         ${geodata_parser_SRCS}
         ${geodata_handlers_gpx_SRCS}
         ${geodata_handlers_kml_SRCS}
+        ${geodata_handlers_osm_SRCS}
         ${geodata_handlers_dgml_SRCS}
         ${geodata_handlers_osmnamefinder_SRCS}
    )
--- branches/marble/marble-gsoc-2009/src/lib/geodata/parser/GeoDataParser.cpp \
#989790:989791 @@ -61,6 +61,9 @@
         return isValidElement(gpx::gpxTag_gpx);
     case GeoData_KML:
         return isValidElement(kml::kmlTag_kml);
+    case GeoData_OSM:
+        //does not have a namespace
+        return true;
     default:
         Q_ASSERT(false);
         return false;
@@ -96,6 +99,9 @@
         return (namespaceUri() == kml::kmlTag_nameSpace20 || 
                 namespaceUri() == kml::kmlTag_nameSpace21 || 
                 namespaceUri() == kml::kmlTag_nameSpace22);
+    case GeoData_OSM:
+        //always "valid" because there is no namespace
+        return true;
     default:
         break;
     }
--- branches/marble/marble-gsoc-2009/src/lib/geodata/parser/GeoDataParser.h \
#989790:989791 @@ -34,7 +34,8 @@
 enum GeoDataSourceType {
     GeoData_GPX    = 0,
     GeoData_KML    = 1,
-    GeoData_GeoRSS = 2
+    GeoData_GeoRSS = 2,
+    GeoData_OSM    = 3
 };
 
 class GEODATA_EXPORT GeoDataParser : public GeoParser {
--- branches/marble/marble-gsoc-2009/src/plugins/render/osmannotate/GeoWidgetBubble.cpp \
#989790:989791 @@ -1,3 +1,13 @@
+//
+// This file is part of the Marble Desktop Globe.
+//
+// This program is free software licensed under the GNU LGPL. You can
+// find a copy of this license in LICENSE.txt in the top directory of
+// the source code.
+//
+// Copyright 2009      Andrew Manson <g.real.ate@gmail.com>
+//
+
 #include "GeoWidgetBubble.h"
 
 #include "GeoPainter.h"
--- branches/marble/marble-gsoc-2009/src/plugins/render/osmannotate/GeoWidgetBubble.h \
#989790:989791 @@ -1,3 +1,13 @@
+//
+// This file is part of the Marble Desktop Globe.
+//
+// This program is free software licensed under the GNU LGPL. You can
+// find a copy of this license in LICENSE.txt in the top directory of
+// the source code.
+//
+// Copyright 2009      Andrew Manson <g.real.ate@gmail.com>
+//
+
 #ifndef GEOWIDGETBUBBLE_H
 #define GEOWIDGETBUBBLE_H
 
--- branches/marble/marble-gsoc-2009/src/plugins/render/osmannotate/OsmAnnotatePlugin.cpp \
#989790:989791 @@ -15,6 +15,7 @@
 #include <QtGui/QRadialGradient>
 #include <QtGui/QPushButton>
 #include <QtGui/QPainterPath>
+#include <QtGui/QFileDialog>
 
 //#include <Phonon/MediaObject>
 //#include <Phonon/VideoWidget>
@@ -25,10 +26,13 @@
 #include "AbstractProjection.h"
 #include "MarbleDirs.h"
 #include "GeoPainter.h"
+#include "GeoDataDocument.h"
 #include "GeoDataCoordinates.h"
 #include "GeoDataLineString.h"
 #include "GeoDataLinearRing.h"
+#include "GeoDataPlacemark.h"
 #include "TextAnnotation.h"
+#include "GeoDataParser.h"
 #include "AreaAnnotation.h"
 #include "MarbleWidget.h"
 
@@ -90,7 +94,7 @@
 
     annon->setCoordinate(madrid);
     
-    //FIXME memory leak withouth a model to do memory managment
+    //FIXME memory leak withouth a model to do memory management
     model.append(annon);
 
     //Attempted to add a video widget as a tech preview but this needs to
@@ -107,6 +111,7 @@
 
     widgetInitalised= false;
     tmp_lineString = 0;
+    m_document = 0;
 }
 
 bool OsmAnnotatePlugin::isInitialized () const
@@ -166,6 +171,16 @@
 //        but->setVisible(false);
 //    }
 
+    //Figure out how to add the data parsed to a scene for rendering
+    //FIXME: this is a terrible hack intended just to test!
+    if( m_document ) {
+        GeoDataPlacemark p(m_document->at(0));
+        GeoDataLinearRing ring(* p.geometry() );
+
+        painter->drawPolygon( ring );
+
+    }
+
     return true;
 }
 
@@ -190,11 +205,47 @@
     }
 }
 
+void OsmAnnotatePlugin::loadOsmFile()
+{
+    QString filename;
+    filename = QFileDialog::getOpenFileName(0, tr("Open File"),
+                            QString(),
+                            tr("All Supported Files (*.osm);;Open Street Map Data \
(*.osm)")); +
+    if ( ! filename.isNull() ) {
+
+        GeoDataParser parser( GeoData_OSM );
+
+        QFile file( filename );
+        if ( !file.exists() ) {
+            qWarning( "File does not exist!" );
+            return;
+        }
+
+        // Open file in right mode
+        file.open( QIODevice::ReadOnly );
+
+        if ( !parser.read( &file ) ) {
+            qWarning( "Could not parse file!" );
+            //do not quit on a failed read!
+            //return
+        }
+        GeoDocument* document = parser.releaseDocument();
+        Q_ASSERT( document );
+
+        m_document = static_cast<GeoDataDocument*>( document );
+
+        file.close();
+
+        qDebug() << "size of container is " << m_document->size();
+    }
+}
+
 bool    OsmAnnotatePlugin::eventFilter(QObject* watched, QEvent* event)
 {
     MarbleWidget* marbleWidget = (MarbleWidget*) watched;
     //FIXME why is the QEvent::MousePress not working? caught somewhere else?
-    //does this mean we need to centralise the event handeling?
+    //does this mean we need to centralise the event handling?
 
     // Catch the mouse button press
     if ( event->type() == QEvent::MouseButtonPress ) {
@@ -296,6 +347,11 @@
     connect( m_drawPolygon, SIGNAL(toggled(bool)),
              this, SLOT(drawPolygon(bool)) );
 
+    m_loadOsmFile = new QAction( this );
+    m_loadOsmFile->setText( "Load Osm File" );
+    connect( m_loadOsmFile, SIGNAL(triggered()),
+             this, SLOT(loadOsmFile()) );
+
     m_beginSeperator = new QAction( this );
     m_beginSeperator->setSeparator( true );
     m_endSeperator = new QAction ( this );
@@ -304,6 +360,7 @@
     widget->registerAction( m_beginSeperator );
     widget->registerAction( m_addPlacemark );
     widget->registerAction( m_drawPolygon );
+    widget->registerAction( m_loadOsmFile );
     widget->registerAction( m_endSeperator );
 
 }
--- branches/marble/marble-gsoc-2009/src/plugins/render/osmannotate/OsmAnnotatePlugin.h \
#989790:989791 @@ -26,6 +26,7 @@
 {
 
     class MarbleWidget;
+    class GeoDataDocument;
 
 /**
  * @short The class that specifies the Marble layer interface of a plugin.
@@ -79,16 +80,20 @@
     QAction*    m_drawLine;
     QAction*    m_beginSeperator;
     QAction*    m_endSeperator;
+    QAction*    m_loadOsmFile;
+
 signals:
     void redraw();
 public slots:
     void drawPolygon(bool);
+    void loadOsmFile();
  protected:
     bool eventFilter(QObject* watched, QEvent* event);
 private:
     void setupActions(MarbleWidget* m);
 
     GeoDataLineString* tmp_lineString;
+    GeoDataDocument* m_document;
 };
 
 }
--- branches/marble/marble-gsoc-2009/src/plugins/render/osmannotate/TextAnnotation.cpp \
#989790:989791 @@ -32,8 +32,6 @@
    //accordingly
    m_textEditor = new TextEditor();
    bubble->setGeoWidget( m_textEditor );
-
-
 }
 
 QRect TextAnnotation::screenBounding()
@@ -74,7 +72,7 @@
     qreal degPix = viewport->angularResolution() * RAD2DEG;
 
     painter->drawEllipse(coordinate(), screenBounding().width(), \
                screenBounding().height(), isGeoProjected());
-    //Would it not be usefull to have a draw latlongbox?
+    //Would it not be useful to have a draw latlongbox?
 //    painter->drawRect(geoBounding());
     qreal north, south, east, west;
 
--- branches/marble/marble-gsoc-2009/src/plugins/render/osmannotate/TextEditor.cpp \
#989790:989791 @@ -1,3 +1,13 @@
+//
+// This file is part of the Marble Desktop Globe.
+//
+// This program is free software licensed under the GNU LGPL. You can
+// find a copy of this license in LICENSE.txt in the top directory of
+// the source code.
+//
+// Copyright 2009      Andrew Manson <g.real.ate@gmail.com>
+//
+
 #include "TextEditor.h"
 
 #include <QtCore/QDebug>
--- branches/marble/marble-gsoc-2009/src/plugins/render/osmannotate/TextEditor.h \
#989790:989791 @@ -1,3 +1,13 @@
+//
+// This file is part of the Marble Desktop Globe.
+//
+// This program is free software licensed under the GNU LGPL. You can
+// find a copy of this license in LICENSE.txt in the top directory of
+// the source code.
+//
+// Copyright 2009      Andrew Manson <g.real.ate@gmail.com>
+//
+
 #ifndef TEXTEDITOR_H
 #define TEXTEDITOR_H
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic