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

List:       kde-commits
Subject:    KDE/kdeedu/marble/src/lib/geodata/data
From:       Thibaut Gridel <tgridel () free ! fr>
Date:       2010-07-17 16:40:57
Message-ID: 20100717164057.65875AC76A () svn ! kde ! org
[Download RAW message or body]

SVN commit 1151064 by tgridel:

Placemark: provide coordinates for all geometries

- combine latLonBoxes with operator+=
- provide virtual latLonAltBox for GeoDataGeometry and give implementation
  for multigeometries as well
- simplify GeoDataPlacemark::coordinates if it has a geometry

 M  +5 -0      GeoDataGeometry.cpp  
 M  +3 -0      GeoDataGeometry.h  
 M  +10 -0     GeoDataLatLonBox.cpp  
 M  +6 -0      GeoDataLatLonBox.h  
 M  +1 -1      GeoDataLineString.h  
 M  +13 -0     GeoDataMultiGeometry.cpp  
 M  +2 -0      GeoDataMultiGeometry.h  
 M  +4 -4      GeoDataPlacemark.cpp  
 M  +1 -1      GeoDataPolygon.h  


--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataGeometry.cpp #1151063:1151064
@@ -143,6 +143,11 @@
     d->m_altitudeMode = altitudeMode;
 }
 
+GeoDataLatLonAltBox GeoDataGeometry::latLonAltBox() const
+{
+    return GeoDataLatLonAltBox();
+}
+
 void GeoDataGeometry::pack( QDataStream& stream ) const
 {
     GeoDataObject::pack( stream );
--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataGeometry.h #1151063:1151064
@@ -28,6 +28,7 @@
 
 class GeoDataPoint;
 class GeoDataPolygon;
+class GeoDataLatLonAltBox;
 class GeoDataLineString; // LinearRing is the same!
 class GeoDataMultiGeometry;
 
@@ -70,6 +71,8 @@
     AltitudeMode altitudeMode() const;
     void setAltitudeMode( const AltitudeMode altitudeMode );
 
+    virtual GeoDataLatLonAltBox latLonAltBox() const;
+
     /// Serialize the contents of the feature to @p stream.
     virtual void pack( QDataStream& stream ) const;
     /// Unserialize the contents of the feature from @p stream.
--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataLatLonBox.cpp \
#1151063:1151064 @@ -473,6 +473,16 @@
     return *this;
 }
 
+GeoDataLatLonBox& GeoDataLatLonBox::operator+=( const GeoDataLatLonBox& other )
+{
+    d->m_north = qMax(d->m_north, other.north());
+    d->m_south = qMin(d->m_south, other.south());
+    d->m_east = qMax(d->m_east, other.east());
+    d->m_west = qMin(d->m_west, other.west());
+    return *this;
+}
+
+
 void GeoDataLatLonBox::pack( QDataStream& stream ) const
 {
     GeoDataObject::pack( stream );
--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataLatLonBox.h #1151063:1151064
@@ -156,6 +156,12 @@
      */
     virtual bool isNull() const;
 
+    /**
+     * @brief Unites this bounding box with the given one.
+     * @return Returns a reference to self.
+     */
+    GeoDataLatLonBox& operator +=( const GeoDataLatLonBox& other) ;
+
     /// Serialize the contents of the feature to @p stream.
     virtual void pack( QDataStream& stream ) const;
     /// Unserialize the contents of the feature from @p stream.
--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataLineString.h #1151063:1151064
@@ -146,7 +146,7 @@
 
     \see GeoDataLatLonAltBox
 */
-    GeoDataLatLonAltBox latLonAltBox() const;
+    virtual GeoDataLatLonAltBox latLonAltBox() const;
 
     
 /*!
--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataMultiGeometry.cpp \
#1151063:1151064 @@ -47,6 +47,19 @@
     return p()->nodeType();
 }
 
+
+GeoDataLatLonAltBox GeoDataMultiGeometry::latLonAltBox() const
+{
+    QVector<GeoDataGeometry*>::const_iterator it = p()->m_vector.constBegin();
+    QVector<GeoDataGeometry*>::const_iterator end = p()->m_vector.constEnd();
+
+    GeoDataLatLonAltBox box( (*it)->latLonAltBox() );
+    for (; it != end; ++it) {
+        box += (*it)->latLonAltBox();
+    }
+    return box;
+}
+
 int GeoDataMultiGeometry::size() const
 {
     return p()->m_vector.size();
--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataMultiGeometry.h \
#1151063:1151064 @@ -41,6 +41,8 @@
     /// Provides type information for downcasting a GeoData
     virtual QString nodeType() const;
 
+    virtual GeoDataLatLonAltBox latLonAltBox() const;
+
     int size() const;
     GeoDataGeometry& at( int pos );
     const GeoDataGeometry& at( int pos ) const;
--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataPlacemark.cpp \
#1151063:1151064 @@ -17,6 +17,8 @@
 // Private
 #include "GeoDataPlacemark_p.h"
 
+#include "GeoDataMultiGeometry.h"
+
 // Qt
 #include <QtCore/QDataStream>
 #include "MarbleDebug.h"
@@ -68,10 +70,8 @@
 
 GeoDataCoordinates GeoDataPlacemark::coordinate() const
 {    
-    if( dynamic_cast<GeoDataLineString*>( p()->m_geometry ) ) {
-        return GeoDataLatLonAltBox::fromLineString( *p()->m_geometry ).center();
-    } else if( dynamic_cast<GeoDataPolygon*>( p()->m_geometry ) ) {
-        return GeoDataLatLonAltBox::fromLineString( \
static_cast<GeoDataPolygon*>(p()->m_geometry)->outerBoundary() ).center(); +    if( \
p()->m_geometry ) { +        return p()->m_geometry->latLonAltBox().center();
     } else {
         return static_cast<GeoDataCoordinates>( p()->m_coordinate );
     }
--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataPolygon.h #1151063:1151064
@@ -148,7 +148,7 @@
 
     \see GeoDataLatLonAltBox
 */
-    GeoDataLatLonAltBox latLonAltBox() const;
+    virtual GeoDataLatLonAltBox latLonAltBox() const;
 
 /*!
     \brief Returns the outer boundary that is represented as a LinearRing.


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

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