Skip to content

Commit 08a82f1

Browse files
committed
Port GML3 improvements to 2.18 branch
1 parent d07968a commit 08a82f1

10 files changed

+69
-69
lines changed

src/core/geometry/qgscompoundcurvev2.cpp

+7-24
Original file line numberDiff line numberDiff line change
@@ -256,33 +256,16 @@ QDomElement QgsCompoundCurveV2::asGML2( QDomDocument& doc, int precision, const
256256

257257
QDomElement QgsCompoundCurveV2::asGML3( QDomDocument& doc, int precision, const QString& ns ) const
258258
{
259-
QDomElement elemCurve = doc.createElementNS( ns, "Curve" );
260-
261-
QDomElement elemSegments = doc.createElementNS( ns, "segments" );
262-
259+
QDomElement compoundCurveElem = doc.createElementNS( ns, "CompositeCurve" );
263260
Q_FOREACH ( const QgsCurveV2* curve, mCurves )
264261
{
265-
if ( dynamic_cast<const QgsLineStringV2*>( curve ) )
266-
{
267-
QgsPointSequenceV2 pts;
268-
curve->points( pts );
269-
270-
QDomElement elemLineStringSegment = doc.createElementNS( ns, "LineStringSegment" );
271-
elemLineStringSegment.appendChild( QgsGeometryUtils::pointsToGML3( pts, doc, precision, ns, is3D() ) );
272-
elemSegments.appendChild( elemLineStringSegment );
273-
}
274-
else if ( dynamic_cast<const QgsCircularStringV2*>( curve ) )
275-
{
276-
QgsPointSequenceV2 pts;
277-
curve->points( pts );
278-
279-
QDomElement elemArcString = doc.createElementNS( ns, "ArcString" );
280-
elemArcString.appendChild( QgsGeometryUtils::pointsToGML3( pts, doc, precision, ns, is3D() ) );
281-
elemSegments.appendChild( elemArcString );
282-
}
262+
QDomElement curveMemberElem = doc.createElementNS( ns, "curveMember" );
263+
QDomElement curveElem = curve->asGML3( doc, precision, ns );
264+
curveMemberElem.appendChild( curveElem );
265+
compoundCurveElem.appendChild( curveMemberElem );
283266
}
284-
elemCurve.appendChild( elemSegments );
285-
return elemCurve;
267+
268+
return compoundCurveElem;
286269
}
287270

288271
QString QgsCompoundCurveV2::asJSON( int precision ) const

src/core/geometry/qgscurvepolygonv2.cpp

+15-7
Original file line numberDiff line numberDiff line change
@@ -320,18 +320,26 @@ QDomElement QgsCurvePolygonV2::asGML3( QDomDocument& doc, int precision, const Q
320320
{
321321
QDomElement elemCurvePolygon = doc.createElementNS( ns, "Polygon" );
322322
QDomElement elemExterior = doc.createElementNS( ns, "exterior" );
323-
QDomElement outerRing = exteriorRing()->asGML2( doc, precision, ns );
324-
outerRing.toElement().setTagName( "LinearRing" );
325-
elemExterior.appendChild( outerRing );
323+
QDomElement curveElem = exteriorRing()->asGML3( doc, precision, ns );
324+
if ( curveElem.tagName() == "LineString" )
325+
{
326+
curveElem.setTagName( "LinearRing" );
327+
}
328+
elemExterior.appendChild( curveElem );
329+
elemCurvePolygon.appendChild( elemExterior );
330+
326331
elemCurvePolygon.appendChild( elemExterior );
327-
QDomElement elemInterior = doc.createElementNS( ns, "interior" );
328332
for ( int i = 0, n = numInteriorRings(); i < n; ++i )
329333
{
330-
QDomElement innerRing = interiorRing( i )->asGML2( doc, precision, ns );
331-
innerRing.toElement().setTagName( "LinearRing" );
334+
QDomElement elemInterior = doc.createElementNS( ns, "interior" );
335+
QDomElement innerRing = interiorRing( i )->asGML3( doc, precision, ns );
336+
if ( innerRing.tagName() == "LineString" )
337+
{
338+
innerRing.setTagName( "LinearRing" );
339+
}
332340
elemInterior.appendChild( innerRing );
341+
elemCurvePolygon.appendChild( elemInterior );
333342
}
334-
elemCurvePolygon.appendChild( elemInterior );
335343
return elemCurvePolygon;
336344
}
337345

src/core/geometry/qgslinestringv2.cpp

+3-8
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,9 @@ QDomElement QgsLineStringV2::asGML3( QDomDocument& doc, int precision, const QSt
209209
QgsPointSequenceV2 pts;
210210
points( pts );
211211

212-
QDomElement elemCurve = doc.createElementNS( ns, "Curve" );
213-
QDomElement elemSegments = doc.createElementNS( ns, "segments" );
214-
QDomElement elemArcString = doc.createElementNS( ns, "LineStringSegment" );
215-
elemArcString.appendChild( QgsGeometryUtils::pointsToGML3( pts, doc, precision, ns, is3D() ) );
216-
elemSegments.appendChild( elemArcString );
217-
elemCurve.appendChild( elemSegments );
218-
219-
return elemCurve;
212+
QDomElement elemLineString = doc.createElementNS( ns, "LineString" );
213+
elemLineString.appendChild( QgsGeometryUtils::pointsToGML3( pts, doc, precision, ns, is3D() ) );
214+
return elemLineString;
220215
}
221216

222217
QString QgsLineStringV2::asJSON( int precision ) const

src/core/geometry/qgsmultilinestringv2.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ QDomElement QgsMultiLineStringV2::asGML2( QDomDocument& doc, int precision, cons
6060

6161
QDomElement QgsMultiLineStringV2::asGML3( QDomDocument& doc, int precision, const QString& ns ) const
6262
{
63-
QDomElement elemMultiCurve = doc.createElementNS( ns, "MultiLineString" );
63+
QDomElement elemMultiCurve = doc.createElementNS( ns, "MultiCurve" );
6464
Q_FOREACH ( const QgsAbstractGeometryV2 *geom, mGeometries )
6565
{
6666
if ( dynamic_cast<const QgsLineStringV2*>( geom ) )

src/server/qgswfsserver.cpp

+16-2
Original file line numberDiff line numberDiff line change
@@ -1993,7 +1993,14 @@ QDomElement QgsWFSServer::createFeatureGML2( QgsFeature* feat, QDomDocument& doc
19931993
delete centroid;
19941994
}
19951995
else
1996-
gmlElem = QgsOgcUtils::geometryToGML( geom, doc, prec );
1996+
{
1997+
QgsAbstractGeometryV2* abstractGeom = geom->geometry();
1998+
if ( abstractGeom )
1999+
{
2000+
gmlElem = abstractGeom->asGML2( doc, prec, "http://www.opengis.net/gml" );
2001+
}
2002+
}
2003+
19972004
if ( !gmlElem.isNull() )
19982005
{
19992006
QgsRectangle box = geom->boundingBox();
@@ -2070,7 +2077,14 @@ QDomElement QgsWFSServer::createFeatureGML3( QgsFeature* feat, QDomDocument& doc
20702077
delete centroid;
20712078
}
20722079
else
2073-
gmlElem = QgsOgcUtils::geometryToGML( geom, doc, "GML3", prec );
2080+
{
2081+
QgsAbstractGeometryV2* abstractGeom = geom->geometry();
2082+
if ( abstractGeom )
2083+
{
2084+
gmlElem = abstractGeom->asGML3( doc, prec, "http://www.opengis.net/gml" );
2085+
}
2086+
}
2087+
20742088
if ( !gmlElem.isNull() )
20752089
{
20762090
QgsRectangle box = geom->boundingBox();

tests/src/core/testqgsgeometry.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -1428,9 +1428,9 @@ void TestQgsGeometry::lineStringV2()
14281428
QCOMPARE( elemToString( exportLineFloat.asGML2( doc, 3 ) ), expectedGML2prec3 );
14291429

14301430
//asGML3
1431-
QString expectedGML3( "<Curve xmlns=\"gml\"><segments xmlns=\"gml\"><LineStringSegment xmlns=\"gml\"><posList xmlns=\"gml\" srsDimension=\"2\">31 32 41 42 51 52</posList></LineStringSegment></segments></Curve>" );
1431+
QString expectedGML3( "<LineString xmlns=\"gml\"><posList xmlns=\"gml\" srsDimension=\"2\">31 32 41 42 51 52</posList></LineString>" );
14321432
QCOMPARE( elemToString( exportLine.asGML3( doc ) ), expectedGML3 );
1433-
QString expectedGML3prec3( "<Curve xmlns=\"gml\"><segments xmlns=\"gml\"><LineStringSegment xmlns=\"gml\"><posList xmlns=\"gml\" srsDimension=\"2\">0.333 0.667 1.333 1.667 2.333 2.667</posList></LineStringSegment></segments></Curve>" );
1433+
QString expectedGML3prec3( "<LineString xmlns=\"gml\"><posList xmlns=\"gml\" srsDimension=\"2\">0.333 0.667 1.333 1.667 2.333 2.667</posList></LineString>" );
14341434
QCOMPARE( elemToString( exportLineFloat.asGML3( doc, 3 ) ), expectedGML3prec3 );
14351435

14361436
//asJSON
@@ -2934,11 +2934,11 @@ void TestQgsGeometry::polygonV2()
29342934
QCOMPARE( elemToString( exportPolygonFloat.asGML2( doc, 3 ) ), expectedGML2prec3 );
29352935

29362936
//as GML3
2937-
QString expectedGML3( "<Polygon xmlns=\"gml\"><exterior xmlns=\"gml\"><LinearRing xmlns=\"gml\"><coordinates xmlns=\"gml\">0,0 0,10 10,10 10,0 0,0</coordinates></LinearRing></exterior>" );
2938-
expectedGML3 += QString( "<interior xmlns=\"gml\"><LinearRing xmlns=\"gml\"><coordinates xmlns=\"gml\">1,1 1,9 9,9 9,1 1,1</coordinates></LinearRing></interior></Polygon>" );
2937+
QString expectedGML3( "<Polygon xmlns=\"gml\"><exterior xmlns=\"gml\"><LinearRing xmlns=\"gml\"><posList xmlns=\"gml\" srsDimension=\"2\">0 0 0 10 10 10 10 0 0 0</posList></LinearRing></exterior>" );
2938+
expectedGML3 += QString( "<interior xmlns=\"gml\"><LinearRing xmlns=\"gml\"><posList xmlns=\"gml\" srsDimension=\"2\">1 1 1 9 9 9 9 1 1 1</posList></LinearRing></interior></Polygon>" );
29392939
QCOMPARE( elemToString( exportPolygon.asGML3( doc ) ), expectedGML3 );
2940-
QString expectedGML3prec3( "<Polygon xmlns=\"gml\"><exterior xmlns=\"gml\"><LinearRing xmlns=\"gml\"><coordinates xmlns=\"gml\">1.111,1.111 1.111,11.111 11.111,11.111 11.111,1.111 1.111,1.111</coordinates></LinearRing></exterior>" );
2941-
expectedGML3prec3 += QString( "<interior xmlns=\"gml\"><LinearRing xmlns=\"gml\"><coordinates xmlns=\"gml\">0.667,0.667 0.667,1.333 1.333,1.333 1.333,0.667 0.667,0.667</coordinates></LinearRing></interior></Polygon>" );
2940+
QString expectedGML3prec3( "<Polygon xmlns=\"gml\"><exterior xmlns=\"gml\"><LinearRing xmlns=\"gml\"><posList xmlns=\"gml\" srsDimension=\"2\">1.111 1.111 1.111 11.111 11.111 11.111 11.111 1.111 1.111 1.111</posList></LinearRing></exterior>" );
2941+
expectedGML3prec3 += QString( "<interior xmlns=\"gml\"><LinearRing xmlns=\"gml\"><posList xmlns=\"gml\" srsDimension=\"2\">0.667 0.667 0.667 1.333 1.333 1.333 1.333 0.667 0.667 0.667</posList></LinearRing></interior></Polygon>" );
29422942
QCOMPARE( elemToString( exportPolygonFloat.asGML3( doc, 3 ) ), expectedGML3prec3 );
29432943

29442944
//removing the fourth to last vertex removes the whole ring

tests/testdata/qgis_server/wfs_getfeature_limit2.txt

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ Content-Type: text/xml; charset=utf-8
1313
</gml:Box>
1414
</gml:boundedBy>
1515
<qgs:geometry>
16-
<gml:Point srsName="EPSG:4326">
17-
<gml:coordinates cs="," ts=" ">8.20349634,44.90148253</gml:coordinates>
18-
</gml:Point>
16+
<Point xmlns="http://www.opengis.net/gml" srsName="EPSG:4326">
17+
<coordinates xmlns="http://www.opengis.net/gml" cs="," ts=" ">8.20349634,44.90148253</coordinates>
18+
</Point>
1919
</qgs:geometry>
2020
<qgs:id>1</qgs:id>
2121
<qgs:name>one</qgs:name>
@@ -30,9 +30,9 @@ Content-Type: text/xml; charset=utf-8
3030
</gml:Box>
3131
</gml:boundedBy>
3232
<qgs:geometry>
33-
<gml:Point srsName="EPSG:4326">
34-
<gml:coordinates cs="," ts=" ">8.20354699,44.90143568</gml:coordinates>
35-
</gml:Point>
33+
<Point xmlns="http://www.opengis.net/gml" srsName="EPSG:4326">
34+
<coordinates xmlns="http://www.opengis.net/gml" cs="," ts=" ">8.20354699,44.90143568</coordinates>
35+
</Point>
3636
</qgs:geometry>
3737
<qgs:id>2</qgs:id>
3838
<qgs:name>two</qgs:name>

tests/testdata/qgis_server/wfs_getfeature_nobbox.txt

+9-9
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ Content-Type: text/xml; charset=utf-8
1313
</gml:Box>
1414
</gml:boundedBy>
1515
<qgs:geometry>
16-
<gml:Point srsName="EPSG:4326">
17-
<gml:coordinates cs="," ts=" ">8.20349634,44.90148253</gml:coordinates>
18-
</gml:Point>
16+
<Point xmlns="http://www.opengis.net/gml" srsName="EPSG:4326">
17+
<coordinates xmlns="http://www.opengis.net/gml" cs="," ts=" ">8.20349634,44.90148253</coordinates>
18+
</Point>
1919
</qgs:geometry>
2020
<qgs:id>1</qgs:id>
2121
<qgs:name>one</qgs:name>
@@ -30,9 +30,9 @@ Content-Type: text/xml; charset=utf-8
3030
</gml:Box>
3131
</gml:boundedBy>
3232
<qgs:geometry>
33-
<gml:Point srsName="EPSG:4326">
34-
<gml:coordinates cs="," ts=" ">8.20354699,44.90143568</gml:coordinates>
35-
</gml:Point>
33+
<Point xmlns="http://www.opengis.net/gml" srsName="EPSG:4326">
34+
<coordinates xmlns="http://www.opengis.net/gml" cs="," ts=" ">8.20354699,44.90143568</coordinates>
35+
</Point>
3636
</qgs:geometry>
3737
<qgs:id>2</qgs:id>
3838
<qgs:name>two</qgs:name>
@@ -47,9 +47,9 @@ Content-Type: text/xml; charset=utf-8
4747
</gml:Box>
4848
</gml:boundedBy>
4949
<qgs:geometry>
50-
<gml:Point srsName="EPSG:4326">
51-
<gml:coordinates cs="," ts=" ">8.20345931,44.90139484</gml:coordinates>
52-
</gml:Point>
50+
<Point xmlns="http://www.opengis.net/gml" srsName="EPSG:4326">
51+
<coordinates xmlns="http://www.opengis.net/gml" cs="," ts=" ">8.20345931,44.90139484</coordinates>
52+
</Point>
5353
</qgs:geometry>
5454
<qgs:id>3</qgs:id>
5555
<qgs:name>three</qgs:name>

tests/testdata/qgis_server/wfs_getfeature_start1_limit1.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ Content-Type: text/xml; charset=utf-8
1313
</gml:Box>
1414
</gml:boundedBy>
1515
<qgs:geometry>
16-
<gml:Point srsName="EPSG:4326">
17-
<gml:coordinates cs="," ts=" ">8.20354699,44.90143568</gml:coordinates>
18-
</gml:Point>
16+
<Point xmlns="http://www.opengis.net/gml" srsName="EPSG:4326">
17+
<coordinates xmlns="http://www.opengis.net/gml" cs="," ts=" ">8.20354699,44.90143568</coordinates>
18+
</Point>
1919
</qgs:geometry>
2020
<qgs:id>2</qgs:id>
2121
<qgs:name>two</qgs:name>

tests/testdata/qgis_server/wfs_getfeature_startindex2.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ Content-Type: text/xml; charset=utf-8
1313
</gml:Box>
1414
</gml:boundedBy>
1515
<qgs:geometry>
16-
<gml:Point srsName="EPSG:4326">
17-
<gml:coordinates cs="," ts=" ">8.20345931,44.90139484</gml:coordinates>
18-
</gml:Point>
16+
<Point xmlns="http://www.opengis.net/gml" srsName="EPSG:4326">
17+
<coordinates xmlns="http://www.opengis.net/gml" cs="," ts=" ">8.20345931,44.90139484</coordinates>
18+
</Point>
1919
</qgs:geometry>
2020
<qgs:id>3</qgs:id>
2121
<qgs:name>three</qgs:name>

0 commit comments

Comments
 (0)