Skip to content

Commit 34684d4

Browse files
authored
Merge pull request #9324 from m-kuhn/latin1
Use QLatin1String for geometry representation operations
2 parents b53d64b + 3359a71 commit 34684d4

10 files changed

+22
-22
lines changed

src/core/geometry/qgscompoundcurve.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ QByteArray QgsCompoundCurve::asWkb() const
245245

246246
QString QgsCompoundCurve::asWkt( int precision ) const
247247
{
248-
QString wkt = wktTypeStr() + " (";
248+
QString wkt = wktTypeStr() + QLatin1String( " (" );
249249
for ( const QgsCurve *curve : mCurves )
250250
{
251251
QString childWkt = curve->asWkt( precision );

src/core/geometry/qgscurvepolygon.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ QByteArray QgsCurvePolygon::asWkb() const
311311

312312
QString QgsCurvePolygon::asWkt( int precision ) const
313313
{
314-
QString wkt = wktTypeStr() + " (";
314+
QString wkt = wktTypeStr() + QLatin1String( " (" );
315315
if ( mExteriorRing )
316316
{
317317
QString childWkt = mExteriorRing->asWkt( precision );
@@ -405,15 +405,15 @@ QString QgsCurvePolygon::asJson( int precision ) const
405405
std::unique_ptr< QgsLineString > exteriorLineString( exteriorRing()->curveToLine() );
406406
QgsPointSequence exteriorPts;
407407
exteriorLineString->points( exteriorPts );
408-
json += QgsGeometryUtils::pointsToJSON( exteriorPts, precision ) + ", ";
408+
json += QgsGeometryUtils::pointsToJSON( exteriorPts, precision ) + QLatin1String( ", " );
409409

410410
std::unique_ptr< QgsLineString > interiorLineString;
411411
for ( int i = 0, n = numInteriorRings(); i < n; ++i )
412412
{
413413
interiorLineString.reset( interiorRing( i )->curveToLine() );
414414
QgsPointSequence interiorPts;
415415
interiorLineString->points( interiorPts );
416-
json += QgsGeometryUtils::pointsToJSON( interiorPts, precision ) + ", ";
416+
json += QgsGeometryUtils::pointsToJSON( interiorPts, precision ) + QLatin1String( ", " );
417417
}
418418
if ( json.endsWith( QLatin1String( ", " ) ) )
419419
{

src/core/geometry/qgsgeometrycollection.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ QByteArray QgsGeometryCollection::asWkb() const
374374

375375
QString QgsGeometryCollection::asWkt( int precision ) const
376376
{
377-
QString wkt = wktTypeStr() + " (";
377+
QString wkt = wktTypeStr() + QLatin1String( " (" );
378378
for ( const QgsAbstractGeometry *geom : mGeometries )
379379
{
380380
QString childWkt = geom->asWkt( precision );
@@ -421,7 +421,7 @@ QString QgsGeometryCollection::asJson( int precision ) const
421421
QString json = QStringLiteral( "{\"type\": \"GeometryCollection\", \"geometries\": [" );
422422
for ( const QgsAbstractGeometry *geom : mGeometries )
423423
{
424-
json += geom->asJson( precision ) + ", ";
424+
json += geom->asJson( precision ) + QLatin1String( ", " );
425425
}
426426
if ( json.endsWith( QLatin1String( ", " ) ) )
427427
{

src/core/geometry/qgsgeometryutils.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,7 @@ QString QgsGeometryUtils::pointsToJSON( const QgsPointSequence &points, int prec
11841184
QString json = QStringLiteral( "[ " );
11851185
for ( const QgsPoint &p : points )
11861186
{
1187-
json += '[' + qgsDoubleToString( p.x(), precision ) + ", " + qgsDoubleToString( p.y(), precision ) + "], ";
1187+
json += '[' + qgsDoubleToString( p.x(), precision ) + QLatin1String( ", " ) + qgsDoubleToString( p.y(), precision ) + QLatin1String( "], " );
11881188
}
11891189
if ( json.endsWith( QLatin1String( ", " ) ) )
11901190
{

src/core/geometry/qgsmulticurve.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ QString QgsMultiCurve::asJson( int precision ) const
119119
std::unique_ptr< QgsLineString > lineString( static_cast<const QgsCurve *>( geom )->curveToLine() );
120120
QgsPointSequence pts;
121121
lineString->points( pts );
122-
json += QgsGeometryUtils::pointsToJSON( pts, precision ) + ", ";
122+
json += QgsGeometryUtils::pointsToJSON( pts, precision ) + QLatin1String( ", " );
123123
}
124124
}
125125
if ( json.endsWith( QLatin1String( ", " ) ) )

src/core/geometry/qgsmultilinestring.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ QString QgsMultiLineString::asJson( int precision ) const
105105
const QgsLineString *lineString = static_cast<const QgsLineString *>( geom );
106106
QgsPointSequence pts;
107107
lineString->points( pts );
108-
json += QgsGeometryUtils::pointsToJSON( pts, precision ) + ", ";
108+
json += QgsGeometryUtils::pointsToJSON( pts, precision ) + QLatin1String( ", " );
109109
}
110110
}
111111
if ( json.endsWith( QLatin1String( ", " ) ) )

src/core/geometry/qgsmultipolygon.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,15 @@ QString QgsMultiPolygon::asJson( int precision ) const
111111
std::unique_ptr< QgsLineString > exteriorLineString( polygon->exteriorRing()->curveToLine() );
112112
QgsPointSequence exteriorPts;
113113
exteriorLineString->points( exteriorPts );
114-
json += QgsGeometryUtils::pointsToJSON( exteriorPts, precision ) + ", ";
114+
json += QgsGeometryUtils::pointsToJSON( exteriorPts, precision ) + QLatin1String( ", " );
115115

116116
std::unique_ptr< QgsLineString > interiorLineString;
117117
for ( int i = 0, n = polygon->numInteriorRings(); i < n; ++i )
118118
{
119119
interiorLineString.reset( polygon->interiorRing( i )->curveToLine() );
120120
QgsPointSequence interiorPts;
121121
interiorLineString->points( interiorPts );
122-
json += QgsGeometryUtils::pointsToJSON( interiorPts, precision ) + ", ";
122+
json += QgsGeometryUtils::pointsToJSON( interiorPts, precision ) + QLatin1String( ", " );
123123
}
124124
if ( json.endsWith( QLatin1String( ", " ) ) )
125125
{

src/core/geometry/qgsmultisurface.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,15 @@ QString QgsMultiSurface::asJson( int precision ) const
121121
std::unique_ptr< QgsLineString > exteriorLineString( polygon->exteriorRing()->curveToLine() );
122122
QgsPointSequence exteriorPts;
123123
exteriorLineString->points( exteriorPts );
124-
json += QgsGeometryUtils::pointsToJSON( exteriorPts, precision ) + ", ";
124+
json += QgsGeometryUtils::pointsToJSON( exteriorPts, precision ) + QLatin1String( ", " );
125125

126126
std::unique_ptr< QgsLineString > interiorLineString;
127127
for ( int i = 0, n = polygon->numInteriorRings(); i < n; ++i )
128128
{
129129
interiorLineString.reset( polygon->interiorRing( i )->curveToLine() );
130130
QgsPointSequence interiorPts;
131131
interiorLineString->points( interiorPts );
132-
json += QgsGeometryUtils::pointsToJSON( interiorPts, precision ) + ", ";
132+
json += QgsGeometryUtils::pointsToJSON( interiorPts, precision ) + QLatin1String( ", " );
133133
}
134134
if ( json.endsWith( QLatin1String( ", " ) ) )
135135
{

src/core/geometry/qgspoint.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ QByteArray QgsPoint::asWkb() const
222222

223223
QString QgsPoint::asWkt( int precision ) const
224224
{
225-
QString wkt = wktTypeStr() + " (";
225+
QString wkt = wktTypeStr() + QLatin1String( " (" );
226226
wkt += qgsDoubleToString( mX, precision ) + ' ' + qgsDoubleToString( mY, precision );
227227
if ( is3D() )
228228
wkt += ' ' + qgsDoubleToString( mZ, precision );
@@ -282,8 +282,8 @@ QDomElement QgsPoint::asGml3( QDomDocument &doc, int precision, const QString &n
282282
QString QgsPoint::asJson( int precision ) const
283283
{
284284
return "{\"type\": \"Point\", \"coordinates\": ["
285-
+ qgsDoubleToString( mX, precision ) + ", " + qgsDoubleToString( mY, precision )
286-
+ "]}";
285+
+ qgsDoubleToString( mX, precision ) + QLatin1String( ", " ) + qgsDoubleToString( mY, precision )
286+
+ QLatin1String( "]}" );
287287
}
288288

289289
void QgsPoint::draw( QPainter &p ) const

src/core/geometry/qgsrectangle.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ QgsRectangle &QgsRectangle::operator+=( const QgsVector v )
104104
QString QgsRectangle::asWktCoordinates() const
105105
{
106106
QString rep =
107-
qgsDoubleToString( mXmin ) + ' ' + qgsDoubleToString( mYmin ) + ", " +
107+
qgsDoubleToString( mXmin ) + ' ' + qgsDoubleToString( mYmin ) + QLatin1String( ", " ) +
108108
qgsDoubleToString( mXmax ) + ' ' + qgsDoubleToString( mYmax );
109109

110110
return rep;
@@ -113,11 +113,11 @@ QString QgsRectangle::asWktCoordinates() const
113113
QString QgsRectangle::asWktPolygon() const
114114
{
115115
QString rep =
116-
QStringLiteral( "POLYGON((" ) +
117-
qgsDoubleToString( mXmin ) + ' ' + qgsDoubleToString( mYmin ) + ", " +
118-
qgsDoubleToString( mXmax ) + ' ' + qgsDoubleToString( mYmin ) + ", " +
119-
qgsDoubleToString( mXmax ) + ' ' + qgsDoubleToString( mYmax ) + ", " +
120-
qgsDoubleToString( mXmin ) + ' ' + qgsDoubleToString( mYmax ) + ", " +
116+
QLatin1String( "POLYGON((" ) +
117+
qgsDoubleToString( mXmin ) + ' ' + qgsDoubleToString( mYmin ) + QLatin1String( ", " ) +
118+
qgsDoubleToString( mXmax ) + ' ' + qgsDoubleToString( mYmin ) + QLatin1String( ", " ) +
119+
qgsDoubleToString( mXmax ) + ' ' + qgsDoubleToString( mYmax ) + QLatin1String( ", " ) +
120+
qgsDoubleToString( mXmin ) + ' ' + qgsDoubleToString( mYmax ) + QLatin1String( ", " ) +
121121
qgsDoubleToString( mXmin ) + ' ' + qgsDoubleToString( mYmin ) +
122122
QStringLiteral( "))" );
123123

0 commit comments

Comments
 (0)