Skip to content

Commit

Permalink
Init z support and GML3 3D
Browse files Browse the repository at this point in the history
  • Loading branch information
lbartoletti committed Oct 23, 2017
1 parent 0d89504 commit 52e9a48
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
23 changes: 5 additions & 18 deletions src/core/geometry/qgstriangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,12 @@ QgsTriangle::QgsTriangle( const QgsPoint &p1, const QgsPoint &p2, const QgsPoint
{
return;
}
QVector< double > x;
x << p1.x() << p2.x() << p3.x();
QVector< double > y;
y << p1.y() << p2.y() << p3.y();
QgsLineString *ext = new QgsLineString( x, y );
setExteriorRing( ext );

std::unique_ptr<QgsLineString> ext( new QgsLineString() );

ext->setPoints( QgsPointSequence() << p1 << p2 << p3 );

setExteriorRing( ext.release() );
}

QgsTriangle::QgsTriangle( const QgsPointXY &p1, const QgsPointXY &p2, const QgsPointXY &p3 )
Expand Down Expand Up @@ -247,18 +246,6 @@ QDomElement QgsTriangle::asGML3( QDomDocument &doc, int precision, const QString
elemExterior.appendChild( curveElem );
elemCurveTriangle.appendChild( elemExterior );

/* No interior ring for triangle
for ( int i = 0, n = numInteriorRings(); i < n; ++i )
{
QDomElement elemInterior = doc.createElementNS( ns, QStringLiteral( "interior" ) );
QDomElement innerRing = interiorRing( i )->asGML3( doc, precision, ns );
if ( innerRing.tagName() == QLatin1String( "LineString" ) )
{
innerRing.setTagName( QStringLiteral( "LinearRing" ) );
}
elemInterior.appendChild( innerRing );
elemCurveTriangle.appendChild( elemInterior );
}*/
return elemCurveTriangle;
}

Expand Down
6 changes: 6 additions & 0 deletions tests/src/core/testqgsgeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5966,6 +5966,9 @@ void TestQgsGeometry::triangle()
QgsTriangle exportTriangle( QgsPoint( 1, 2 ),
QgsPoint( 3, 4 ),
QgsPoint( 6, 5 ) );
QgsTriangle exportTriangleZ( QgsPoint( 1, 2, 3 ),
QgsPoint( 11, 12, 13 ),
QgsPoint( 1, 12, 23 ) );
QgsTriangle exportTriangleFloat( QgsPoint( 1 + 1 / 3.0, 2 + 2 / 3.0 ),
QgsPoint( 3 + 1 / 3.0, 4 + 2 / 3.0 ),
QgsPoint( 6 + 1 / 3.0, 5 + 2 / 3.0 ) );
Expand All @@ -5984,6 +5987,9 @@ void TestQgsGeometry::triangle()
QCOMPARE( elemToString( exportTriangleFloat.asGML3( doc, 3 ) ), expectedGML3prec3 );
QString expectedGML3empty( QStringLiteral( "" ) ); // TODO: FIXME?
QGSCOMPAREGML( elemToString( exportEmptyTriangle.asGML3( doc ) ), expectedGML3empty );
QString expectedGML3Z( QStringLiteral( "<Triangle xmlns=\"gml\"><exterior xmlns=\"gml\"><LinearRing xmlns=\"gml\"><posList xmlns=\"gml\" srsDimension=\"3\">1 2 3 11 12 13 1 12 23 1 2 3</posList></LinearRing></exterior></Triangle>" ) );
QCOMPARE( elemToString( exportTriangleZ.asGML3( doc ) ), expectedGML3Z );


// lengths and angles
QgsTriangle t7( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ) );
Expand Down

0 comments on commit 52e9a48

Please sign in to comment.