Skip to content

Commit 969df01

Browse files
committed
Moved GML import/export to a new class: QgsOgcUtils
1 parent 290f8fd commit 969df01

File tree

17 files changed

+1166
-1041
lines changed

17 files changed

+1166
-1041
lines changed

python/core/core.sip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
%Include qgsmimedatautils.sip
4848
%Include qgsnetworkaccessmanager.sip
4949
%Include qgsofflineediting.sip
50+
%Include qgsogcutils.sip
5051
%Include qgsoverlayobject.sip
5152
%Include qgsowsconnection.sip
5253
%Include qgspaintenginehack.sip

python/core/qgsgeometry.sip

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,6 @@ class QgsGeometry
4141
/** static method that creates geometry from Wkt */
4242
static QgsGeometry* fromWkt( QString wkt ) /Factory/;
4343

44-
/** static method that creates geometry from GML2
45-
@param XML representation of the geometry. GML elements are expected to be
46-
in default namespace (<Point>...</Point>) or in "gml" namespace (<gml:Point>...</gml:Point>)
47-
@note added in 1.9
48-
*/
49-
static QgsGeometry* fromGML2( const QString& xmlString ) /Factory/;
50-
51-
/** static method that creates geometry from GML2
52-
@note added in 1.9
53-
*/
54-
static QgsGeometry* fromGML2( const QDomNode& geometryNode ) /Factory/;
55-
5644
/** construct geometry from a point */
5745
static QgsGeometry* fromPoint( const QgsPoint& point ) /Factory/;
5846
/** construct geometry from a multipoint */

python/core/qgsogcutils.sip

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
3+
class QgsOgcUtils
4+
{
5+
%TypeHeaderCode
6+
#include <qgsogcutils.h>
7+
%End
8+
9+
public:
10+
11+
/** static method that creates geometry from GML2
12+
@param XML representation of the geometry. GML elements are expected to be
13+
in default namespace (<Point>...</Point>) or in "gml" namespace (<gml:Point>...</gml:Point>)
14+
@note added in 1.9
15+
*/
16+
static QgsGeometry* geometryFromGML2( const QString& xmlString ) /Factory/;
17+
18+
/** static method that creates geometry from GML2
19+
@note added in 1.9
20+
*/
21+
static QgsGeometry* geometryFromGML2( const QDomNode& geometryNode ) /Factory/;
22+
23+
/** Exports the geometry to mGML2
24+
@return true in case of success and false else
25+
*/
26+
static QDomElement geometryToGML2( QgsGeometry* geometry, QDomDocument& doc );
27+
28+
/** read rectangle from GML2 Box */
29+
static QgsRectangle rectangleFromGMLBox( const QDomNode& boxNode );
30+
31+
};
32+

src/core/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ SET(QGIS_CORE_SRCS
8686
qgsnetworkreplyparser.cpp
8787
qgscredentials.cpp
8888
qgsofflineediting.cpp
89+
qgsogcutils.cpp
8990
qgsoverlayobject.cpp
9091
qgsowsconnection.cpp
9192
qgspalgeometry.cpp
@@ -404,6 +405,7 @@ SET(QGIS_CORE_HDRS
404405
qgsnetworkreplyparser.h
405406
qgscredentials.h
406407
qgsofflineediting.h
408+
qgsogcutils.h
407409
qgsoverlayobjectpositionmanager.h
408410
qgsowsconnection.h
409411
qgspallabeling.h

src/core/qgsexpression.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "qgsfeature.h"
2929
#include "qgsgeometry.h"
3030
#include "qgslogger.h"
31+
#include "qgsogcutils.h"
3132

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

801802
if ( geom )
802803
return QVariant::fromValue( *geom );
@@ -2268,11 +2269,10 @@ void QgsExpression::NodeFunction::toOgcFilter( QDomDocument &doc, QDomElement &e
22682269
{
22692270
if ( childElem.attribute( "name" ) == "geomFromWKT" )
22702271
{
2271-
QgsGeometry* geom = 0;
2272-
geom = QgsGeometry::fromWkt( childElem.firstChildElement().text() );
2272+
QgsGeometry* geom = QgsGeometry::fromWkt( childElem.firstChildElement().text() );
22732273
if ( geom )
2274-
funcElem.appendChild( geom->exportToGML2( doc ) );
2275-
2274+
funcElem.appendChild( QgsOgcUtils::geometryToGML2( geom, doc ) );
2275+
delete geom;
22762276
}
22772277
else if ( childElem.attribute( "name" ) == "geomFromGML2" )
22782278
{

0 commit comments

Comments
 (0)