Skip to content

Commit aa24896

Browse files
committedJul 7, 2017
Fix GML2 after GML3 improvements
1 parent 59d1f6d commit aa24896

File tree

7 files changed

+37
-20
lines changed

7 files changed

+37
-20
lines changed
 

‎src/core/geometry/qgsgeometryutils.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -877,12 +877,20 @@ QDomElement QgsGeometryUtils::pointsToGML2( const QgsPointSequence &points, QDom
877877
{
878878
QDomElement elemCoordinates = doc.createElementNS( ns, QStringLiteral( "coordinates" ) );
879879

880+
// coordinate separator
881+
QString cs = ",";
882+
// tupel separator
883+
QString ts = " ";
884+
885+
elemCoordinates.setAttribute( "cs", cs );
886+
elemCoordinates.setAttribute( "ts", ts );
887+
880888
QString strCoordinates;
881889

882890
Q_FOREACH ( const QgsPoint &p, points )
883-
strCoordinates += qgsDoubleToString( p.x(), precision ) + ',' + qgsDoubleToString( p.y(), precision ) + ' ';
891+
strCoordinates += qgsDoubleToString( p.x(), precision ) + cs + qgsDoubleToString( p.y(), precision ) + ts;
884892

885-
if ( strCoordinates.endsWith( ' ' ) )
893+
if ( strCoordinates.endsWith( ts ) )
886894
strCoordinates.chop( 1 ); // Remove trailing space
887895

888896
elemCoordinates.appendChild( doc.createTextNode( strCoordinates ) );

‎src/core/geometry/qgspoint.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,16 @@ QDomElement QgsPoint::asGML2( QDomDocument &doc, int precision, const QString &n
232232
{
233233
QDomElement elemPoint = doc.createElementNS( ns, QStringLiteral( "Point" ) );
234234
QDomElement elemCoordinates = doc.createElementNS( ns, QStringLiteral( "coordinates" ) );
235-
QString strCoordinates = qgsDoubleToString( mX, precision ) + ',' + qgsDoubleToString( mY, precision );
235+
236+
// coordinate separator
237+
QString cs = ",";
238+
// tupel separator
239+
QString ts = " ";
240+
241+
elemCoordinates.setAttribute( "cs", cs );
242+
elemCoordinates.setAttribute( "ts", ts );
243+
244+
QString strCoordinates = qgsDoubleToString( mX, precision ) + cs + qgsDoubleToString( mY, precision );
236245
elemCoordinates.appendChild( doc.createTextNode( strCoordinates ) );
237246
elemPoint.appendChild( elemCoordinates );
238247
return elemPoint;

‎tests/src/core/testqgsgeometry.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -616,9 +616,9 @@ void TestQgsGeometry::point()
616616
QgsPoint exportPoint( 1, 2 );
617617
QgsPoint exportPointFloat( 1 / 3.0, 2 / 3.0 );
618618
QDomDocument doc( QStringLiteral( "gml" ) );
619-
QString expectedGML2( QStringLiteral( "<Point xmlns=\"gml\"><coordinates xmlns=\"gml\">1,2</coordinates></Point>" ) );
619+
QString expectedGML2( QStringLiteral( "<Point xmlns=\"gml\"><coordinates xmlns=\"gml\" cs=\",\" ts=\" \">1,2</coordinates></Point>" ) );
620620
QCOMPARE( elemToString( exportPoint.asGML2( doc ) ), expectedGML2 );
621-
QString expectedGML2prec3( QStringLiteral( "<Point xmlns=\"gml\"><coordinates xmlns=\"gml\">0.333,0.667</coordinates></Point>" ) );
621+
QString expectedGML2prec3( QStringLiteral( "<Point xmlns=\"gml\"><coordinates xmlns=\"gml\" cs=\",\" ts=\" \">0.333,0.667</coordinates></Point>" ) );
622622
QCOMPARE( elemToString( exportPointFloat.asGML2( doc, 3 ) ), expectedGML2prec3 );
623623

624624
//asGML3
@@ -1738,9 +1738,9 @@ void TestQgsGeometry::lineString()
17381738
<< QgsPoint( 1 + 1 / 3.0, 1 + 2 / 3.0 )
17391739
<< QgsPoint( 2 + 1 / 3.0, 2 + 2 / 3.0 ) );
17401740
QDomDocument doc( QStringLiteral( "gml" ) );
1741-
QString expectedGML2( QStringLiteral( "<LineString xmlns=\"gml\"><coordinates xmlns=\"gml\">31,32 41,42 51,52</coordinates></LineString>" ) );
1741+
QString expectedGML2( QStringLiteral( "<LineString xmlns=\"gml\"><coordinates xmlns=\"gml\" cs=\",\" ts=\" \">31,32 41,42 51,52</coordinates></LineString>" ) );
17421742
QCOMPARE( elemToString( exportLine.asGML2( doc ) ), expectedGML2 );
1743-
QString expectedGML2prec3( QStringLiteral( "<LineString xmlns=\"gml\"><coordinates xmlns=\"gml\">0.333,0.667 1.333,1.667 2.333,2.667</coordinates></LineString>" ) );
1743+
QString expectedGML2prec3( QStringLiteral( "<LineString xmlns=\"gml\"><coordinates xmlns=\"gml\" cs=\",\" ts=\" \">0.333,0.667 1.333,1.667 2.333,2.667</coordinates></LineString>" ) );
17441744
QCOMPARE( elemToString( exportLineFloat.asGML2( doc, 3 ) ), expectedGML2prec3 );
17451745

17461746
//asGML3
@@ -3202,11 +3202,11 @@ void TestQgsGeometry::polygon()
32023202
QDomDocument doc( "gml" );
32033203

32043204
// as GML2
3205-
QString expectedSimpleGML2( "<Polygon xmlns=\"gml\"><outerBoundaryIs xmlns=\"gml\"><LinearRing xmlns=\"gml\"><coordinates xmlns=\"gml\">0,0 0,10 10,10 10,0 0,0</coordinates></LinearRing></outerBoundaryIs></Polygon>" );
3205+
QString expectedSimpleGML2( QStringLiteral( "<Polygon xmlns=\"gml\"><outerBoundaryIs xmlns=\"gml\"><LinearRing xmlns=\"gml\"><coordinates xmlns=\"gml\" cs=\",\" ts=\" \">0,0 0,10 10,10 10,0 0,0</coordinates></LinearRing></outerBoundaryIs></Polygon>" ) );
32063206
QCOMPARE( elemToString( exportPolygon.asGML2( doc ) ), expectedSimpleGML2 );
32073207

32083208
//as GML3
3209-
QString expectedSimpleGML3( "<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></Polygon>" );
3209+
QString expectedSimpleGML3( QStringLiteral( "<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></Polygon>" ) );
32103210
QCOMPARE( elemToString( exportPolygon.asGML3( doc ) ), expectedSimpleGML3 );
32113211

32123212
// as JSON
@@ -3238,11 +3238,11 @@ void TestQgsGeometry::polygon()
32383238
QCOMPARE( exportPolygonFloat.asJSON( 3 ), expectedJsonPrec3 );
32393239

32403240
// as GML2
3241-
QString expectedGML2( QStringLiteral( "<Polygon xmlns=\"gml\"><outerBoundaryIs xmlns=\"gml\"><LinearRing xmlns=\"gml\"><coordinates xmlns=\"gml\">0,0 0,10 10,10 10,0 0,0</coordinates></LinearRing></outerBoundaryIs>" ) );
3242-
expectedGML2 += QStringLiteral( "<innerBoundaryIs xmlns=\"gml\"><LinearRing xmlns=\"gml\"><coordinates xmlns=\"gml\">1,1 1,9 9,9 9,1 1,1</coordinates></LinearRing></innerBoundaryIs></Polygon>" );
3241+
QString expectedGML2( QStringLiteral( "<Polygon xmlns=\"gml\"><outerBoundaryIs xmlns=\"gml\"><LinearRing xmlns=\"gml\"><coordinates xmlns=\"gml\" cs=\",\" ts=\" \">0,0 0,10 10,10 10,0 0,0</coordinates></LinearRing></outerBoundaryIs>" ) );
3242+
expectedGML2 += QStringLiteral( "<innerBoundaryIs xmlns=\"gml\"><LinearRing xmlns=\"gml\"><coordinates xmlns=\"gml\" cs=\",\" ts=\" \">1,1 1,9 9,9 9,1 1,1</coordinates></LinearRing></innerBoundaryIs></Polygon>" );
32433243
QCOMPARE( elemToString( exportPolygon.asGML2( doc ) ), expectedGML2 );
3244-
QString expectedGML2prec3( QStringLiteral( "<Polygon xmlns=\"gml\"><outerBoundaryIs 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></outerBoundaryIs>" ) );
3245-
expectedGML2prec3 += QStringLiteral( "<innerBoundaryIs 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></innerBoundaryIs></Polygon>" );
3244+
QString expectedGML2prec3( QStringLiteral( "<Polygon xmlns=\"gml\"><outerBoundaryIs xmlns=\"gml\"><LinearRing xmlns=\"gml\"><coordinates xmlns=\"gml\" cs=\",\" ts=\" \">1.111,1.111 1.111,11.111 11.111,11.111 11.111,1.111 1.111,1.111</coordinates></LinearRing></outerBoundaryIs>" ) );
3245+
expectedGML2prec3 += QStringLiteral( "<innerBoundaryIs xmlns=\"gml\"><LinearRing xmlns=\"gml\"><coordinates xmlns=\"gml\" cs=\",\" ts=\" \">0.667,0.667 0.667,1.333 1.333,1.333 1.333,0.667 0.667,0.667</coordinates></LinearRing></innerBoundaryIs></Polygon>" );
32463246
QCOMPARE( elemToString( exportPolygonFloat.asGML2( doc, 3 ) ), expectedGML2prec3 );
32473247

32483248
//as GML3

‎tests/testdata/qgis_server/wfs_getfeature_limit2.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Content-Type: text/xml; charset=utf-8
1414
</gml:boundedBy>
1515
<qgs:geometry>
1616
<Point xmlns="http://www.opengis.net/gml" srsName="EPSG:4326">
17-
<coordinates xmlns="http://www.opengis.net/gml">8.20349634,44.90148253</coordinates>
17+
<coordinates xmlns="http://www.opengis.net/gml" cs="," ts=" ">8.20349634,44.90148253</coordinates>
1818
</Point>
1919
</qgs:geometry>
2020
<qgs:id>1</qgs:id>
@@ -31,7 +31,7 @@ Content-Type: text/xml; charset=utf-8
3131
</gml:boundedBy>
3232
<qgs:geometry>
3333
<Point xmlns="http://www.opengis.net/gml" srsName="EPSG:4326">
34-
<coordinates xmlns="http://www.opengis.net/gml">8.20354699,44.90143568</coordinates>
34+
<coordinates xmlns="http://www.opengis.net/gml" cs="," ts=" ">8.20354699,44.90143568</coordinates>
3535
</Point>
3636
</qgs:geometry>
3737
<qgs:id>2</qgs:id>

‎tests/testdata/qgis_server/wfs_getfeature_nobbox.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Content-Type: text/xml; charset=utf-8
1414
</gml:boundedBy>
1515
<qgs:geometry>
1616
<Point xmlns="http://www.opengis.net/gml" srsName="EPSG:4326">
17-
<coordinates xmlns="http://www.opengis.net/gml">8.20349634,44.90148253</coordinates>
17+
<coordinates xmlns="http://www.opengis.net/gml" cs="," ts=" ">8.20349634,44.90148253</coordinates>
1818
</Point>
1919
</qgs:geometry>
2020
<qgs:id>1</qgs:id>
@@ -31,7 +31,7 @@ Content-Type: text/xml; charset=utf-8
3131
</gml:boundedBy>
3232
<qgs:geometry>
3333
<Point xmlns="http://www.opengis.net/gml" srsName="EPSG:4326">
34-
<coordinates xmlns="http://www.opengis.net/gml">8.20354699,44.90143568</coordinates>
34+
<coordinates xmlns="http://www.opengis.net/gml" cs="," ts=" ">8.20354699,44.90143568</coordinates>
3535
</Point>
3636
</qgs:geometry>
3737
<qgs:id>2</qgs:id>
@@ -48,7 +48,7 @@ Content-Type: text/xml; charset=utf-8
4848
</gml:boundedBy>
4949
<qgs:geometry>
5050
<Point xmlns="http://www.opengis.net/gml" srsName="EPSG:4326">
51-
<coordinates xmlns="http://www.opengis.net/gml">8.20345931,44.90139484</coordinates>
51+
<coordinates xmlns="http://www.opengis.net/gml" cs="," ts=" ">8.20345931,44.90139484</coordinates>
5252
</Point>
5353
</qgs:geometry>
5454
<qgs:id>3</qgs:id>

‎tests/testdata/qgis_server/wfs_getfeature_start1_limit1.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Content-Type: text/xml; charset=utf-8
1414
</gml:boundedBy>
1515
<qgs:geometry>
1616
<Point xmlns="http://www.opengis.net/gml" srsName="EPSG:4326">
17-
<coordinates xmlns="http://www.opengis.net/gml">8.20354699,44.90143568</coordinates>
17+
<coordinates xmlns="http://www.opengis.net/gml" cs="," ts=" ">8.20354699,44.90143568</coordinates>
1818
</Point>
1919
</qgs:geometry>
2020
<qgs:id>2</qgs:id>

‎tests/testdata/qgis_server/wfs_getfeature_startindex2.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Content-Type: text/xml; charset=utf-8
1414
</gml:boundedBy>
1515
<qgs:geometry>
1616
<Point xmlns="http://www.opengis.net/gml" srsName="EPSG:4326">
17-
<coordinates xmlns="http://www.opengis.net/gml">8.20345931,44.90139484</coordinates>
17+
<coordinates xmlns="http://www.opengis.net/gml" cs="," ts=" ">8.20345931,44.90139484</coordinates>
1818
</Point>
1919
</qgs:geometry>
2020
<qgs:id>3</qgs:id>

0 commit comments

Comments
 (0)
Please sign in to comment.