[Marble-commits] KDE/kdeedu/marble/src
Andrew Manson
g.real.ate at gmail.com
Mon Jul 27 14:40:59 CEST 2009
SVN commit 1002969 by mansona:
The OSM Way data structure is now a GeoDataPlacemark as per request ;)
M +14 -5 lib/geodata/data/GeoDataPlacemark.h
M +22 -3 plugins/render/osmannotate/osm/OsmWayGraphicsItem.cpp
M +14 -4 plugins/render/osmannotate/osm/OsmWayGraphicsItem.h
--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataPlacemark.h #1002968:1002969
@@ -39,6 +39,11 @@
* mountain. It is filled with data by the KML or GPX loader and the
* PlacemarkModel makes use of it.
*
+ * A Placemark can have an associated geometry which will be rendered to the map
+ * along with the placemark's point icon. If you would like to render more than
+ * one geometry for any one placemark than use @see setGeometry() to set add a
+ * @see MultiGeometry.
+ *
* This is more or less only a GeoDataFeature with a geographic
* position and a country code attached to it. The country code is
* not provided in a KML file.
@@ -84,8 +89,10 @@
GeoDataCoordinates coordinate() const;
/**
- * Return a pointer to the current Geometry object
- */
+ * The geometry of the GeoDataPlacemark is to be rendered to the marble map
+ * along with the icon at the coordinate associated with this Placemark.
+ * @return a pointer to the current Geometry object
+ */
GeoDataGeometry* geometry() const;
/**
@@ -106,9 +113,11 @@
void setCoordinate( const GeoDataPoint &point );
/**
- * Set any kind of @p GeoDataGeometry like @p GeoDataPoint ,
- * @p GeoDataLineString , @p GeoDataLinearRing , @p GeoDataMultiGeometry
- */
+ * Sets the current Geometry of this Placmark. @see geometry() and the class
+ * overview for description of the geometry consept. The geometry can be set
+ * to any @see GeoDataGeometry like @see GeoDataPoint, at see GeoDataLineString,
+ * @see GeoDataLinearRing and @see GeoDataMultiGeometry
+ */
void setGeometry( const GeoDataPoint& entry );
void setGeometry( const GeoDataLineString& entry );
void setGeometry( const GeoDataLinearRing& entry );
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/osm/OsmWayGraphicsItem.cpp #1002968:1002969
@@ -10,6 +10,7 @@
#include "OsmWayGraphicsItem.h"
+#include "GeoDataPlacemark.h"
#include "GeoPainter.h"
#include "OsmNodeGraphicsItem.h"
#include "OsmNodeTagHandler.h"
@@ -21,13 +22,19 @@
{
OsmWayGraphicsItem::OsmWayGraphicsItem()
- : GeoLineStringGraphicsItem()
+ : GeoGraphicsItem()
{
+ m_placemark = new GeoDataPlacemark();
+ m_placemark->setGeometry( GeoDataLineString() );
}
+OsmWayGraphicsItem::~OsmWayGraphicsItem()
+{
+ delete m_placemark;
+}
+
void OsmWayGraphicsItem::addNodeReferenceId( int reference )
{
- m_nodeIdList.append( reference );
if( osm::OsmNodeTagHandler::nodeRef.contains( reference ) ) {
OsmNodeGraphicsItem* node = osm::OsmNodeTagHandler::nodeRef.value( reference );
append( node->point() );
@@ -37,12 +44,24 @@
}
}
+void OsmWayGraphicsItem::append( const GeoDataPoint& point )
+{
+ GeoDataLineString* line = dynamic_cast<GeoDataLineString*>(m_placemark->geometry());
+ if( line ) {
+ line->append( point );
+ }
+}
+
void OsmWayGraphicsItem::paint( GeoPainter* painter, ViewportParams* viewport,
const QString& renderPos, GeoSceneLayer* layer )
{
painter->save();
+
painter->setPen( Qt::black );
- painter->drawPolyline( m_lineString );
+ if( m_placemark->geometry() ) {
+ painter->drawPolyline( *m_placemark->geometry() );
+ }
+
painter->restore();
}
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/osm/OsmWayGraphicsItem.h #1002968:1002969
@@ -11,15 +11,18 @@
#ifndef OSMWAYGRAPHICSITEM_H
#define OSMWAYGRAPHICSITEM_H
-#include "GeoLineStringGraphicsItem.h"
-#include "marble_export.h"
+#include "GeoGraphicsItem.h"
namespace Marble{
-class OsmWayGraphicsItem : public GeoLineStringGraphicsItem
+class GeoDataPlacemark;
+class GeoDataPoint;
+
+class OsmWayGraphicsItem : public GeoGraphicsItem
{
public:
OsmWayGraphicsItem();
+ virtual ~OsmWayGraphicsItem();
/**
* This method is intended to be used only while parsing OSM files. It allows
@@ -30,11 +33,18 @@
*/
void addNodeReferenceId( int reference );
+ /**
+ * This method is intended to append a @see GeoDataPoint to the internal
+ * data representation of this OSM Way item. This only appends to the end of
+ * the Line String that represents this OSM Way and hense extends its length
+ */
+ void append( const GeoDataPoint& point );
+
virtual void paint( GeoPainter* painter, ViewportParams *viewport,
const QString &renderPos, GeoSceneLayer *layer );
private:
- QList<int> m_nodeIdList;
+ GeoDataPlacemark* m_placemark;
};
}
More information about the Marble-commits
mailing list