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

Andrew Manson g.real.ate at gmail.com
Tue Jul 28 20:07:10 CEST 2009


SVN commit 1003737 by mansona:

BUG:201681 fixed 
The problem with crashing has been ammended by Torsten. The APIDOX have been ammended 
to discourage incorrect usage of the centerOn(GeoDataCoordinates) method and the 
centerOn(GeoDataLatLonBox) method has been finished. 
Also committing the start of the XML writer classes. 


 M  +10 -6     lib/MarbleWidget.cpp  
 M  +10 -5     lib/MarbleWidget.h  
 M  +1 -0      lib/geodata/CMakeLists.txt  
 A             lib/geodata/writer (directory)  
 A             lib/geodata/writer/GeoWriter.cpp   [License: LGPL]
 A             lib/geodata/writer/GeoWriter.h   [License: LGPL]
 M  +11 -6     plugins/render/osmannotate/OsmAnnotatePlugin.cpp  
 M  +3 -0      plugins/render/osmannotate/OsmAnnotatePlugin.h  


--- trunk/KDE/kdeedu/marble/src/lib/MarbleWidget.cpp #1003736:1003737
@@ -595,19 +595,23 @@
 
 void MarbleWidget::centerOn( const GeoDataLatLonBox &box, bool animated )
 {
-    //FIXME: actually centerOn the middle of the bounding box once BUG:201681 is fixed
-    qDebug() << Q_FUNC_INFO;
-    qDebug() << "Centering on: " << box.center().toString();
-
+    //work out the needed zoom level
     ViewportParams* viewparams = d->m_map->viewParams()->viewport();
     int maxScreenSize = viewparams->height() > viewparams->width() ?
                      viewparams->height() : viewparams->width();
 
     qreal maxBoundingSize = box.height() > box.width() ? box.height() : box.width();
 
-    int zoomRadius = ( 0.25 * M_PI ) * ( maxScreenSize / maxBoundingSize );
+    //prevent devide by zero
+    if( maxBoundingSize ) {
+        int zoomRadius = ( 0.25 * M_PI ) * ( maxScreenSize / maxBoundingSize );
+        setRadius( zoomRadius );
+    }
 
-    setRadius( zoomRadius );
+    //move the map
+    d->m_map->centerOn( box.center().longitude( GeoDataCoordinates::Degree ),
+                        box.center().latitude( GeoDataCoordinates::Degree ) );
+
     repaint();
 }
 
--- trunk/KDE/kdeedu/marble/src/lib/MarbleWidget.h #1003736:1003737
@@ -611,9 +611,9 @@
 
     /**
      * @brief  Center the view on a geographical point
-     * @param  lat  an angle parallel to the latitude lines
+     * @param  lat  an angle in degrees parallel to the latitude lines
      *              +90(N) - -90(S)
-     * @param  lon  an angle parallel to the longitude lines
+     * @param  lon  an angle in degrees parallel to the longitude lines
      *              +180(W) - -180(E)
      */
     void  centerOn( const qreal &lon, const qreal &lat, bool animated = false );
@@ -626,8 +626,13 @@
 
     /**
      * @brief  Center the view on a point
-     * @param  point the point above earth from which the view can be seen
-     *               by looking vertically down.
+     * This method centers the Marble map on the point described by the latitude
+     * and longitude in the GeoDataCoordinate paramerter @c point. It also zooms
+     * the map to be at the elevation described by the altitude. If this is
+     * not the desired functionality or you do not have an accurate altitude
+     * then use @see centerOn(qreal, qreal, bool)
+     * @param point the point in 3 dimensions above the globe to move the view
+     *              to. It will always be looking vertically down.
      */
     void  centerOn( const GeoDataCoordinates &point, bool animated = false );
 
@@ -635,7 +640,7 @@
      * @brief Center the view on a bounding box so that it completley fills the viewport
      * This method not only centers on the center of the GeoDataLatLon box but it also
      * adjusts the zoom of the marble widget so that the LatLon box provided fills
-     * the viewport
+     * the viewport.
      * @param box The GeoDataLatLonBox to zoom and move the MarbleWidget to.
      */
     void centerOn( const GeoDataLatLonBox& box, bool animated = false );
--- trunk/KDE/kdeedu/marble/src/lib/geodata/CMakeLists.txt #1003736:1003737
@@ -9,6 +9,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_writer_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} geodata/writer/*.cpp )
 
 FILE( GLOB geodata_data_HDRS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} geodata/data/*.h )
 
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/OsmAnnotatePlugin.cpp #1003736:1003737
@@ -29,6 +29,16 @@
 namespace Marble
 {
 
+OsmAnnotatePlugin::OsmAnnotatePlugin()
+        : RenderPlugin()
+{
+
+}
+
+OsmAnnotatePlugin::~OsmAnnotatePlugin()
+{
+}
+
 QStringList OsmAnnotatePlugin::backendTypes() const
 {
     return QStringList( "osmannotation" );
@@ -203,15 +213,10 @@
         // now zoom to the newly added OSM file
         if( m_itemModel->size() > 0 ) {
             OsmBoundsGraphicsItem* item;
-            // mostly guarenteed that the first item will be a bounds item
+            // mostly guaranteed that the first item will be a bounds item
             // if not then don't centre on anything
             item = dynamic_cast<OsmBoundsGraphicsItem*>( m_itemModel->first() );
             if( item ) {
-                // FIXME: uncomment this line if you would like to recreate the
-                // crash in BUG:201681
-//                m_marbleWidget->centerOn( item->coordinate(), false );
-                //get the zoom level
-                // difficult?
                 m_marbleWidget->centerOn( item->latLonBox() );
             }
         }
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/OsmAnnotatePlugin.h #1003736:1003737
@@ -41,6 +41,9 @@
     MARBLE_PLUGIN( OsmAnnotatePlugin )
 
  public:
+    OsmAnnotatePlugin();
+    virtual ~OsmAnnotatePlugin();
+
     QStringList backendTypes() const;
 
     QString renderPolicy() const;


More information about the Marble-commits mailing list