Skip to content
Permalink
Browse files

Port GML3 improvements to 2.14 branch

  • Loading branch information
mhugent authored and rldhont committed Jul 4, 2017
1 parent 44fb457 commit f96af4a19d0fef4b584a4f203aebd6be2add1c91
@@ -255,33 +255,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
@@ -317,30 +317,19 @@ QDomElement QgsCurvePolygonV2::asGML3( QDomDocument& doc, int precision, const Q
{
QDomElement elemCurvePolygon = doc.createElementNS( ns, "Polygon" );
QDomElement elemExterior = doc.createElementNS( ns, "exterior" );
QDomElement outerRing = exteriorRing()->asGML3( doc, precision, ns );
if ( outerRing.tagName() == QString( "Curve" ) )
QDomElement curveElem = exteriorRing()->asGML3( doc, precision, ns );
if ( curveElem.tagName() == "LineString" )
{
QDomNodeList posListElements = outerRing.elementsByTagName( "posList" );
outerRing = doc.createElementNS( ns, "LinearRing" );
outerRing.appendChild( posListElements.at( 0 ) );
curveElem.setTagName( "LinearRing" );
}
else
{
outerRing.setTagName( "LinearRing" );
}
elemExterior.appendChild( outerRing );
elemExterior.appendChild( curveElem );
elemCurvePolygon.appendChild( elemExterior );

for ( int i = 0, n = numInteriorRings(); i < n; ++i )
{
QDomElement elemInterior = doc.createElementNS( ns, "interior" );
QDomElement innerRing = interiorRing( i )->asGML3( doc, precision, ns );
if ( innerRing.tagName() == QString( "Curve" ) )
{
QDomNodeList posListElements = innerRing.elementsByTagName( "posList" );
innerRing = doc.createElementNS( ns, "LinearRing" );
innerRing.appendChild( posListElements.at( 0 ) );
}
else
if ( innerRing.tagName() == "LineString" )
{
innerRing.setTagName( "LinearRing" );
}
@@ -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
@@ -54,7 +54,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 ) )
@@ -2004,7 +2004,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();
@@ -2081,7 +2088,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();
@@ -1408,9 +1408,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
@@ -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 f96af4a

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