Skip to content

Commit

Permalink
Port GML3 improvements to 2.14 branch
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent authored and rldhont committed Jul 4, 2017
1 parent 44fb457 commit f96af4a
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 75 deletions.
31 changes: 7 additions & 24 deletions src/core/geometry/qgscompoundcurvev2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 6 additions & 17 deletions src/core/geometry/qgscurvepolygonv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" );
}
Expand Down
11 changes: 3 additions & 8 deletions src/core/geometry/qgslinestringv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/core/geometry/qgsmultilinestringv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) )
Expand Down
18 changes: 16 additions & 2 deletions src/server/qgswfsserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions tests/src/core/testqgsgeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions tests/testdata/qgis_server/wfs_getfeature_limit2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand Down
18 changes: 9 additions & 9 deletions tests/testdata/qgis_server/wfs_getfeature_nobbox.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand All @@ -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>
Expand Down
6 changes: 3 additions & 3 deletions tests/testdata/qgis_server/wfs_getfeature_start1_limit1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
6 changes: 3 additions & 3 deletions tests/testdata/qgis_server/wfs_getfeature_startindex2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit f96af4a

Please sign in to comment.