Skip to content

Commit

Permalink
Moved GML import/export to a new class: QgsOgcUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Mar 7, 2013
1 parent 290f8fd commit 969df01
Show file tree
Hide file tree
Showing 17 changed files with 1,166 additions and 1,041 deletions.
1 change: 1 addition & 0 deletions python/core/core.sip
Expand Up @@ -47,6 +47,7 @@
%Include qgsmimedatautils.sip
%Include qgsnetworkaccessmanager.sip
%Include qgsofflineediting.sip
%Include qgsogcutils.sip
%Include qgsoverlayobject.sip
%Include qgsowsconnection.sip
%Include qgspaintenginehack.sip
Expand Down
12 changes: 0 additions & 12 deletions python/core/qgsgeometry.sip
Expand Up @@ -41,18 +41,6 @@ class QgsGeometry
/** static method that creates geometry from Wkt */
static QgsGeometry* fromWkt( QString wkt ) /Factory/;

/** static method that creates geometry from GML2
@param XML representation of the geometry. GML elements are expected to be
in default namespace (<Point>...</Point>) or in "gml" namespace (<gml:Point>...</gml:Point>)
@note added in 1.9
*/
static QgsGeometry* fromGML2( const QString& xmlString ) /Factory/;

/** static method that creates geometry from GML2
@note added in 1.9
*/
static QgsGeometry* fromGML2( const QDomNode& geometryNode ) /Factory/;

/** construct geometry from a point */
static QgsGeometry* fromPoint( const QgsPoint& point ) /Factory/;
/** construct geometry from a multipoint */
Expand Down
32 changes: 32 additions & 0 deletions python/core/qgsogcutils.sip
@@ -0,0 +1,32 @@


class QgsOgcUtils
{
%TypeHeaderCode
#include <qgsogcutils.h>
%End

public:

/** static method that creates geometry from GML2
@param XML representation of the geometry. GML elements are expected to be
in default namespace (<Point>...</Point>) or in "gml" namespace (<gml:Point>...</gml:Point>)
@note added in 1.9
*/
static QgsGeometry* geometryFromGML2( const QString& xmlString ) /Factory/;

/** static method that creates geometry from GML2
@note added in 1.9
*/
static QgsGeometry* geometryFromGML2( const QDomNode& geometryNode ) /Factory/;

/** Exports the geometry to mGML2
@return true in case of success and false else
*/
static QDomElement geometryToGML2( QgsGeometry* geometry, QDomDocument& doc );

/** read rectangle from GML2 Box */
static QgsRectangle rectangleFromGMLBox( const QDomNode& boxNode );

};

2 changes: 2 additions & 0 deletions src/core/CMakeLists.txt
Expand Up @@ -86,6 +86,7 @@ SET(QGIS_CORE_SRCS
qgsnetworkreplyparser.cpp
qgscredentials.cpp
qgsofflineediting.cpp
qgsogcutils.cpp
qgsoverlayobject.cpp
qgsowsconnection.cpp
qgspalgeometry.cpp
Expand Down Expand Up @@ -404,6 +405,7 @@ SET(QGIS_CORE_HDRS
qgsnetworkreplyparser.h
qgscredentials.h
qgsofflineediting.h
qgsogcutils.h
qgsoverlayobjectpositionmanager.h
qgsowsconnection.h
qgspallabeling.h
Expand Down
10 changes: 5 additions & 5 deletions src/core/qgsexpression.cpp
Expand Up @@ -28,6 +28,7 @@
#include "qgsfeature.h"
#include "qgsgeometry.h"
#include "qgslogger.h"
#include "qgsogcutils.h"

// from parser
extern QgsExpression::Node* parseExpression( const QString& str, QString& parserErrorMsg );
Expand Down Expand Up @@ -796,7 +797,7 @@ static QVariant fcnGeomFromWKT( const QVariantList& values, QgsFeature*, QgsExpr
static QVariant fcnGeomFromGML2( const QVariantList& values, QgsFeature*, QgsExpression* parent )
{
QString gml = getStringValue( values.at( 0 ), parent );
QgsGeometry* geom = QgsGeometry::fromGML2( gml );
QgsGeometry* geom = QgsOgcUtils::geometryFromGML2( gml );

if ( geom )
return QVariant::fromValue( *geom );
Expand Down Expand Up @@ -2268,11 +2269,10 @@ void QgsExpression::NodeFunction::toOgcFilter( QDomDocument &doc, QDomElement &e
{
if ( childElem.attribute( "name" ) == "geomFromWKT" )
{
QgsGeometry* geom = 0;
geom = QgsGeometry::fromWkt( childElem.firstChildElement().text() );
QgsGeometry* geom = QgsGeometry::fromWkt( childElem.firstChildElement().text() );
if ( geom )
funcElem.appendChild( geom->exportToGML2( doc ) );

funcElem.appendChild( QgsOgcUtils::geometryToGML2( geom, doc ) );
delete geom;
}
else if ( childElem.attribute( "name" ) == "geomFromGML2" )
{
Expand Down

0 comments on commit 969df01

Please sign in to comment.