Skip to content
Permalink
Browse files

Port GML3 improvements to 2.18 branch

  • Loading branch information
mhugent committed Feb 22, 2017
1 parent d07968a commit 08a82f1962edb6d31731acef15cde00555202800
@@ -256,33 +256,16 @@ QDomElement QgsCompoundCurveV2::asGML2( QDomDocument& doc, int precision, const

QDomElement QgsCompoundCurveV2::asGML3( QDomDocument& doc, int precision, const QString& ns ) const
{
QDomElement elemCurve = doc.createElementNS( ns, "Curve" );

QDomElement elemSegments = doc.createElementNS( ns, "segments" );

QDomElement compoundCurveElem = doc.createElementNS( ns, "CompositeCurve" );
Q_FOREACH ( const QgsCurveV2* curve, mCurves )
{
if ( dynamic_cast<const QgsLineStringV2*>( curve ) )
{
QgsPointSequenceV2 pts;
curve->points( pts );

QDomElement elemLineStringSegment = doc.createElementNS( ns, "LineStringSegment" );
elemLineStringSegment.appendChild( QgsGeometryUtils::pointsToGML3( pts, doc, precision, ns, is3D() ) );
elemSegments.appendChild( elemLineStringSegment );
}
else if ( dynamic_cast<const QgsCircularStringV2*>( curve ) )
{
QgsPointSequenceV2 pts;
curve->points( pts );

QDomElement elemArcString = doc.createElementNS( ns, "ArcString" );
elemArcString.appendChild( QgsGeometryUtils::pointsToGML3( pts, doc, precision, ns, is3D() ) );
elemSegments.appendChild( elemArcString );
}
QDomElement curveMemberElem = doc.createElementNS( ns, "curveMember" );
QDomElement curveElem = curve->asGML3( doc, precision, ns );
curveMemberElem.appendChild( curveElem );
compoundCurveElem.appendChild( curveMemberElem );
}
elemCurve.appendChild( elemSegments );
return elemCurve;

return compoundCurveElem;
}

QString QgsCompoundCurveV2::asJSON( int precision ) const
@@ -320,18 +320,26 @@ QDomElement QgsCurvePolygonV2::asGML3( QDomDocument& doc, int precision, const Q
{
QDomElement elemCurvePolygon = doc.createElementNS( ns, "Polygon" );
QDomElement elemExterior = doc.createElementNS( ns, "exterior" );
QDomElement outerRing = exteriorRing()->asGML2( doc, precision, ns );
outerRing.toElement().setTagName( "LinearRing" );
elemExterior.appendChild( outerRing );
QDomElement curveElem = exteriorRing()->asGML3( doc, precision, ns );
if ( curveElem.tagName() == "LineString" )
{
curveElem.setTagName( "LinearRing" );
}
elemExterior.appendChild( curveElem );
elemCurvePolygon.appendChild( elemExterior );

elemCurvePolygon.appendChild( elemExterior );
QDomElement elemInterior = doc.createElementNS( ns, "interior" );
for ( int i = 0, n = numInteriorRings(); i < n; ++i )
{
QDomElement innerRing = interiorRing( i )->asGML2( doc, precision, ns );
innerRing.toElement().setTagName( "LinearRing" );
QDomElement elemInterior = doc.createElementNS( ns, "interior" );
QDomElement innerRing = interiorRing( i )->asGML3( doc, precision, ns );
if ( innerRing.tagName() == "LineString" )
{
innerRing.setTagName( "LinearRing" );
}
elemInterior.appendChild( innerRing );
elemCurvePolygon.appendChild( elemInterior );
}
elemCurvePolygon.appendChild( elemInterior );
return elemCurvePolygon;
}

@@ -209,14 +209,9 @@ QDomElement QgsLineStringV2::asGML3( QDomDocument& doc, int precision, const QSt
QgsPointSequenceV2 pts;
points( pts );

QDomElement elemCurve = doc.createElementNS( ns, "Curve" );
QDomElement elemSegments = doc.createElementNS( ns, "segments" );
QDomElement elemArcString = doc.createElementNS( ns, "LineStringSegment" );
elemArcString.appendChild( QgsGeometryUtils::pointsToGML3( pts, doc, precision, ns, is3D() ) );
elemSegments.appendChild( elemArcString );
elemCurve.appendChild( elemSegments );

return elemCurve;
QDomElement elemLineString = doc.createElementNS( ns, "LineString" );
elemLineString.appendChild( QgsGeometryUtils::pointsToGML3( pts, doc, precision, ns, is3D() ) );
return elemLineString;
}

QString QgsLineStringV2::asJSON( int precision ) const
@@ -60,7 +60,7 @@ QDomElement QgsMultiLineStringV2::asGML2( QDomDocument& doc, int precision, cons

QDomElement QgsMultiLineStringV2::asGML3( QDomDocument& doc, int precision, const QString& ns ) const
{
QDomElement elemMultiCurve = doc.createElementNS( ns, "MultiLineString" );
QDomElement elemMultiCurve = doc.createElementNS( ns, "MultiCurve" );
Q_FOREACH ( const QgsAbstractGeometryV2 *geom, mGeometries )
{
if ( dynamic_cast<const QgsLineStringV2*>( geom ) )
@@ -1993,7 +1993,14 @@ QDomElement QgsWFSServer::createFeatureGML2( QgsFeature* feat, QDomDocument& doc
delete centroid;
}
else
gmlElem = QgsOgcUtils::geometryToGML( geom, doc, prec );
{
QgsAbstractGeometryV2* abstractGeom = geom->geometry();
if ( abstractGeom )
{
gmlElem = abstractGeom->asGML2( doc, prec, "http://www.opengis.net/gml" );
}
}

if ( !gmlElem.isNull() )
{
QgsRectangle box = geom->boundingBox();
@@ -2070,7 +2077,14 @@ QDomElement QgsWFSServer::createFeatureGML3( QgsFeature* feat, QDomDocument& doc
delete centroid;
}
else
gmlElem = QgsOgcUtils::geometryToGML( geom, doc, "GML3", prec );
{
QgsAbstractGeometryV2* abstractGeom = geom->geometry();
if ( abstractGeom )
{
gmlElem = abstractGeom->asGML3( doc, prec, "http://www.opengis.net/gml" );
}
}

if ( !gmlElem.isNull() )
{
QgsRectangle box = geom->boundingBox();
@@ -1428,9 +1428,9 @@ void TestQgsGeometry::lineStringV2()
QCOMPARE( elemToString( exportLineFloat.asGML2( doc, 3 ) ), expectedGML2prec3 );

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

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

//as GML3
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>" );
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>" );
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>" );
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>" );
QCOMPARE( elemToString( exportPolygon.asGML3( doc ) ), expectedGML3 );
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>" );
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>" );
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>" );
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>" );
QCOMPARE( elemToString( exportPolygonFloat.asGML3( doc, 3 ) ), expectedGML3prec3 );

//removing the fourth to last vertex removes the whole ring
@@ -13,9 +13,9 @@ Content-Type: text/xml; charset=utf-8
</gml:Box>
</gml:boundedBy>
<qgs:geometry>
<gml:Point srsName="EPSG:4326">
<gml:coordinates cs="," ts=" ">8.20349634,44.90148253</gml:coordinates>
</gml:Point>
<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>
</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>
<gml:Point srsName="EPSG:4326">
<gml:coordinates cs="," ts=" ">8.20354699,44.90143568</gml:coordinates>
</gml:Point>
<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>
<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>
<gml:Point srsName="EPSG:4326">
<gml:coordinates cs="," ts=" ">8.20349634,44.90148253</gml:coordinates>
</gml:Point>
<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>
</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>
<gml:Point srsName="EPSG:4326">
<gml:coordinates cs="," ts=" ">8.20354699,44.90143568</gml:coordinates>
</gml:Point>
<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>
<qgs:id>2</qgs:id>
<qgs:name>two</qgs:name>
@@ -47,9 +47,9 @@ Content-Type: text/xml; charset=utf-8
</gml:Box>
</gml:boundedBy>
<qgs:geometry>
<gml:Point srsName="EPSG:4326">
<gml:coordinates cs="," ts=" ">8.20345931,44.90139484</gml:coordinates>
</gml:Point>
<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>
</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>
<gml:Point srsName="EPSG:4326">
<gml:coordinates cs="," ts=" ">8.20354699,44.90143568</gml:coordinates>
</gml:Point>
<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>
<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>
<gml:Point srsName="EPSG:4326">
<gml:coordinates cs="," ts=" ">8.20345931,44.90139484</gml:coordinates>
</gml:Point>
<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>
</qgs:geometry>
<qgs:id>3</qgs:id>
<qgs:name>three</qgs:name>

0 comments on commit 08a82f1

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