Skip to content

Commit

Permalink
Rename QgsMultiPolyline to QgsMultiPolylineXY
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Oct 30, 2017
1 parent 29e65ed commit b790874
Show file tree
Hide file tree
Showing 19 changed files with 53 additions and 53 deletions.
10 changes: 5 additions & 5 deletions python/core/geometry/qgsgeometry.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/analysis/network/qgsvectorlayerdirector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptooldeletepart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() )
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsmaptooloffsetcurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
28 changes: 14 additions & 14 deletions src/core/geometry/qgsgeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down Expand Up @@ -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 ) );
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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 );
}
Expand All @@ -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] );
}
Expand All @@ -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;
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 )
Expand Down
10 changes: 5 additions & 5 deletions src/core/geometry/qgsgeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/core/geometry/qgsgeometryfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
4 changes: 2 additions & 2 deletions src/core/geometry/qgsgeometryfactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsgeometryvalidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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] );
}
Expand Down
6 changes: 3 additions & 3 deletions src/core/qgsogcutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
Expand All @@ -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 ) );
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgstracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -463,7 +463,7 @@ bool QgsTracer::initGraph()
mHasTopologyProblem = false;

QgsFeature f;
QgsMultiPolyline mpl;
QgsMultiPolylineXY mpl;

// extract linestrings

Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectorlayereditutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
2 changes: 1 addition & 1 deletion src/core/symbology/qgssymbollayerutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgshighlight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++ )
{
Expand Down
4 changes: 2 additions & 2 deletions src/gui/qgsrubberband.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() )
Expand Down Expand Up @@ -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 )
{
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/topology/topolTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/providers/grass/qgis.v.in.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
4 changes: 2 additions & 2 deletions tests/src/core/testqgsgeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15058,8 +15058,8 @@ void TestQgsGeometry::smoothCheck()
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 )
Expand Down
Loading

0 comments on commit b790874

Please sign in to comment.