[Marble-commits] KDE/kdeedu/marble/src/lib/geodata/data
Thibaut Gridel
tgridel at free.fr
Sat Jan 15 14:35:04 CET 2011
SVN commit 1214594 by tgridel:
GeoDataPlacemark: drop internal GeoDataCoordinates and use geometry always
M +12 -17 GeoDataPlacemark.cpp
M +1 -3 GeoDataPlacemark_p.h
--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataPlacemark.cpp #1214593:1214594
@@ -29,20 +29,20 @@
GeoDataPlacemark::GeoDataPlacemark()
: GeoDataFeature( new GeoDataPlacemarkPrivate )
{
- p()->m_coordinate.setParent( this );
+ p()->m_geometry->setParent( this );
}
GeoDataPlacemark::GeoDataPlacemark( const GeoDataPlacemark& other )
: GeoDataFeature( other )
{
- p()->m_coordinate.setParent( this );
+ p()->m_geometry->setParent( this );
}
GeoDataPlacemark::GeoDataPlacemark( const QString& name )
: GeoDataFeature( new GeoDataPlacemarkPrivate )
{
d->m_name = name;
- p()->m_coordinate.setParent( this );
+ p()->m_geometry->setParent( this );
}
GeoDataPlacemark::~GeoDataPlacemark()
@@ -66,10 +66,7 @@
GeoDataGeometry* GeoDataPlacemark::geometry() const
{
- if( p()->m_geometry )
return p()->m_geometry;
- else
- return &( p()->m_coordinate );
}
GeoDataLookAt *GeoDataPlacemark::lookAt() const
@@ -85,11 +82,15 @@
GeoDataCoordinates GeoDataPlacemark::coordinate() const
{
if( p()->m_geometry ) {
+ if ( p()->m_geometry->geometryId() != GeoDataPointId ) {
return p()->m_geometry->latLonAltBox().center();
} else {
- return static_cast<GeoDataCoordinates>( p()->m_coordinate );
+ return GeoDataCoordinates( *static_cast<GeoDataPoint*>( p()->m_geometry ) );
}
+ } else {
+ return GeoDataCoordinates();
}
+}
void GeoDataPlacemark::coordinate( qreal& lon, qreal& lat, qreal& alt ) const
{
@@ -102,23 +103,19 @@
coord.geoCoordinates( lon, lat );
alt = coord.altitude();
} else {
- p()->m_coordinate.geoCoordinates( lon, lat );
- alt = p()->m_coordinate.altitude();
+ static_cast<GeoDataPoint*>(p()->m_geometry)->geoCoordinates( lon, lat );
+ alt = static_cast<GeoDataPoint*>(p()->m_geometry)->altitude();
}
}
void GeoDataPlacemark::setCoordinate( qreal lon, qreal lat, qreal alt, GeoDataPoint::Unit _unit)
{
- detach();
- p()->m_coordinate = GeoDataPoint( lon, lat, alt, _unit );
- p()->m_coordinate.setParent( this );
+ setGeometry( new GeoDataPoint(lon, lat, alt, _unit ) );
}
void GeoDataPlacemark::setCoordinate( const GeoDataPoint &point )
{
- detach();
- p()->m_coordinate = GeoDataPoint( point );
- p()->m_coordinate.setParent( this );
+ setGeometry ( new GeoDataPoint( point ) );
}
void GeoDataPlacemark::setGeometry( GeoDataGeometry *entry )
@@ -189,7 +186,6 @@
{
stream << InvalidGeometryId;
}
- p()->m_coordinate.pack( stream );
}
QXmlStreamWriter& GeoDataPlacemark::pack( QXmlStreamWriter& stream ) const
@@ -263,7 +259,6 @@
break;
default: break;
};
- p()->m_coordinate.unpack( stream );
}
}
--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataPlacemark_p.h #1214593:1214594
@@ -22,7 +22,7 @@
{
public:
GeoDataPlacemarkPrivate()
- : m_geometry( 0 ),
+ : m_geometry( new GeoDataPoint ),
m_area( -1.0 ),
m_population( -1 ),
m_lookAt( 0 )
@@ -67,7 +67,6 @@
delete m_geometry;
m_geometry = geometry;
- m_coordinate = other.m_coordinate;
m_countrycode = other.m_countrycode;
m_area = other.m_area;
m_population = other.m_population;
@@ -97,7 +96,6 @@
// Data for a Placemark in addition to those in GeoDataFeature.
GeoDataGeometry *m_geometry; // any GeoDataGeometry entry like locations
- GeoDataPoint m_coordinate; // The geographic position
QString m_countrycode; // Country code.
qreal m_area; // Area in square kilometer
qint64 m_population; // population in number of inhabitants
More information about the Marble-commits
mailing list