Skip to content
Permalink
Browse files

Init z support and GML3 3D

  • Loading branch information
lbartoletti committed Oct 23, 2017
1 parent 0d89504 commit 52e9a48c097383a986d504ea0ff1f8b99b940036
Showing with 11 additions and 18 deletions.
  1. +5 −18 src/core/geometry/qgstriangle.cpp
  2. +6 −0 tests/src/core/testqgsgeometry.cpp
@@ -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 )
@@ -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;
}

@@ -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 ) );
@@ -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 ) );

0 comments on commit 52e9a48

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