Skip to content
Permalink
Browse files

Rename QgsMultiPolyline to QgsMultiPolylineXY

  • Loading branch information
m-kuhn committed Oct 29, 2017
1 parent 29e65ed commit b7908744e3801bda47a37b1f2b65117e4091e3a3
@@ -23,7 +23,7 @@ typedef QVector<QVector<QgsPointXY>> QgsPolygonXY;

typedef QVector<QgsPointXY> QgsMultiPointXY;

typedef QVector<QVector<QgsPointXY>> QgsMultiPolyline;
typedef QVector<QVector<QgsPointXY>> QgsMultiPolylineXY;

typedef QVector<QVector<QVector<QgsPointXY>>> QgsMultiPolygon;

@@ -184,9 +184,9 @@ Creates a new geometry from a QgsMultiPointXY object
:rtype: QgsGeometry
%End

static QgsGeometry fromMultiPolyline( const QgsMultiPolyline &multiline );
static QgsGeometry fromMultiPolyline( const QgsMultiPolylineXY &multiline );
%Docstring
Creates a new geometry from a QgsMultiPolyline object
Creates a new geometry from a QgsMultiPolylineXY object
:rtype: QgsGeometry
%End
static QgsGeometry fromPolygon( const QgsPolygonXY &polygon );
@@ -1158,11 +1158,11 @@ Returns an extruded version of this geometry.
:rtype: QgsMultiPointXY
%End

QgsMultiPolyline asMultiPolyline() const;
QgsMultiPolylineXY asMultiPolyline() const;
%Docstring
Returns contents of the geometry as a multi linestring
if wkbType is WKBMultiLineString, otherwise an empty list
:rtype: QgsMultiPolyline
:rtype: QgsMultiPolylineXY
%End

QgsMultiPolygon asMultiPolygon() const;
@@ -164,13 +164,13 @@ void QgsVectorLayerDirector::makeGraph( QgsGraphBuilderInterface *builder, const
return;
}

QgsMultiPolyline mpl;
QgsMultiPolylineXY mpl;
if ( QgsWkbTypes::flatType( feature.geometry().wkbType() ) == QgsWkbTypes::MultiLineString )
mpl = feature.geometry().asMultiPolyline();
else if ( QgsWkbTypes::flatType( feature.geometry().wkbType() ) == QgsWkbTypes::LineString )
mpl.push_back( feature.geometry().asPolyline() );

QgsMultiPolyline::iterator mplIt;
QgsMultiPolylineXY::iterator mplIt;
for ( mplIt = mpl.begin(); mplIt != mpl.end(); ++mplIt )
{
QgsPointXY pt1, pt2;
@@ -307,13 +307,13 @@ void QgsVectorLayerDirector::makeGraph( QgsGraphBuilderInterface *builder, const
}

// begin features segments and add arc to the Graph;
QgsMultiPolyline mpl;
QgsMultiPolylineXY mpl;
if ( QgsWkbTypes::flatType( feature.geometry().wkbType() ) == QgsWkbTypes::MultiLineString )
mpl = feature.geometry().asMultiPolyline();
else if ( QgsWkbTypes::flatType( feature.geometry().wkbType() ) == QgsWkbTypes::LineString )
mpl.push_back( feature.geometry().asPolyline() );

QgsMultiPolyline::iterator mplIt;
QgsMultiPolylineXY::iterator mplIt;
for ( mplIt = mpl.begin(); mplIt != mpl.end(); ++mplIt )
{
QgsPointXY pt1, pt2;
@@ -145,7 +145,7 @@ QgsGeometry QgsMapToolDeletePart::partUnderPoint( QPoint point, QgsFeatureId &fi
}
if ( g.wkbType() == QgsWkbTypes::MultiLineString || g.wkbType() == QgsWkbTypes::MultiLineString25D )
{
QgsMultiPolyline mline = g.asMultiPolyline();
QgsMultiPolylineXY mline = g.asMultiPolyline();
for ( int part = 0; part < mline.count(); part++ )
{
if ( snapVertex < mline[part].count() )
@@ -462,8 +462,8 @@ QgsGeometry QgsMapToolOffsetCurve::convertToSingleLine( const QgsGeometry &geom,
//search vertex
isMulti = true;
int currentVertex = 0;
QgsMultiPolyline multiLine = geom.asMultiPolyline();
QgsMultiPolyline::const_iterator it = multiLine.constBegin();
QgsMultiPolylineXY multiLine = geom.asMultiPolyline();
QgsMultiPolylineXY::const_iterator it = multiLine.constBegin();
for ( ; it != multiLine.constEnd(); ++it )
{
currentVertex += it->size();
@@ -201,7 +201,7 @@ QgsGeometry QgsGeometry::fromMultiPoint( const QgsMultiPointXY &multipoint )
return QgsGeometry();
}

QgsGeometry QgsGeometry::fromMultiPolyline( const QgsMultiPolyline &multiline )
QgsGeometry QgsGeometry::fromMultiPolyline( const QgsMultiPolylineXY &multiline )
{
std::unique_ptr< QgsMultiLineString > geom = QgsGeometryFactory::fromMultiPolyline( multiline );
if ( geom )
@@ -1394,26 +1394,26 @@ QgsMultiPointXY QgsGeometry::asMultiPoint() const
return multiPoint;
}

QgsMultiPolyline QgsGeometry::asMultiPolyline() const
QgsMultiPolylineXY QgsGeometry::asMultiPolyline() const
{
if ( !d->geometry )
{
return QgsMultiPolyline();
return QgsMultiPolylineXY();
}

QgsGeometryCollection *geomCollection = qgsgeometry_cast<QgsGeometryCollection *>( d->geometry.get() );
if ( !geomCollection )
{
return QgsMultiPolyline();
return QgsMultiPolylineXY();
}

int nLines = geomCollection->numGeometries();
if ( nLines < 1 )
{
return QgsMultiPolyline();
return QgsMultiPolylineXY();
}

QgsMultiPolyline mpl;
QgsMultiPolylineXY mpl;
for ( int i = 0; i < nLines; ++i )
{
const QgsLineString *line = qgsgeometry_cast<const QgsLineString *>( geomCollection->geometryN( i ) );
@@ -2828,7 +2828,7 @@ QgsGeometry QgsGeometry::convertToPoint( bool destMultipart ) const
// input geometry is multipart
if ( isMultipart() )
{
const QgsMultiPolyline multiLine = asMultiPolyline();
const QgsMultiPolylineXY multiLine = asMultiPolyline();
QgsMultiPointXY multiPoint;
for ( const QgsPolylineXY &l : multiLine )
for ( const QgsPointXY &p : l )
@@ -2893,7 +2893,7 @@ QgsGeometry QgsGeometry::convertToLine( bool destMultipart ) const
return QgsGeometry();

if ( destMultipart )
return fromMultiPolyline( QgsMultiPolyline() << multiPoint );
return fromMultiPolyline( QgsMultiPolylineXY() << multiPoint );
else
return fromPolylineXY( multiPoint );
}
@@ -2913,12 +2913,12 @@ QgsGeometry QgsGeometry::convertToLine( bool destMultipart ) const
// destination is multipart => makes a multipoint with a single line
QgsPolylineXY line = asPolyline();
if ( !line.isEmpty() )
return fromMultiPolyline( QgsMultiPolyline() << line );
return fromMultiPolyline( QgsMultiPolylineXY() << line );
}
else
{
// destination is singlepart => make a single part if possible
QgsMultiPolyline multiLine = asMultiPolyline();
QgsMultiPolylineXY multiLine = asMultiPolyline();
if ( multiLine.count() == 1 )
return fromPolylineXY( multiLine[0] );
}
@@ -2931,7 +2931,7 @@ QgsGeometry QgsGeometry::convertToLine( bool destMultipart ) const
if ( isMultipart() )
{
const QgsMultiPolygon multiPolygon = asMultiPolygon();
QgsMultiPolyline multiLine;
QgsMultiPolylineXY multiLine;
for ( const QgsPolygonXY &poly : multiPolygon )
for ( const QgsPolylineXY &line : poly )
multiLine << line;
@@ -2959,7 +2959,7 @@ QgsGeometry QgsGeometry::convertToLine( bool destMultipart ) const
if ( destMultipart )
{
const QgsPolygonXY polygon = asPolygon();
QgsMultiPolyline multiLine;
QgsMultiPolylineXY multiLine;
for ( const QgsPolylineXY &line : polygon )
multiLine << line;
return fromMultiPolyline( multiLine );
@@ -3014,9 +3014,9 @@ QgsGeometry QgsGeometry::convertToPolygon( bool destMultipart ) const
// input geometry is multiline
if ( isMultipart() )
{
QgsMultiPolyline multiLine = asMultiPolyline();
QgsMultiPolylineXY multiLine = asMultiPolyline();
QgsMultiPolygon multiPolygon;
for ( QgsMultiPolyline::iterator multiLineIt = multiLine.begin(); multiLineIt != multiLine.end(); ++multiLineIt )
for ( QgsMultiPolylineXY::iterator multiLineIt = multiLine.begin(); multiLineIt != multiLine.end(); ++multiLineIt )
{
// do not create polygon for a 1 segment line
if ( ( *multiLineIt ).count() < 3 )
@@ -80,9 +80,9 @@ typedef QVector<QgsPointXY> QgsMultiPointXY;

//! A collection of QgsPolylines that share a common collection of attributes
#ifndef SIP_RUN
typedef QVector<QgsPolylineXY> QgsMultiPolyline;
typedef QVector<QgsPolylineXY> QgsMultiPolylineXY;
#else
typedef QVector<QVector<QgsPointXY>> QgsMultiPolyline;
typedef QVector<QVector<QgsPointXY>> QgsMultiPolylineXY;
#endif

//! A collection of QgsPolygons that share a common collection of attributes
@@ -241,8 +241,8 @@ class CORE_EXPORT QgsGeometry
*/
static QgsGeometry fromPolyline( const QgsPolyline &polyline );

//! Creates a new geometry from a QgsMultiPolyline object
static QgsGeometry fromMultiPolyline( const QgsMultiPolyline &multiline );
//! Creates a new geometry from a QgsMultiPolylineXY object
static QgsGeometry fromMultiPolyline( const QgsMultiPolylineXY &multiline );
//! Creates a new geometry from a QgsPolygon
static QgsGeometry fromPolygon( const QgsPolygonXY &polygon );
//! Creates a new geometry from a QgsMultiPolygon
@@ -1164,7 +1164,7 @@ class CORE_EXPORT QgsGeometry
* Returns contents of the geometry as a multi linestring
* if wkbType is WKBMultiLineString, otherwise an empty list
*/
QgsMultiPolyline asMultiPolyline() const;
QgsMultiPolylineXY asMultiPolyline() const;

/**
* Returns contents of the geometry as a multi polygon
@@ -154,7 +154,7 @@ std::unique_ptr<QgsAbstractGeometry> QgsGeometryFactory::fromPolyline( const Qgs
return linestringFromPolyline( polyline );
}

std::unique_ptr<QgsMultiLineString> QgsGeometryFactory::fromMultiPolyline( const QgsMultiPolyline &multiline )
std::unique_ptr<QgsMultiLineString> QgsGeometryFactory::fromMultiPolyline( const QgsMultiPolylineXY &multiline )
{
std::unique_ptr< QgsMultiLineString > mLine = qgis::make_unique< QgsMultiLineString >();
for ( int i = 0; i < multiline.size(); ++i )
@@ -39,7 +39,7 @@ class QgsMultiPolygonV2;
typedef QVector<QgsPointXY> QgsPolylineXY;
typedef QVector<QgsPolylineXY> QgsPolygonXY;
typedef QVector<QgsPointXY> QgsMultiPointXY;
typedef QVector<QgsPolylineXY> QgsMultiPolyline;
typedef QVector<QgsPolylineXY> QgsMultiPolylineXY;
typedef QVector<QgsPolygonXY> QgsMultiPolygon;

/**
@@ -71,7 +71,7 @@ class CORE_EXPORT QgsGeometryFactory
//! Construct geometry from a polyline
static std::unique_ptr< QgsAbstractGeometry > fromPolyline( const QgsPolylineXY &polyline );
//! Construct geometry from a multipolyline
static std::unique_ptr<QgsMultiLineString> fromMultiPolyline( const QgsMultiPolyline &multiline );
static std::unique_ptr<QgsMultiLineString> fromMultiPolyline( const QgsMultiPolylineXY &multiline );
//! Construct geometry from a polygon
static std::unique_ptr<QgsPolygonV2> fromPolygon( const QgsPolygonXY &polygon );
//! Construct geometry from a multipolygon
@@ -272,7 +272,7 @@ void QgsGeometryValidator::run()
}
else if ( flatType == QgsWkbTypes::MultiLineString )
{
QgsMultiPolyline mp = mGeometry.asMultiPolyline();
QgsMultiPolylineXY mp = mGeometry.asMultiPolyline();
for ( int i = 0; !mStop && i < mp.size(); i++ )
validatePolyline( i, mp[i] );
}
@@ -262,7 +262,7 @@ QgsGeometry QgsOgcUtils::geometryFromGMLLineString( const QDomElement &geometryE
QgsGeometry QgsOgcUtils::geometryFromGMLPolygon( const QDomElement &geometryElement )
{
//read all the coordinates (as QgsPoint) into memory. Each linear ring has an entry in the vector
QgsMultiPolyline ringCoordinates;
QgsMultiPolylineXY ringCoordinates;

//read coordinates for outer boundary
QgsPolylineXY exteriorPointList;
@@ -340,7 +340,7 @@ QgsGeometry QgsOgcUtils::geometryFromGMLPolygon( const QDomElement &geometryElem
return QgsGeometry();

int npoints = 0;//total number of points
for ( QgsMultiPolyline::const_iterator it = ringCoordinates.constBegin(); it != ringCoordinates.constEnd(); ++it )
for ( QgsMultiPolylineXY::const_iterator it = ringCoordinates.constBegin(); it != ringCoordinates.constEnd(); ++it )
{
npoints += it->size();
}
@@ -362,7 +362,7 @@ QgsGeometry QgsOgcUtils::geometryFromGMLPolygon( const QDomElement &geometryElem
wkbPosition += sizeof( int );
memcpy( &( wkb )[wkbPosition], &nrings, sizeof( int ) );
wkbPosition += sizeof( int );
for ( QgsMultiPolyline::const_iterator it = ringCoordinates.constBegin(); it != ringCoordinates.constEnd(); ++it )
for ( QgsMultiPolylineXY::const_iterator it = ringCoordinates.constBegin(); it != ringCoordinates.constEnd(); ++it )
{
nPointsInRing = it->size();
memcpy( &( wkb )[wkbPosition], &nPointsInRing, sizeof( int ) );
@@ -409,7 +409,7 @@ void resetGraph( QgsTracerGraph &g )
}


void extractLinework( const QgsGeometry &g, QgsMultiPolyline &mpl )
void extractLinework( const QgsGeometry &g, QgsMultiPolylineXY &mpl )
{
QgsGeometry geom = g;
// segmentize curved geometries - we will use noding algorithm from GEOS
@@ -463,7 +463,7 @@ bool QgsTracer::initGraph()
mHasTopologyProblem = false;

QgsFeature f;
QgsMultiPolyline mpl;
QgsMultiPolylineXY mpl;

// extract linestrings

@@ -535,7 +535,7 @@ int QgsVectorLayerEditUtils::addTopologicalPoints( const QgsGeometry &geom )
case QgsWkbTypes::MultiLineString25D:
case QgsWkbTypes::MultiLineString:
{
QgsMultiPolyline multiLine = geom.asMultiPolyline();
QgsMultiPolylineXY multiLine = geom.asMultiPolyline();
QgsPolylineXY currentPolyline;

for ( int i = 0; i < multiLine.size(); ++i )
@@ -793,7 +793,7 @@ QList<QPolygonF> offsetLine( QPolygonF polyline, double dist, QgsWkbTypes::Geome
}
else if ( QgsWkbTypes::flatType( tempGeometry.wkbType() ) == QgsWkbTypes::MultiLineString )
{
QgsMultiPolyline tempMPolyline = tempGeometry.asMultiPolyline();
QgsMultiPolylineXY tempMPolyline = tempGeometry.asMultiPolyline();
resultLine.reserve( tempMPolyline.count() );
for ( int part = 0; part < tempMPolyline.count(); ++part )
{
@@ -293,7 +293,7 @@ void QgsHighlight::paint( QPainter *p )
}
else
{
QgsMultiPolyline m = mGeometry->asMultiPolyline();
QgsMultiPolylineXY m = mGeometry->asMultiPolyline();

for ( int i = 0; i < m.size(); i++ )
{
@@ -301,7 +301,7 @@ void QgsRubberBand::addGeometry( const QgsGeometry &geometry, const QgsCoordinat
case QgsWkbTypes::MultiLineString25D:
{

const QgsMultiPolyline mline = geom.asMultiPolyline();
const QgsMultiPolylineXY mline = geom.asMultiPolyline();
for ( const QgsPolylineXY &line : mline )
{
if ( line.isEmpty() )
@@ -634,7 +634,7 @@ QgsGeometry QgsRubberBand::asGeometry() const
{
if ( mPoints.size() > 1 )
{
QgsMultiPolyline multiPolyline;
QgsMultiPolylineXY multiPolyline;
QList< QList<QgsPointXY> >::const_iterator it = mPoints.constBegin();
for ( ; it != mPoints.constEnd(); ++it )
{
@@ -285,7 +285,7 @@ ErrorList topolTest::checkDanglingLines( double tolerance, QgsVectorLayer *layer

if ( g1.isMultipart() )
{
QgsMultiPolyline lines = g1.asMultiPolyline();
QgsMultiPolylineXY lines = g1.asMultiPolyline();
for ( int m = 0; m < lines.count(); m++ )
{
QgsPolylineXY line = lines[m];
@@ -772,7 +772,7 @@ ErrorList topolTest::checkPseudos( double tolerance, QgsVectorLayer *layer1, Qgs

if ( g1.isMultipart() )
{
QgsMultiPolyline lines = g1.asMultiPolyline();
QgsMultiPolylineXY lines = g1.asMultiPolyline();
for ( int m = 0; m < lines.count(); m++ )
{
QgsPolylineXY line = lines[m];
@@ -985,7 +985,7 @@ ErrorList topolTest::checkSegmentLength( double tolerance, QgsVectorLayer *layer
QgsMultiPolygon mpol;
QgsPolylineXY segm;
QgsPolylineXY ls;
QgsMultiPolyline mls;
QgsMultiPolylineXY mls;
QList<FeatureLayer> fls;
TopolErrorShort *err = nullptr;
double distance;
@@ -271,7 +271,7 @@ int main( int argc, char **argv )
}
else if ( geometryType == QgsWkbTypes::MultiLineString )
{
QgsMultiPolyline multiPolyline = geometry.asMultiPolyline();
QgsMultiPolylineXY multiPolyline = geometry.asMultiPolyline();
Q_FOREACH ( const QgsPolylineXY &polyline, multiPolyline )
{
writePolyline( map, GV_LINE, polyline, cats );
wkt = QStringLiteral( "MultiLineString ((0 0, 10 0, 10 10, 20 10),(30 30, 40 30, 40 40, 50 40))" );
geom = QgsGeometry::fromWkt( wkt );
result = geom.smooth( 1, 0.25 );
QgsMultiPolyline multiLine = result.asMultiPolyline();
QgsMultiPolyline expectedMultiline;
QgsMultiPolylineXY multiLine = result.asMultiPolyline();
QgsMultiPolylineXY expectedMultiline;
expectedMultiline << ( QgsPolylineXY() << QgsPointXY( 0, 0 ) << QgsPointXY( 7.5, 0 ) << QgsPointXY( 10.0, 2.5 )
<< QgsPointXY( 10.0, 7.5 ) << QgsPointXY( 12.5, 10.0 ) << QgsPointXY( 20.0, 10.0 ) )
<< ( QgsPolylineXY() << QgsPointXY( 30.0, 30.0 ) << QgsPointXY( 37.5, 30.0 ) << QgsPointXY( 40.0, 32.5 )

0 comments on commit b790874

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