Skip to content
Permalink
Browse files

more stl to qt ports and size_t => int fixups

  • Loading branch information
jef-n committed Dec 25, 2015
1 parent 5605eaf commit 71dc33910680a78456ad80939767c764b69e0d76
Showing with 227 additions and 237 deletions.
  1. +1 −1 python/analysis/network/qgsgraph.sip
  2. +2 −9 python/core/geometry/qgsgeometry.sip
  3. +1 −2 python/core/qgsfeature.sip
  4. +2 −1 src/analysis/CMakeLists.txt
  5. +1 −1 src/analysis/network/qgsgraph.h
  6. +1 −1 src/analysis/vector/qgsgeometryanalyzer.cpp
  7. +1 −1 src/app/gps/qwtpolar-0.1/qwt_polar_curve.cpp
  8. +5 −1 src/core/CMakeLists.txt
  9. +1 −1 src/core/dxf/qgsdxfexport.cpp
  10. +2 −2 src/core/geometry/qgsgeometry.cpp
  11. +2 −2 src/core/geometry/qgsgeometry.h
  12. +2 −1 src/core/geometry/qgspointv2.cpp
  13. +1 −1 src/core/pal/feature.cpp
  14. +3 −3 src/core/pal/layer.cpp
  15. +1 −1 src/core/qgsexpression.h
  16. +1 −1 src/core/qgsfeature.cpp
  17. +1 −1 src/core/qgsfeature.h
  18. +1 −1 src/core/qgsgeometrysimplifier.cpp
  19. +18 −18 src/core/qgsmaptopixelgeometrysimplifier.cpp
  20. +1 −1 src/core/qgsmaptopixelgeometrysimplifier.h
  21. +2 −2 src/plugins/dxf2shp_converter/builder.cpp
  22. +5 −5 src/plugins/dxf2shp_converter/dxflib/src/dl_dxf.cpp
  23. +3 −4 src/plugins/georeferencer/qgsgcplist.cpp
  24. +2 −5 src/plugins/georeferencer/qgsgcplist.h
  25. +2 −3 src/plugins/georeferencer/qgsgcplistmodel.cpp
  26. +2 −4 src/plugins/georeferencer/qgsgeorefplugingui.cpp
  27. +25 −41 src/plugins/georeferencer/qgsgeoreftransform.cpp
  28. +5 −5 src/plugins/georeferencer/qgsgeoreftransform.h
  29. +34 −35 src/plugins/georeferencer/qgsleastsquares.cpp
  30. +9 −9 src/plugins/georeferencer/qgsleastsquares.h
  31. +2 −2 src/plugins/georeferencer/qgsrasterchangecoords.cpp
  32. +2 −2 src/plugins/georeferencer/qgsrasterchangecoords.h
  33. +5 −0 src/plugins/grass/CMakeLists.txt
  34. +1 −1 src/providers/gdal/qgsgdaldataitems.h
  35. +21 −6 src/providers/grass/CMakeLists.txt
  36. +1 −1 src/providers/grass/qgsgrassvectormaplayer.cpp
  37. +1 −1 src/providers/ogr/qgsogrdataitems.h
  38. +1 −1 src/providers/ogr/qgsogrgeometrysimplifier.cpp
  39. +6 −5 src/providers/oracle/ocispatial/qsql_ocispatial.cpp
  40. +1 −1 src/providers/postgres/qgspostgresprovider.cpp
  41. +1 −2 src/providers/spatialite/qgsspatialiteconnection.cpp
  42. +1 −1 src/providers/spatialite/qgsspatialiteexpressioncompiler.cpp
  43. +3 −4 src/providers/spatialite/qgsspatialitefeatureiterator.cpp
  44. +17 −24 src/providers/spatialite/qgsspatialiteprovider.cpp
  45. +10 −10 src/providers/spatialite/qgsspatialiteprovider.h
  46. +5 −5 src/providers/virtual/qgsvirtuallayerblob.cpp
  47. +1 −1 src/providers/virtual/qgsvirtuallayerblob.h
  48. +4 −4 src/providers/virtual/qgsvirtuallayersqlitemodule.cpp
  49. +1 −1 src/providers/wms/qgswmsprovider.cpp
  50. +1 −1 tests/src/core/testqgsfeature.cpp
  51. +5 −1 tests/src/providers/grass/CMakeLists.txt
@@ -19,7 +19,7 @@ class QgsGraphArc
QVariant property( int propertyIndex ) const;

/**
* get array of proertyes
* get array of properties
*/
QVector< QVariant > properties() const;

@@ -14,13 +14,6 @@ typedef QVector< QVector<QgsPoint> > QgsMultiPolyline;
/** A collection of QgsPolygons that share a common collection of attributes */
typedef QVector< QVector< QVector<QgsPoint> > > QgsMultiPolygon;

%If (WS_MACX)
typedef unsigned long size_t;
%End
%If (WS_X11 || WS_WIN)
typedef unsigned int size_t;
%End

/** \ingroup core
* A geometry is the spatial representation of a feature. Since QGIS 2.10, QgsGeometry acts as a generic container
* for geometry objects. QgsGeometry is implicitly shared, so making copies of geometries is inexpensive. The geometry
@@ -98,7 +91,7 @@ class QgsGeometry
Set the geometry, feeding in the buffer containing OGC Well-Known Binary and the buffer's length.
This class will take ownership of the buffer.
*/
void fromWkb( unsigned char * wkb /Array/, size_t length /ArraySize/ );
void fromWkb( unsigned char * wkb /Array/, int length /ArraySize/ );
%MethodCode
// create copy of Python's string and pass it to fromWkb()
unsigned char * copy = new unsigned char[a1];
@@ -120,7 +113,7 @@ class QgsGeometry
* Returns the size of the WKB in asWkb().
* @see asWkb
*/
size_t wkbSize() const;
int wkbSize() const;

/** Returns a geos geometry. QgsGeometry retains ownership of the geometry, so the returned object should not be deleted.
@param precision The precision of the grid to which to snap the geometry vertices. If 0, no snapping is performed.
@@ -378,7 +378,6 @@ class QgsFeature
* @see constGeometry
* @see geometryAndOwnership
* @see setGeometryAndOwnership
* @deprecated will be removed in QGIS 3.0
*/
// void setGeometry( QgsGeometry* geom /Transfer/ );

@@ -392,7 +391,7 @@ class QgsFeature
* @see geometryAndOwnership
* @deprecated will be removed in QGIS 3.0
*/
void setGeometryAndOwnership( unsigned char * geom /Transfer/, size_t length ) /Deprecated/;
void setGeometryAndOwnership( unsigned char * geom /Transfer/, int length ) /Deprecated/;

/** Assign a field map with the feature to allow attribute access by attribute name.
* @param fields The attribute fields which this feature holds
@@ -69,10 +69,11 @@ IF(NOT MSVC)
)
ELSE(NOT MSVC)
IF(PEDANTIC)
# 4127 expression is constant
# 4702 unreachable code
SET_SOURCE_FILES_PROPERTIES(
${CMAKE_BINARY_DIR}/src/analysis/qgsrastercalcparser.cpp
PROPERTIES COMPILE_FLAGS "-wd4702"
PROPERTIES COMPILE_FLAGS "-wd4127 -wd4702"
)
ENDIF(PEDANTIC)
ENDIF(NOT MSVC)
@@ -53,7 +53,7 @@ class ANALYSIS_EXPORT QgsGraphArc
QVariant property( int propertyIndex ) const;

/**
* get array of proertyes
* get array of properties
*/
QVector< QVariant > properties() const;

@@ -715,7 +715,7 @@ void QgsGeometryAnalyzer::dissolveFeature( QgsFeature& f, int nProcessedFeatures

if ( nProcessedFeatures == 0 )
{
size_t geomSize = featureGeometry->wkbSize();
int geomSize = featureGeometry->wkbSize();
*dissolveGeometry = new QgsGeometry();
unsigned char* wkb = new unsigned char[geomSize];
memcpy( wkb, featureGeometry->asWkb(), geomSize );
@@ -419,7 +419,7 @@ void QwtPolarCurve::drawSymbols( QPainter *painter, const QwtSymbol &symbol,
*/
int QwtPolarCurve::dataSize() const
{
return d_points->size();
return (int) d_points->size();
}

//! Update the widget that represents the curve on the legend
@@ -409,7 +409,11 @@ IF(NOT MSVC)
SET_SOURCE_FILES_PROPERTIES(qgsexpressionparser.cpp PROPERTIES COMPILE_FLAGS -w)
ELSE(NOT MSVC)
# -wd4702 unreachable code
SET_SOURCE_FILES_PROPERTIES(geometry/qgsgeos.cpp PROPERTIES COMPILE_FLAGS -wd4702)
SET_SOURCE_FILES_PROPERTIES(
geometry/qgsgeos.cpp
pal/feature.cpp
pal/pointset.cpp
PROPERTIES COMPILE_FLAGS -wd4702)
ENDIF(NOT MSVC)

SET(QGIS_CORE_MOC_HDRS
@@ -3801,7 +3801,7 @@ int QgsDxfExport::closestColorMatch( QRgb pixel )
{
int idx = 0;
int current_distance = INT_MAX;
for ( size_t i = 1; i < sizeof( mDxfColors ) / sizeof( *mDxfColors ); ++i )
for ( int i = 1; i < ( int )( sizeof( mDxfColors ) / sizeof( *mDxfColors ) ); ++i )
{
int dist = color_distance( pixel, i );
if ( dist < current_distance )
@@ -232,7 +232,7 @@ QgsGeometry* QgsGeometry::fromRect( const QgsRectangle& rect )
return fromPolygon( polygon );
}

void QgsGeometry::fromWkb( unsigned char *wkb, size_t length )
void QgsGeometry::fromWkb( unsigned char *wkb, int length )
{
Q_UNUSED( length );

@@ -262,7 +262,7 @@ const unsigned char *QgsGeometry::asWkb() const
return d->mWkb;
}

size_t QgsGeometry::wkbSize() const
int QgsGeometry::wkbSize() const
{
if ( !d->geometry )
{
@@ -142,7 +142,7 @@ class CORE_EXPORT QgsGeometry
Set the geometry, feeding in the buffer containing OGC Well-Known Binary and the buffer's length.
This class will take ownership of the buffer.
*/
void fromWkb( unsigned char * wkb, size_t length );
void fromWkb( unsigned char * wkb, int length );

/**
Returns the buffer containing this geometry in WKB format.
@@ -155,7 +155,7 @@ class CORE_EXPORT QgsGeometry
* Returns the size of the WKB in asWkb().
* @see asWkb
*/
size_t wkbSize() const;
int wkbSize() const;

/** Returns a geos geometry. QgsGeometry retains ownership of the geometry, so the returned object should not be deleted.
@param precision The precision of the grid to which to snap the geometry vertices. If 0, no snapping is performed.
@@ -408,8 +408,9 @@ bool QgsPointV2::convertTo( QgsWKBTypes::Type type )
mWkbType = type;
return true;
default:
return false;
break;
}

return false;
}

@@ -78,7 +78,7 @@ namespace pal
: PointSet( other )
, mLF( other.mLF )
{
Q_FOREACH ( FeaturePart* hole, other.mHoles )
Q_FOREACH ( const FeaturePart* hole, other.mHoles )
{
mHoles << new FeaturePart( *hole );
mHoles.last()->holeOf = this;
@@ -459,7 +459,7 @@ namespace pal
// Walk along line
unsigned int cur = 0;
double lambda = 0;
std::vector<Point> part;
QVector<Point> part;
for ( ;; )
{
lambda += chopInterval;
@@ -477,7 +477,7 @@ namespace pal
p.y = points[cur - 1].y + c * ( points[cur].y - points[cur - 1].y );
part.push_back( p );
GEOSCoordSequence* cooSeq = GEOSCoordSeq_create_r( geosctxt, part.size(), 2 );
for ( std::size_t i = 0; i < part.size(); ++i )
for ( int i = 0; i < part.size(); ++i )
{
GEOSCoordSeq_setX_r( geosctxt, cooSeq, i, part[i].x );
GEOSCoordSeq_setY_r( geosctxt, cooSeq, i, part[i].y );
@@ -494,7 +494,7 @@ namespace pal
// Create final part
part.push_back( points[n - 1] );
GEOSCoordSequence* cooSeq = GEOSCoordSeq_create_r( geosctxt, part.size(), 2 );
for ( std::size_t i = 0; i < part.size(); ++i )
for ( int i = 0; i < part.size(); ++i )
{
GEOSCoordSeq_setX_r( geosctxt, cooSeq, i, part[i].x );
GEOSCoordSeq_setY_r( geosctxt, cooSeq, i, part[i].y );
@@ -865,7 +865,7 @@ class CORE_EXPORT QgsExpression
virtual QVariant eval( QgsExpression* parent, const QgsExpressionContext* context ) override;
virtual QString dump() const override;

virtual QStringList referencedColumns() const override { QStringList lst( mNode->referencedColumns() ); Q_FOREACH ( Node* n, mList->list() ) lst.append( n->referencedColumns() ); return lst; }
virtual QStringList referencedColumns() const override { QStringList lst( mNode->referencedColumns() ); Q_FOREACH ( const Node* n, mList->list() ) lst.append( n->referencedColumns() ); return lst; }
virtual bool needsGeometry() const override { bool needs = false; Q_FOREACH ( Node* n, mList->list() ) needs |= n->needsGeometry(); return needs; }
virtual void accept( Visitor& v ) const override { v.visit( *this ); }
virtual Node* clone() const override;
@@ -163,7 +163,7 @@ void QgsFeature::setGeometry( QgsGeometry* geom )

/** Set the pointer to the feature geometry
*/
void QgsFeature::setGeometryAndOwnership( unsigned char *geom, size_t length )
void QgsFeature::setGeometryAndOwnership( unsigned char *geom, int length )
{
QgsGeometry *g = new QgsGeometry();
g->fromWkb( geom, length );
@@ -340,7 +340,7 @@ class CORE_EXPORT QgsFeature
* @see geometryAndOwnership
* @deprecated will be removed in QGIS 3.0
*/
Q_DECL_DEPRECATED void setGeometryAndOwnership( unsigned char * geom, size_t length );
Q_DECL_DEPRECATED void setGeometryAndOwnership( unsigned char * geom, int length );

/** Assign a field map with the feature to allow attribute access by attribute name.
* @param fields The attribute fields which this feature holds
@@ -64,7 +64,7 @@ bool QgsTopologyPreservingSimplifier::simplifyGeometry( QgsGeometry* geometry )

if ( g )
{
size_t wkbSize = g->wkbSize();
int wkbSize = g->wkbSize();
unsigned char* wkb = reinterpret_cast< unsigned char* >( malloc( wkbSize ) );
memcpy( wkb, g->asWkb(), wkbSize );
geometry->fromWkb( wkb, wkbSize );
@@ -41,7 +41,7 @@ float QgsMapToPixelSimplifier::calculateLengthSquared2D( double x1, double y1, d
}

//! Returns the BBOX of the specified WKB-point stream
inline static QgsRectangle calculateBoundingBox( QGis::WkbType wkbType, const unsigned char* wkb, size_t numPoints )
inline static QgsRectangle calculateBoundingBox( QGis::WkbType wkbType, const unsigned char* wkb, int numPoints )
{
double x, y;
QgsRectangle r;
@@ -50,7 +50,7 @@ inline static QgsRectangle calculateBoundingBox( QGis::WkbType wkbType, const un
int sizeOfDoubleX = sizeof( double );
int sizeOfDoubleY = ( QGis::wkbDimensions( wkbType ) - 1 ) * sizeof( double );

for ( size_t i = 0; i < numPoints; ++i )
for ( int i = 0; i < numPoints; ++i )
{
memcpy( &x, wkb, sizeof( double ) );
wkb += sizeOfDoubleX;
@@ -65,9 +65,9 @@ inline static QgsRectangle calculateBoundingBox( QGis::WkbType wkbType, const un
//! Generalize the WKB-geometry using the BBOX of the original geometry
static bool generalizeWkbGeometryByBoundingBox(
QGis::WkbType wkbType,
const unsigned char* sourceWkb, size_t sourceWkbSize,
unsigned char* targetWkb, size_t& targetWkbSize,
const QgsRectangle& envelope, bool writeHeader )
const unsigned char *sourceWkb, int sourceWkbSize,
unsigned char *targetWkb, int &targetWkbSize,
const QgsRectangle &envelope, bool writeHeader )
{
Q_UNUSED( sourceWkb );
unsigned char* wkb2 = targetWkb;
@@ -77,7 +77,7 @@ static bool generalizeWkbGeometryByBoundingBox(
int sizeOfDoubleY = sizeof( double ) * ( QGis::wkbDimensions( wkbType ) - 1 );

// If the geometry is already minimal skip the generalization
size_t minimumSize = geometryType == QGis::WKBLineString ? 4 + 2 * ( sizeOfDoubleX + sizeOfDoubleY ) : 8 + 5 * ( sizeOfDoubleX + sizeOfDoubleY );
int minimumSize = geometryType == QGis::WKBLineString ? 4 + 2 * ( sizeOfDoubleX + sizeOfDoubleY ) : 8 + 5 * ( sizeOfDoubleX + sizeOfDoubleY );

if ( writeHeader )
minimumSize += 5;
@@ -167,9 +167,9 @@ static bool generalizeWkbGeometryByBoundingBox(
//! Simplify the WKB-geometry using the specified tolerance
bool QgsMapToPixelSimplifier::simplifyWkbGeometry(
int simplifyFlags, QGis::WkbType wkbType,
const unsigned char* sourceWkb, size_t sourceWkbSize,
unsigned char* targetWkb, size_t& targetWkbSize,
const QgsRectangle& envelope, double map2pixelTol,
const unsigned char *sourceWkb, int sourceWkbSize,
unsigned char *targetWkb, int &targetWkbSize,
const QgsRectangle &envelope, double map2pixelTol,
bool writeHeader, bool isaLinearRing )
{
bool isGeneralizable = true;
@@ -178,7 +178,7 @@ bool QgsMapToPixelSimplifier::simplifyWkbGeometry(
// Save initial WKB settings to use when the simplification creates invalid geometries
const unsigned char* sourcePrevWkb = sourceWkb;
unsigned char* targetPrevWkb = targetWkb;
size_t targetWkbPrevSize = targetWkbSize;
int targetWkbPrevSize = targetWkbSize;

// Can replace the geometry by its BBOX ?
if (( simplifyFlags & QgsMapToPixelSimplifier::SimplifyEnvelope ) &&
@@ -296,7 +296,7 @@ bool QgsMapToPixelSimplifier::simplifyWkbGeometry(
// approximate the geometry's shape by its bounding box
// (rect for linear ring / one segment for line string)
unsigned char* targetTempWkb = targetWkb;
size_t targetWkbTempSize = targetWkbSize;
int targetWkbTempSize = targetWkbSize;

sourceWkb = sourcePrevWkb;
targetWkb = targetPrevWkb;
@@ -352,8 +352,8 @@ bool QgsMapToPixelSimplifier::simplifyWkbGeometry(
memcpy( &numPoints_i, sourceWkb, 4 );
QgsRectangle envelope_i = numRings == 1 ? envelope : calculateBoundingBox( wkbType, sourceWkb + 4, numPoints_i );

size_t sourceWkbSize_i = 4 + numPoints_i * QGis::wkbDimensions( wkbType ) * sizeof( double );
size_t targetWkbSize_i = 0;
int sourceWkbSize_i = 4 + numPoints_i * QGis::wkbDimensions( wkbType ) * sizeof( double );
int targetWkbSize_i = 0;

result |= simplifyWkbGeometry( simplifyFlags, wkbType, sourceWkb, sourceWkbSize_i, targetWkb, targetWkbSize_i, envelope_i, map2pixelTol, false, true );
sourceWkb += sourceWkbSize_i;
@@ -375,8 +375,8 @@ bool QgsMapToPixelSimplifier::simplifyWkbGeometry(

for ( int i = 0; i < numGeoms; ++i )
{
size_t sourceWkbSize_i = 0;
size_t targetWkbSize_i = 0;
int sourceWkbSize_i = 0;
int targetWkbSize_i = 0;

// ... calculate the wkb-size of the current child complex geometry
if ( flatType == QGis::WKBMultiLineString )
@@ -429,7 +429,7 @@ QgsGeometry* QgsMapToPixelSimplifier::simplify( QgsGeometry* geometry ) const
{
QgsGeometry* g = new QgsGeometry();

size_t wkbSize = geometry->wkbSize();
int wkbSize = geometry->wkbSize();
unsigned char* wkb = reinterpret_cast< unsigned char* >( malloc( wkbSize ) );
memcpy( wkb, geometry->asWkb(), wkbSize );
g->fromWkb( wkb, wkbSize );
@@ -441,7 +441,7 @@ QgsGeometry* QgsMapToPixelSimplifier::simplify( QgsGeometry* geometry ) const
//! Simplifies the geometry (Removing duplicated points) when is applied the specified map2pixel context
bool QgsMapToPixelSimplifier::simplifyGeometry( QgsGeometry* geometry, int simplifyFlags, double tolerance )
{
size_t finalWkbSize = 0;
int finalWkbSize = 0;

// Check whether the geometry can be simplified using the map2pixel context
QGis::GeometryType geometryType = geometry->type();
@@ -452,7 +452,7 @@ bool QgsMapToPixelSimplifier::simplifyGeometry( QgsGeometry* geometry, int simpl
QGis::WkbType wkbType = geometry->wkbType();

const unsigned char* wkb = geometry->asWkb();
size_t wkbSize = geometry->wkbSize();
int wkbSize = geometry->wkbSize();

unsigned char* targetWkb = new unsigned char[wkbSize];
memcpy( targetWkb, wkb, wkbSize );
@@ -45,7 +45,7 @@ class CORE_EXPORT QgsMapToPixelSimplifier : public QgsAbstractGeometrySimplifier

private:
//! Simplify the WKB-geometry using the specified tolerance
static bool simplifyWkbGeometry( int simplifyFlags, QGis::WkbType wkbType, const unsigned char* sourceWkb, size_t sourceWkbSize, unsigned char* targetWkb, size_t& targetWkbSize, const QgsRectangle& envelope, double map2pixelTol, bool writeHeader = true, bool isaLinearRing = false );
static bool simplifyWkbGeometry( int simplifyFlags, QGis::WkbType wkbType, const unsigned char* sourceWkb, int sourceWkbSize, unsigned char* targetWkb, int &targetWkbSize, const QgsRectangle& envelope, double map2pixelTol, bool writeHeader = true, bool isaLinearRing = false );

protected:
//! Current simplification flags
@@ -276,7 +276,7 @@ void Builder::addArc( const DL_ArcData& data )

// Finalize

int dim = arcPoints.size();
int dim = ( int ) arcPoints.size();
QVector<double> xv( dim );
QVector<double> yv( dim );
QVector<double> zv( dim );
@@ -325,7 +325,7 @@ void Builder::addCircle( const DL_CircleData& data )
circlePoints.push_back( myPoint );
}

int dim = circlePoints.size();
int dim = ( int ) circlePoints.size();
QVector<double> xv( dim );
QVector<double> yv( dim );
QVector<double> zv( dim );

0 comments on commit 71dc339

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