Skip to content
Permalink
Browse files

Use QLatin1String for geometry representation operations

  • Loading branch information
m-kuhn committed Mar 1, 2019
1 parent 7d83263 commit 3359a7159ce37e2fa0a82c2e996961345ae0f516
@@ -245,7 +245,7 @@ QByteArray QgsCompoundCurve::asWkb() const

QString QgsCompoundCurve::asWkt( int precision ) const
{
QString wkt = wktTypeStr() + " (";
QString wkt = wktTypeStr() + QLatin1String( " (" );
for ( const QgsCurve *curve : mCurves )
{
QString childWkt = curve->asWkt( precision );
@@ -311,7 +311,7 @@ QByteArray QgsCurvePolygon::asWkb() const

QString QgsCurvePolygon::asWkt( int precision ) const
{
QString wkt = wktTypeStr() + " (";
QString wkt = wktTypeStr() + QLatin1String( " (" );
if ( mExteriorRing )
{
QString childWkt = mExteriorRing->asWkt( precision );
@@ -405,15 +405,15 @@ QString QgsCurvePolygon::asJson( int precision ) const
std::unique_ptr< QgsLineString > exteriorLineString( exteriorRing()->curveToLine() );
QgsPointSequence exteriorPts;
exteriorLineString->points( exteriorPts );
json += QgsGeometryUtils::pointsToJSON( exteriorPts, precision ) + ", ";
json += QgsGeometryUtils::pointsToJSON( exteriorPts, precision ) + QLatin1String( ", " );

std::unique_ptr< QgsLineString > interiorLineString;
for ( int i = 0, n = numInteriorRings(); i < n; ++i )
{
interiorLineString.reset( interiorRing( i )->curveToLine() );
QgsPointSequence interiorPts;
interiorLineString->points( interiorPts );
json += QgsGeometryUtils::pointsToJSON( interiorPts, precision ) + ", ";
json += QgsGeometryUtils::pointsToJSON( interiorPts, precision ) + QLatin1String( ", " );
}
if ( json.endsWith( QLatin1String( ", " ) ) )
{
@@ -374,7 +374,7 @@ QByteArray QgsGeometryCollection::asWkb() const

QString QgsGeometryCollection::asWkt( int precision ) const
{
QString wkt = wktTypeStr() + " (";
QString wkt = wktTypeStr() + QLatin1String( " (" );
for ( const QgsAbstractGeometry *geom : mGeometries )
{
QString childWkt = geom->asWkt( precision );
@@ -421,7 +421,7 @@ QString QgsGeometryCollection::asJson( int precision ) const
QString json = QStringLiteral( "{\"type\": \"GeometryCollection\", \"geometries\": [" );
for ( const QgsAbstractGeometry *geom : mGeometries )
{
json += geom->asJson( precision ) + ", ";
json += geom->asJson( precision ) + QLatin1String( ", " );
}
if ( json.endsWith( QLatin1String( ", " ) ) )
{
@@ -1184,7 +1184,7 @@ QString QgsGeometryUtils::pointsToJSON( const QgsPointSequence &points, int prec
QString json = QStringLiteral( "[ " );
for ( const QgsPoint &p : points )
{
json += '[' + qgsDoubleToString( p.x(), precision ) + ", " + qgsDoubleToString( p.y(), precision ) + "], ";
json += '[' + qgsDoubleToString( p.x(), precision ) + QLatin1String( ", " ) + qgsDoubleToString( p.y(), precision ) + QLatin1String( "], " );
}
if ( json.endsWith( QLatin1String( ", " ) ) )
{
@@ -119,7 +119,7 @@ QString QgsMultiCurve::asJson( int precision ) const
std::unique_ptr< QgsLineString > lineString( static_cast<const QgsCurve *>( geom )->curveToLine() );
QgsPointSequence pts;
lineString->points( pts );
json += QgsGeometryUtils::pointsToJSON( pts, precision ) + ", ";
json += QgsGeometryUtils::pointsToJSON( pts, precision ) + QLatin1String( ", " );
}
}
if ( json.endsWith( QLatin1String( ", " ) ) )
@@ -105,7 +105,7 @@ QString QgsMultiLineString::asJson( int precision ) const
const QgsLineString *lineString = static_cast<const QgsLineString *>( geom );
QgsPointSequence pts;
lineString->points( pts );
json += QgsGeometryUtils::pointsToJSON( pts, precision ) + ", ";
json += QgsGeometryUtils::pointsToJSON( pts, precision ) + QLatin1String( ", " );
}
}
if ( json.endsWith( QLatin1String( ", " ) ) )
@@ -111,15 +111,15 @@ QString QgsMultiPolygon::asJson( int precision ) const
std::unique_ptr< QgsLineString > exteriorLineString( polygon->exteriorRing()->curveToLine() );
QgsPointSequence exteriorPts;
exteriorLineString->points( exteriorPts );
json += QgsGeometryUtils::pointsToJSON( exteriorPts, precision ) + ", ";
json += QgsGeometryUtils::pointsToJSON( exteriorPts, precision ) + QLatin1String( ", " );

std::unique_ptr< QgsLineString > interiorLineString;
for ( int i = 0, n = polygon->numInteriorRings(); i < n; ++i )
{
interiorLineString.reset( polygon->interiorRing( i )->curveToLine() );
QgsPointSequence interiorPts;
interiorLineString->points( interiorPts );
json += QgsGeometryUtils::pointsToJSON( interiorPts, precision ) + ", ";
json += QgsGeometryUtils::pointsToJSON( interiorPts, precision ) + QLatin1String( ", " );
}
if ( json.endsWith( QLatin1String( ", " ) ) )
{
@@ -121,15 +121,15 @@ QString QgsMultiSurface::asJson( int precision ) const
std::unique_ptr< QgsLineString > exteriorLineString( polygon->exteriorRing()->curveToLine() );
QgsPointSequence exteriorPts;
exteriorLineString->points( exteriorPts );
json += QgsGeometryUtils::pointsToJSON( exteriorPts, precision ) + ", ";
json += QgsGeometryUtils::pointsToJSON( exteriorPts, precision ) + QLatin1String( ", " );

std::unique_ptr< QgsLineString > interiorLineString;
for ( int i = 0, n = polygon->numInteriorRings(); i < n; ++i )
{
interiorLineString.reset( polygon->interiorRing( i )->curveToLine() );
QgsPointSequence interiorPts;
interiorLineString->points( interiorPts );
json += QgsGeometryUtils::pointsToJSON( interiorPts, precision ) + ", ";
json += QgsGeometryUtils::pointsToJSON( interiorPts, precision ) + QLatin1String( ", " );
}
if ( json.endsWith( QLatin1String( ", " ) ) )
{
@@ -222,7 +222,7 @@ QByteArray QgsPoint::asWkb() const

QString QgsPoint::asWkt( int precision ) const
{
QString wkt = wktTypeStr() + " (";
QString wkt = wktTypeStr() + QLatin1String( " (" );
wkt += qgsDoubleToString( mX, precision ) + ' ' + qgsDoubleToString( mY, precision );
if ( is3D() )
wkt += ' ' + qgsDoubleToString( mZ, precision );
@@ -282,8 +282,8 @@ QDomElement QgsPoint::asGml3( QDomDocument &doc, int precision, const QString &n
QString QgsPoint::asJson( int precision ) const
{
return "{\"type\": \"Point\", \"coordinates\": ["
+ qgsDoubleToString( mX, precision ) + ", " + qgsDoubleToString( mY, precision )
+ "]}";
+ qgsDoubleToString( mX, precision ) + QLatin1String( ", " ) + qgsDoubleToString( mY, precision )
+ QLatin1String( "]}" );
}

void QgsPoint::draw( QPainter &p ) const
@@ -104,7 +104,7 @@ QgsRectangle &QgsRectangle::operator+=( const QgsVector v )
QString QgsRectangle::asWktCoordinates() const
{
QString rep =
qgsDoubleToString( mXmin ) + ' ' + qgsDoubleToString( mYmin ) + ", " +
qgsDoubleToString( mXmin ) + ' ' + qgsDoubleToString( mYmin ) + QLatin1String( ", " ) +
qgsDoubleToString( mXmax ) + ' ' + qgsDoubleToString( mYmax );

return rep;
@@ -113,11 +113,11 @@ QString QgsRectangle::asWktCoordinates() const
QString QgsRectangle::asWktPolygon() const
{
QString rep =
QStringLiteral( "POLYGON((" ) +
qgsDoubleToString( mXmin ) + ' ' + qgsDoubleToString( mYmin ) + ", " +
qgsDoubleToString( mXmax ) + ' ' + qgsDoubleToString( mYmin ) + ", " +
qgsDoubleToString( mXmax ) + ' ' + qgsDoubleToString( mYmax ) + ", " +
qgsDoubleToString( mXmin ) + ' ' + qgsDoubleToString( mYmax ) + ", " +
QLatin1String( "POLYGON((" ) +
qgsDoubleToString( mXmin ) + ' ' + qgsDoubleToString( mYmin ) + QLatin1String( ", " ) +
qgsDoubleToString( mXmax ) + ' ' + qgsDoubleToString( mYmin ) + QLatin1String( ", " ) +
qgsDoubleToString( mXmax ) + ' ' + qgsDoubleToString( mYmax ) + QLatin1String( ", " ) +
qgsDoubleToString( mXmin ) + ' ' + qgsDoubleToString( mYmax ) + QLatin1String( ", " ) +
qgsDoubleToString( mXmin ) + ' ' + qgsDoubleToString( mYmin ) +
QStringLiteral( "))" );

0 comments on commit 3359a71

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