mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-29 00:03:59 -04:00
- when creating geometry from WKT, upgrade dimensionality of geometry if coordinates are 3/4 dimensional - match dimensionality of collections to child dimensionality - fix area of curves was non-zero if curve is closed - don't consider m values when testing for curve closedness - add unit tests for closedness - add unit tests for CircularStrings, CompoundCurves, CurvePolygon, tests with geometries with Z/M values
92 lines
2.4 KiB
C++
92 lines
2.4 KiB
C++
/***************************************************************************
|
|
qgscurvev2.cpp
|
|
--------------
|
|
begin : November 2014
|
|
copyright : (C) 2014 by Marco Hugentobler
|
|
email : marco at sourcepole dot ch
|
|
***************************************************************************/
|
|
|
|
/***************************************************************************
|
|
* *
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
* it under the terms of the GNU General Public License as published by *
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
* (at your option) any later version. *
|
|
* *
|
|
***************************************************************************/
|
|
|
|
#include "qgscurvev2.h"
|
|
#include "qgslinestringv2.h"
|
|
|
|
QgsCurveV2::QgsCurveV2(): QgsAbstractGeometryV2()
|
|
{}
|
|
|
|
QgsCurveV2::~QgsCurveV2()
|
|
{}
|
|
|
|
bool QgsCurveV2::isClosed() const
|
|
{
|
|
if ( numPoints() == 0 )
|
|
return false;
|
|
|
|
//don't consider M-coordinates when testing closedness
|
|
QgsPointV2 start = startPoint();
|
|
QgsPointV2 end = endPoint();
|
|
return ( qgsDoubleNear( start.x(), end.x(), 1E-8 ) &&
|
|
qgsDoubleNear( start.y(), end.y(), 1E-8 ) &&
|
|
qgsDoubleNear( start.z(), end.z(), 1E-8 ) );
|
|
}
|
|
|
|
bool QgsCurveV2::isRing() const
|
|
{
|
|
return ( isClosed() && numPoints() >= 4 );
|
|
}
|
|
|
|
void QgsCurveV2::coordinateSequence( QList< QList< QList< QgsPointV2 > > >& coord ) const
|
|
{
|
|
coord.clear();
|
|
QList<QgsPointV2> pts;
|
|
points( pts );
|
|
QList< QList<QgsPointV2> > ptsList;
|
|
ptsList.append( pts );
|
|
coord.append( ptsList );
|
|
}
|
|
|
|
bool QgsCurveV2::nextVertex( QgsVertexId& id, QgsPointV2& vertex ) const
|
|
{
|
|
if ( id.vertex < 0 )
|
|
{
|
|
id.vertex = 0;
|
|
if ( id.part < 0 )
|
|
{
|
|
id.part = 0;
|
|
}
|
|
if ( id.ring < 0 )
|
|
{
|
|
id.ring = 0;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if ( id.vertex + 1 >= numPoints() )
|
|
{
|
|
return false;
|
|
}
|
|
++id.vertex;
|
|
}
|
|
return pointAt( id.vertex, vertex, id.type );
|
|
}
|
|
|
|
QgsAbstractGeometryV2* QgsCurveV2::segmentize() const
|
|
{
|
|
return curveToLine();
|
|
}
|
|
|
|
QgsPointV2 QgsCurveV2::vertexAt( const QgsVertexId& id ) const
|
|
{
|
|
QgsPointV2 v;
|
|
QgsVertexId::VertexType type;
|
|
pointAt( id.vertex, v, type );
|
|
return v;
|
|
}
|