Skip to content
Permalink
Browse files

Fix rubber band handing of curved geometries (#5790)

  • Loading branch information
nirvn committed Dec 2, 2017
1 parent f8788b9 commit d0e927a84f8aba58e15856a04fc2f8ba61be9dcc
Showing with 47 additions and 69 deletions.
  1. +47 −69 src/gui/qgsrubberband.cpp
@@ -261,97 +261,75 @@ void QgsRubberBand::addGeometry( const QgsGeometry &geometry, const QgsCoordinat
geom.transform( ct );
}

switch ( QgsWkbTypes::flatType( geom.wkbType() ) )
QgsWkbTypes::Type geomType = geom.wkbType();
if ( QgsWkbTypes::geometryType( geomType ) == QgsWkbTypes::PointGeometry && !QgsWkbTypes::isMultiType( geomType ) )
{

case QgsWkbTypes::Point:
case QgsWkbTypes::Point25D:
QgsPointXY pt = geom.asPoint();
addPoint( pt, false, idx );
removeLastPoint( idx, false );
}
else if ( QgsWkbTypes::geometryType( geomType ) == QgsWkbTypes::PointGeometry && QgsWkbTypes::isMultiType( geomType ) )
{
const QgsMultiPointXY mpt = geom.asMultiPoint();
for ( QgsPointXY pt : mpt )
{
QgsPointXY pt = geom.asPoint();
addPoint( pt, false, idx );
removeLastPoint( idx, false );
idx++;
}
break;

case QgsWkbTypes::MultiPoint:
case QgsWkbTypes::MultiPoint25D:
}
else if ( QgsWkbTypes::geometryType( geomType ) == QgsWkbTypes::LineGeometry && !QgsWkbTypes::isMultiType( geomType ) )
{
const QgsPolylineXY line = geom.asPolyline();
for ( QgsPointXY pt : line )
{
const QgsMultiPointXY mpt = geom.asMultiPoint();
for ( QgsPointXY pt : mpt )
{
addPoint( pt, false, idx );
removeLastPoint( idx, false );
idx++;
}
addPoint( pt, false, idx );
}
break;

case QgsWkbTypes::LineString:
case QgsWkbTypes::LineString25D:
}
else if ( QgsWkbTypes::geometryType( geomType ) == QgsWkbTypes::LineGeometry && QgsWkbTypes::isMultiType( geomType ) )
{
const QgsMultiPolylineXY mline = geom.asMultiPolyline();
for ( const QgsPolylineXY &line : mline )
{
const QgsPolylineXY line = geom.asPolyline();
if ( line.isEmpty() )
{
continue;
}
for ( QgsPointXY pt : line )
{
addPoint( pt, false, idx );
}
idx++;
}
break;

case QgsWkbTypes::MultiLineString:
case QgsWkbTypes::MultiLineString25D:
}
else if ( QgsWkbTypes::geometryType( geomType ) == QgsWkbTypes::PolygonGeometry && !QgsWkbTypes::isMultiType( geomType ) )
{
const QgsPolygonXY poly = geom.asPolygon();
const QgsPolylineXY line = poly.at( 0 );
for ( QgsPointXY pt : line )
{

const QgsMultiPolylineXY mline = geom.asMultiPolyline();
for ( const QgsPolylineXY &line : mline )
{
if ( line.isEmpty() )
{
continue;
}

for ( QgsPointXY pt : line )
{
addPoint( pt, false, idx );
}
idx++;
}
addPoint( pt, false, idx );
}
break;

case QgsWkbTypes::Polygon:
case QgsWkbTypes::Polygon25D:
}
else if ( QgsWkbTypes::geometryType( geomType ) == QgsWkbTypes::PolygonGeometry && QgsWkbTypes::isMultiType( geomType ) )
{
const QgsMultiPolygonXY multipoly = geom.asMultiPolygon();
for ( const QgsPolygonXY &poly : multipoly )
{
const QgsPolygonXY poly = geom.asPolygon();
if ( poly.empty() )
continue;

const QgsPolylineXY line = poly.at( 0 );
for ( QgsPointXY pt : line )
{
addPoint( pt, false, idx );
}
idx++;
}
break;

case QgsWkbTypes::MultiPolygon:
case QgsWkbTypes::MultiPolygon25D:
{
const QgsMultiPolygonXY multipoly = geom.asMultiPolygon();
for ( const QgsPolygonXY &poly : multipoly )
{
if ( poly.empty() )
continue;

const QgsPolylineXY line = poly.at( 0 );
for ( QgsPointXY pt : line )
{
addPoint( pt, false, idx );
}
idx++;
}
}
break;

case QgsWkbTypes::Unknown:
default:
return;
}
else
{
return;
}

setVisible( true );

0 comments on commit d0e927a

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