Skip to content

Commit

Permalink
use QgsWkbTypes methods to simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Oct 5, 2016
1 parent 5b67d2a commit 33644ef
Showing 1 changed file with 2 additions and 75 deletions.
77 changes: 2 additions & 75 deletions src/providers/memory/qgsmemoryprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,35 +47,7 @@ QgsMemoryProvider::QgsMemoryProvider( const QString& uri )
geometry = url.path();
}

geometry = geometry.toLower();
if ( geometry == "point" )
mWkbType = QgsWkbTypes::Point;
else if ( geometry == "linestring" )
mWkbType = QgsWkbTypes::LineString;
else if ( geometry == "polygon" )
mWkbType = QgsWkbTypes::Polygon;
else if ( geometry == "multipoint" )
mWkbType = QgsWkbTypes::MultiPoint;
else if ( geometry == "multilinestring" )
mWkbType = QgsWkbTypes::MultiLineString;
else if ( geometry == "multipolygon" )
mWkbType = QgsWkbTypes::MultiPolygon;
else if ( geometry == "point25d" )
mWkbType = QgsWkbTypes::Point25D;
else if ( geometry == "linestring25d" )
mWkbType = QgsWkbTypes::LineString25D;
else if ( geometry == "polygon25d" )
mWkbType = QgsWkbTypes::Polygon25D;
else if ( geometry == "multipoint25d" )
mWkbType = QgsWkbTypes::MultiPoint25D;
else if ( geometry == "multilinestring25d" )
mWkbType = QgsWkbTypes::MultiLineString25D;
else if ( geometry == "multipolygon25d" )
mWkbType = QgsWkbTypes::MultiPolygon25D;
else if ( geometry == "none" )
mWkbType = QgsWkbTypes::NoGeometry;
else
mWkbType = QgsWkbTypes::Unknown;
mWkbType = QgsWkbTypes::parseType( geometry );

if ( url.hasQueryItem( "crs" ) )
{
Expand Down Expand Up @@ -220,52 +192,7 @@ QString QgsMemoryProvider::dataSourceUri( bool expandAuthConfig ) const
Q_UNUSED( expandAuthConfig )

QUrl uri( "memory" );
QString geometry;
switch ( mWkbType )
{
case QgsWkbTypes::Point :
geometry = "Point";
break;
case QgsWkbTypes::LineString :
geometry = "LineString";
break;
case QgsWkbTypes::Polygon :
geometry = "Polygon";
break;
case QgsWkbTypes::MultiPoint :
geometry = "MultiPoint";
break;
case QgsWkbTypes::MultiLineString :
geometry = "MultiLineString";
break;
case QgsWkbTypes::MultiPolygon :
geometry = "MultiPolygon";
break;
case QgsWkbTypes::Point25D :
geometry = "Point25D";
break;
case QgsWkbTypes::LineString25D :
geometry = "LineString25D";
break;
case QgsWkbTypes::Polygon25D :
geometry = "Polygon25D";
break;
case QgsWkbTypes::MultiPoint25D :
geometry = "MultiPoint25D";
break;
case QgsWkbTypes::MultiLineString25D :
geometry = "MultiLineString25D";
break;
case QgsWkbTypes::MultiPolygon25D :
geometry = "MultiPolygon25D";
break;
case QgsWkbTypes::NoGeometry :
geometry = "None";
break;
default:
geometry = "";
break;
}
QString geometry = QgsWkbTypes::displayString( mWkbType );
uri.addQueryItem( "geometry", geometry );

if ( mCrs.isValid() )
Expand Down

0 comments on commit 33644ef

Please sign in to comment.