Skip to content
Permalink
Browse files

Fix GML2 after Port GML3 improvements to 2.14 branch

  • Loading branch information
rldhont committed Jul 5, 2017
1 parent f96af4a commit f8d50ce652466095175bef664b76f0061f793f13
@@ -631,12 +631,20 @@ QDomElement QgsGeometryUtils::pointsToGML2( const QgsPointSequenceV2 &points, QD
{
QDomElement elemCoordinates = doc.createElementNS( ns, "coordinates" );

// coordinate separator
QString cs = ",";
// tupel separator
QString ts = " ";

elemCoordinates.setAttribute( "cs", cs );
elemCoordinates.setAttribute( "ts", ts );

QString strCoordinates;

Q_FOREACH ( const QgsPointV2& p, points )
strCoordinates += qgsDoubleToString( p.x(), precision ) + ',' + qgsDoubleToString( p.y(), precision ) + ' ';
strCoordinates += qgsDoubleToString( p.x(), precision ) + cs + qgsDoubleToString( p.y(), precision ) + ts;

if ( strCoordinates.endsWith( ' ' ) )
if ( strCoordinates.endsWith( ts ) )
strCoordinates.chop( 1 ); // Remove trailing space

elemCoordinates.appendChild( doc.createTextNode( strCoordinates ) );
@@ -213,7 +213,16 @@ QDomElement QgsPointV2::asGML2( QDomDocument& doc, int precision, const QString&
{
QDomElement elemPoint = doc.createElementNS( ns, "Point" );
QDomElement elemCoordinates = doc.createElementNS( ns, "coordinates" );
QString strCoordinates = qgsDoubleToString( mX, precision ) + ',' + qgsDoubleToString( mY, precision );

// coordinate separator
QString cs = ",";
// tupel separator
QString ts = " ";

elemCoordinates.setAttribute( "cs", cs );
elemCoordinates.setAttribute( "ts", ts );

QString strCoordinates = qgsDoubleToString( mX, precision ) + cs + qgsDoubleToString( mY, precision );
elemCoordinates.appendChild( doc.createTextNode( strCoordinates ) );
elemPoint.appendChild( elemCoordinates );
return elemPoint;
@@ -564,9 +564,9 @@ void TestQgsGeometry::pointV2()
QgsPointV2 exportPoint( 1, 2 );
QgsPointV2 exportPointFloat( 1 / 3.0, 2 / 3.0 );
QDomDocument doc( "gml" );
QString expectedGML2( "<Point xmlns=\"gml\"><coordinates xmlns=\"gml\">1,2</coordinates></Point>" );
QString expectedGML2( "<Point xmlns=\"gml\"><coordinates xmlns=\"gml\" cs=\",\" ts=\" \">1,2</coordinates></Point>" );
QCOMPARE( elemToString( exportPoint.asGML2( doc ) ), expectedGML2 );
QString expectedGML2prec3( "<Point xmlns=\"gml\"><coordinates xmlns=\"gml\">0.333,0.667</coordinates></Point>" );
QString expectedGML2prec3( "<Point xmlns=\"gml\"><coordinates xmlns=\"gml\" cs=\",\" ts=\" \">0.333,0.667</coordinates></Point>" );
QCOMPARE( elemToString( exportPointFloat.asGML2( doc, 3 ) ), expectedGML2prec3 );

//asGML3
@@ -1402,9 +1402,9 @@ void TestQgsGeometry::lineStringV2()
<< QgsPointV2( 1 + 1 / 3.0, 1 + 2 / 3.0 )
<< QgsPointV2( 2 + 1 / 3.0, 2 + 2 / 3.0 ) );
QDomDocument doc( "gml" );
QString expectedGML2( "<LineString xmlns=\"gml\"><coordinates xmlns=\"gml\">31,32 41,42 51,52</coordinates></LineString>" );
QString expectedGML2( "<LineString xmlns=\"gml\"><coordinates xmlns=\"gml\" cs=\",\" ts=\" \">31,32 41,42 51,52</coordinates></LineString>" );
QCOMPARE( elemToString( exportLine.asGML2( doc ) ), expectedGML2 );
QString expectedGML2prec3( "<LineString xmlns=\"gml\"><coordinates xmlns=\"gml\">0.333,0.667 1.333,1.667 2.333,2.667</coordinates></LineString>" );
QString expectedGML2prec3( "<LineString xmlns=\"gml\"><coordinates xmlns=\"gml\" cs=\",\" ts=\" \">0.333,0.667 1.333,1.667 2.333,2.667</coordinates></LineString>" );
QCOMPARE( elemToString( exportLineFloat.asGML2( doc, 3 ) ), expectedGML2prec3 );

//asGML3
@@ -2845,7 +2845,7 @@ void TestQgsGeometry::polygonV2()
QDomDocument doc( "gml" );

// as GML2
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>" );
QString expectedSimpleGML2( "<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>" );
QCOMPARE( elemToString( exportPolygon.asGML2( doc ) ), expectedSimpleGML2 );

//as GML3
@@ -2883,11 +2883,11 @@ void TestQgsGeometry::polygonV2()
QCOMPARE( exportPolygonFloat.asJSON( 3 ), expectedJsonPrec3 );

// as GML2
QString expectedGML2( "<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>" );
expectedGML2 += QString( "<innerBoundaryIs xmlns=\"gml\"><LinearRing xmlns=\"gml\"><coordinates xmlns=\"gml\">1,1 1,9 9,9 9,1 1,1</coordinates></LinearRing></innerBoundaryIs></Polygon>" );
QString expectedGML2( "<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>" );
expectedGML2 += QString( "<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>" );
QCOMPARE( elemToString( exportPolygon.asGML2( doc ) ), expectedGML2 );
QString expectedGML2prec3( "<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>" );
expectedGML2prec3 += QString( "<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>" );
QString expectedGML2prec3( "<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>" );
expectedGML2prec3 += QString( "<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>" );
QCOMPARE( elemToString( exportPolygonFloat.asGML2( doc, 3 ) ), expectedGML2prec3 );

//as GML3
@@ -13,9 +13,9 @@ Content-Type: text/xml; charset=utf-8
</gml:Box>
</gml:boundedBy>
<qgs:geometry>
<Point xmlns="http://www.opengis.net/gml" srsName="EPSG:4326">
<Point xmlns="http://www.opengis.net/gml" srsName="EPSG:4326">
<coordinates xmlns="http://www.opengis.net/gml" cs="," ts=" ">8.20349634,44.90148253</coordinates>
</Point>
</Point>
</qgs:geometry>
<qgs:id>1</qgs:id>
<qgs:name>one</qgs:name>
@@ -30,9 +30,9 @@ Content-Type: text/xml; charset=utf-8
</gml:Box>
</gml:boundedBy>
<qgs:geometry>
<Point xmlns="http://www.opengis.net/gml" srsName="EPSG:4326">
<Point xmlns="http://www.opengis.net/gml" srsName="EPSG:4326">
<coordinates xmlns="http://www.opengis.net/gml" cs="," ts=" ">8.20354699,44.90143568</coordinates>
</Point>
</Point>
</qgs:geometry>
<qgs:id>2</qgs:id>
<qgs:name>two</qgs:name>
@@ -13,9 +13,9 @@ Content-Type: text/xml; charset=utf-8
</gml:Box>
</gml:boundedBy>
<qgs:geometry>
<Point xmlns="http://www.opengis.net/gml" srsName="EPSG:4326">
<Point xmlns="http://www.opengis.net/gml" srsName="EPSG:4326">
<coordinates xmlns="http://www.opengis.net/gml" cs="," ts=" ">8.20349634,44.90148253</coordinates>
</Point>
</Point>
</qgs:geometry>
<qgs:id>1</qgs:id>
<qgs:name>one</qgs:name>
@@ -30,7 +30,7 @@ Content-Type: text/xml; charset=utf-8
</gml:Box>
</gml:boundedBy>
<qgs:geometry>
<Point xmlns="http://www.opengis.net/gml" srsName="EPSG:4326">
<Point xmlns="http://www.opengis.net/gml" srsName="EPSG:4326">
<coordinates xmlns="http://www.opengis.net/gml" cs="," ts=" ">8.20354699,44.90143568</coordinates>
</Point>
</qgs:geometry>
@@ -47,9 +47,9 @@ Content-Type: text/xml; charset=utf-8
</gml:Box>
</gml:boundedBy>
<qgs:geometry>
<Point xmlns="http://www.opengis.net/gml" srsName="EPSG:4326">
<Point xmlns="http://www.opengis.net/gml" srsName="EPSG:4326">
<coordinates xmlns="http://www.opengis.net/gml" cs="," ts=" ">8.20345931,44.90139484</coordinates>
</Point>
</Point>
</qgs:geometry>
<qgs:id>3</qgs:id>
<qgs:name>three</qgs:name>
@@ -13,9 +13,9 @@ Content-Type: text/xml; charset=utf-8
</gml:Box>
</gml:boundedBy>
<qgs:geometry>
<Point xmlns="http://www.opengis.net/gml" srsName="EPSG:4326">
<Point xmlns="http://www.opengis.net/gml" srsName="EPSG:4326">
<coordinates xmlns="http://www.opengis.net/gml" cs="," ts=" ">8.20354699,44.90143568</coordinates>
</Point>
</Point>
</qgs:geometry>
<qgs:id>2</qgs:id>
<qgs:name>two</qgs:name>
@@ -13,9 +13,9 @@ Content-Type: text/xml; charset=utf-8
</gml:Box>
</gml:boundedBy>
<qgs:geometry>
<Point xmlns="http://www.opengis.net/gml" srsName="EPSG:4326">
<Point xmlns="http://www.opengis.net/gml" srsName="EPSG:4326">
<coordinates xmlns="http://www.opengis.net/gml" cs="," ts=" ">8.20345931,44.90139484</coordinates>
</Point>
</Point>
</qgs:geometry>
<qgs:id>3</qgs:id>
<qgs:name>three</qgs:name>

0 comments on commit f8d50ce

Please sign in to comment.
You can’t perform that action at this time.