marble
Go to the documentation of this file.
26 needAnotherPass =
false;
28 QXmlSimpleReader xmlReader;
29 xmlReader.setContentHandler(
this );
30 xmlReader.setErrorHandler(
this );
32 QFile file( content.absoluteFilePath() );
33 QXmlInputSource *source =
new QXmlInputSource( &file );
35 if ( !xmlReader.parse( source ) ) {
36 qCritical() <<
"Failed to parse " << content.absoluteFilePath();
43 bool XmlParser::startElement (
const QString & ,
const QString & ,
const QString & qName,
const QXmlAttributes & atts )
45 if ( qName ==
"node" ) {
47 m_id = atts.value(
"id" ).toInt();
48 m_node.
lon = atts.value(
"lon" ).toFloat();
49 m_node.
lat = atts.value(
"lat" ).toFloat();
51 }
else if ( qName ==
"way" ) {
52 m_id = atts.value(
"id" ).toInt();
55 }
else if ( qName ==
"nd" ) {
56 m_way.
nodes.push_back( atts.value(
"ref" ).toInt() );
57 }
else if ( qName ==
"relation" ) {
58 m_id = atts.value(
"id" ).toInt();
59 m_relation = Relation();
60 m_relation.
nodes.clear();
62 }
else if ( qName ==
"member" ) {
63 if ( atts.value(
"type" ) ==
"node" ) {
64 m_relation.
nodes.push_back( atts.value(
"ref" ).toInt() );
65 }
else if ( atts.value(
"type" ) ==
"way" ) {
67 if ( atts.value(
"role" ) ==
"outer" ) role =
Outer;
68 if ( atts.value(
"role" ) ==
"inner" ) role =
Inner;
69 m_relation.
ways.push_back( QPair<int, RelationRole>( atts.value(
"ref" ).toInt(), role ) );
70 }
else if ( atts.value(
"type" ) ==
"relation" ) {
71 m_relation.
relations.push_back( atts.value(
"ref" ).toInt() );
73 qDebug() <<
"Unknown relation member type " << atts.value(
"type" );
75 }
else if ( qName ==
"tag" && m_element ==
RelationType ) {
76 if ( atts.value(
"k" ) ==
"boundary" && atts.value(
"v" ) ==
"administrative" ) {
78 }
else if ( atts.value(
"k" ) ==
"admin_level" ) {
79 m_relation.
adminLevel = atts.value(
"v" ).toInt();
80 }
else if ( atts.value(
"k" ) ==
"name" ) {
81 m_relation.
name = atts.value(
"v" );
82 }
else if ( atts.value(
"k" ) ==
"type" && atts.value(
"v" ) ==
"multipolygon" ) {
85 }
else if ( qName ==
"tag" && m_element ==
WayType ) {
86 QString
const key = atts.value(
"k" );
87 QString
const value = atts.value(
"v" );
88 if ( key ==
"name" ) {
90 }
else if ( key ==
"addr:street" ) {
93 }
else if ( key ==
"addr:housenumber" ) {
96 }
else if ( key ==
"addr:city" ) {
99 }
else if ( key ==
"building" && value ==
"yes" ) {
107 }
else if ( qName ==
"tag" && m_element ==
NodeType ) {
108 QString
const key = atts.value(
"k" );
109 QString
const value = atts.value(
"v" );
110 if ( key ==
"name" ) {
112 }
else if ( key ==
"addr:street" ) {
115 }
else if ( key ==
"addr:housenumber" ) {
118 }
else if ( key ==
"addr:city" ) {
132 bool XmlParser::endElement (
const QString & ,
const QString & ,
const QString & qName )
134 if ( qName ==
"node" ) {
136 }
else if ( qName ==
"way" ) {
138 }
else if ( qName ==
"relation" ) {
147 #include "XmlParser.moc"
virtual bool parse(const QFileInfo &file, int pass, bool &needAnotherPass)
void setCategory(Element &element, const QString &key, const QString &value)
QHash< int, Relation > m_relations
QList< QPair< int, RelationRole > > ways
bool shouldSave(ElementType type, const QString &key, const QString &value)
XmlParser(QObject *parent=0)
QHash< int, Node > m_nodes
bool isAdministrativeBoundary
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:53 by
doxygen 1.8.7 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.