Skip to content

Commit f96af4a

Browse files
mhugentrldhont
authored andcommittedJul 4, 2017
Port GML3 improvements to 2.14 branch
1 parent 44fb457 commit f96af4a

10 files changed

+56
-75
lines changed
 

‎src/core/geometry/qgscompoundcurvev2.cpp

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -255,33 +255,16 @@ QDomElement QgsCompoundCurveV2::asGML2( QDomDocument& doc, int precision, const
255255

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

287270
QString QgsCompoundCurveV2::asJSON( int precision ) const

‎src/core/geometry/qgscurvepolygonv2.cpp

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -317,30 +317,19 @@ QDomElement QgsCurvePolygonV2::asGML3( QDomDocument& doc, int precision, const Q
317317
{
318318
QDomElement elemCurvePolygon = doc.createElementNS( ns, "Polygon" );
319319
QDomElement elemExterior = doc.createElementNS( ns, "exterior" );
320-
QDomElement outerRing = exteriorRing()->asGML3( doc, precision, ns );
321-
if ( outerRing.tagName() == QString( "Curve" ) )
320+
QDomElement curveElem = exteriorRing()->asGML3( doc, precision, ns );
321+
if ( curveElem.tagName() == "LineString" )
322322
{
323-
QDomNodeList posListElements = outerRing.elementsByTagName( "posList" );
324-
outerRing = doc.createElementNS( ns, "LinearRing" );
325-
outerRing.appendChild( posListElements.at( 0 ) );
323+
curveElem.setTagName( "LinearRing" );
326324
}
327-
else
328-
{
329-
outerRing.setTagName( "LinearRing" );
330-
}
331-
elemExterior.appendChild( outerRing );
325+
elemExterior.appendChild( curveElem );
332326
elemCurvePolygon.appendChild( elemExterior );
327+
333328
for ( int i = 0, n = numInteriorRings(); i < n; ++i )
334329
{
335330
QDomElement elemInterior = doc.createElementNS( ns, "interior" );
336331
QDomElement innerRing = interiorRing( i )->asGML3( doc, precision, ns );
337-
if ( innerRing.tagName() == QString( "Curve" ) )
338-
{
339-
QDomNodeList posListElements = innerRing.elementsByTagName( "posList" );
340-
innerRing = doc.createElementNS( ns, "LinearRing" );
341-
innerRing.appendChild( posListElements.at( 0 ) );
342-
}
343-
else
332+
if ( innerRing.tagName() == "LineString" )
344333
{
345334
innerRing.setTagName( "LinearRing" );
346335
}

‎src/core/geometry/qgslinestringv2.cpp

Lines changed: 3 additions & 8 deletions
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ QDomElement QgsMultiLineStringV2::asGML2( QDomDocument& doc, int precision, cons
5454

5555
QDomElement QgsMultiLineStringV2::asGML3( QDomDocument& doc, int precision, const QString& ns ) const
5656
{
57-
QDomElement elemMultiCurve = doc.createElementNS( ns, "MultiLineString" );
57+
QDomElement elemMultiCurve = doc.createElementNS( ns, "MultiCurve" );
5858
Q_FOREACH ( const QgsAbstractGeometryV2 *geom, mGeometries )
5959
{
6060
if ( dynamic_cast<const QgsLineStringV2*>( geom ) )

‎src/server/qgswfsserver.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2004,7 +2004,14 @@ QDomElement QgsWFSServer::createFeatureGML2( QgsFeature* feat, QDomDocument& doc
20042004
delete centroid;
20052005
}
20062006
else
2007-
gmlElem = QgsOgcUtils::geometryToGML( geom, doc, prec );
2007+
{
2008+
QgsAbstractGeometryV2* abstractGeom = geom->geometry();
2009+
if ( abstractGeom )
2010+
{
2011+
gmlElem = abstractGeom->asGML2( doc, prec, "http://www.opengis.net/gml" );
2012+
}
2013+
}
2014+
20082015
if ( !gmlElem.isNull() )
20092016
{
20102017
QgsRectangle box = geom->boundingBox();
@@ -2081,7 +2088,14 @@ QDomElement QgsWFSServer::createFeatureGML3( QgsFeature* feat, QDomDocument& doc
20812088
delete centroid;
20822089
}
20832090
else
2084-
gmlElem = QgsOgcUtils::geometryToGML( geom, doc, "GML3", prec );
2091+
{
2092+
QgsAbstractGeometryV2* abstractGeom = geom->geometry();
2093+
if ( abstractGeom )
2094+
{
2095+
gmlElem = abstractGeom->asGML3( doc, prec, "http://www.opengis.net/gml" );
2096+
}
2097+
}
2098+
20852099
if ( !gmlElem.isNull() )
20862100
{
20872101
QgsRectangle box = geom->boundingBox();

‎tests/src/core/testqgsgeometry.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,9 +1408,9 @@ void TestQgsGeometry::lineStringV2()
14081408
QCOMPARE( elemToString( exportLineFloat.asGML2( doc, 3 ) ), expectedGML2prec3 );
14091409

14101410
//asGML3
1411-
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>" );
1411+
QString expectedGML3( "<LineString xmlns=\"gml\"><posList xmlns=\"gml\" srsDimension=\"2\">31 32 41 42 51 52</posList></LineString>" );
14121412
QCOMPARE( elemToString( exportLine.asGML3( doc ) ), expectedGML3 );
1413-
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>" );
1413+
QString expectedGML3prec3( "<LineString xmlns=\"gml\"><posList xmlns=\"gml\" srsDimension=\"2\">0.333 0.667 1.333 1.667 2.333 2.667</posList></LineString>" );
14141414
QCOMPARE( elemToString( exportLineFloat.asGML3( doc, 3 ) ), expectedGML3prec3 );
14151415

14161416
//asJSON

‎tests/testdata/qgis_server/wfs_getfeature_limit2.txt

Lines changed: 6 additions & 6 deletions
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

Lines changed: 9 additions & 9 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 3 additions & 3 deletions
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)
Please sign in to comment.