Skip to content

Commit

Permalink
Enable gml3 curve output for compoundcurve and some fixes for gml3 ou…
Browse files Browse the repository at this point in the history
…tput in general
  • Loading branch information
mhugent committed Feb 14, 2017
1 parent dedeb9c commit 93645a3
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 40 deletions.
31 changes: 7 additions & 24 deletions src/core/geometry/qgscompoundcurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,33 +248,16 @@ QDomElement QgsCompoundCurve::asGML2( QDomDocument& doc, int precision, const QS

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

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

QDomElement compoundCurveElem = doc.createElementNS( ns, QStringLiteral( "CompositeCurve" ) );
Q_FOREACH ( const QgsCurve* curve, mCurves )
{
if ( dynamic_cast<const QgsLineString*>( curve ) )
{
QgsPointSequence pts;
curve->points( pts );

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

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

return compoundCurveElem;
}

QString QgsCompoundCurve::asJSON( int precision ) const
Expand Down
22 changes: 15 additions & 7 deletions src/core/geometry/qgscurvepolygon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,18 +308,26 @@ QDomElement QgsCurvePolygon::asGML3( QDomDocument& doc, int precision, const QSt
{
QDomElement elemCurvePolygon = doc.createElementNS( ns, QStringLiteral( "Polygon" ) );
QDomElement elemExterior = doc.createElementNS( ns, QStringLiteral( "exterior" ) );
QDomElement outerRing = exteriorRing()->asGML2( doc, precision, ns );
outerRing.toElement().setTagName( QStringLiteral( "LinearRing" ) );
elemExterior.appendChild( outerRing );
QDomElement curveElem = exteriorRing()->asGML3( doc, precision, ns );
if ( curveElem.tagName() == "LineString" )
{
curveElem.setTagName( QStringLiteral( "LinearRing" ) );
}
elemExterior.appendChild( curveElem );
elemCurvePolygon.appendChild( elemExterior );

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

Expand Down
11 changes: 3 additions & 8 deletions src/core/geometry/qgslinestring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,9 @@ QDomElement QgsLineString::asGML3( QDomDocument& doc, int precision, const QStri
QgsPointSequence pts;
points( pts );

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

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

QString QgsLineString::asJSON( int precision ) const
Expand Down
2 changes: 1 addition & 1 deletion src/core/geometry/qgsmultilinestring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ QDomElement QgsMultiLineString::asGML2( QDomDocument& doc, int precision, const

QDomElement QgsMultiLineString::asGML3( QDomDocument& doc, int precision, const QString& ns ) const
{
QDomElement elemMultiCurve = doc.createElementNS( ns, QStringLiteral( "MultiLineString" ) );
QDomElement elemMultiCurve = doc.createElementNS( ns, QStringLiteral( "MultiCurve" ) );
Q_FOREACH ( const QgsAbstractGeometry *geom, mGeometries )
{
if ( dynamic_cast<const QgsLineString*>( geom ) )
Expand Down

0 comments on commit 93645a3

Please sign in to comment.