mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
indentation update
This commit is contained in:
parent
bf456694be
commit
24acebef41
@ -75,7 +75,7 @@ class JoinAttributes(GeoAlgorithm):
|
||||
joinField2Index = layer2.fieldNameIndex(field2)
|
||||
|
||||
# Output
|
||||
outFields = vector.combineVectorFields(layer,layer2)
|
||||
outFields = vector.combineVectorFields(layer,layer2)
|
||||
|
||||
writer = output.getVectorWriter(outFields, provider.geometryType(),
|
||||
layer.crs())
|
||||
|
@ -561,9 +561,9 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
|
||||
chkUseRenderCaching->setChecked( settings.value( "/qgis/enable_render_caching", false ).toBool() );
|
||||
|
||||
// Default simplify drawing configuration
|
||||
mSimplifyDrawingGroupBox->setChecked( settings.value( "/qgis/simplifyDrawingHints", (int)QgsVectorLayer::DefaultSimplification ).toInt() != QgsVectorLayer::NoSimplification );
|
||||
mSimplifyDrawingSlider->setValue( (int)(5.0f * (settings.value( "/qgis/simplifyDrawingTol", QGis::DEFAULT_MAPTOPIXEL_THRESHOLD ).toFloat()-1)) );
|
||||
mSimplifyDrawingPanel->setVisible( mSimplifyDrawingSlider->value()>0 );
|
||||
mSimplifyDrawingGroupBox->setChecked( settings.value( "/qgis/simplifyDrawingHints", ( int )QgsVectorLayer::DefaultSimplification ).toInt() != QgsVectorLayer::NoSimplification );
|
||||
mSimplifyDrawingSlider->setValue(( int )( 5.0f * ( settings.value( "/qgis/simplifyDrawingTol", QGis::DEFAULT_MAPTOPIXEL_THRESHOLD ).toFloat() - 1 ) ) );
|
||||
mSimplifyDrawingPanel->setVisible( mSimplifyDrawingSlider->value() > 0 );
|
||||
|
||||
// Slightly awkard here at the settings value is true to use QImage,
|
||||
// but the checkbox is true to use QPixmap
|
||||
@ -2080,6 +2080,6 @@ void QgsOptions::saveDefaultDatumTransformations()
|
||||
|
||||
void QgsOptions::on_mSimplifyDrawingSlider_valueChanged( int value )
|
||||
{
|
||||
mSimplifyDrawingPanel->setVisible( value>0 );
|
||||
mSimplifyDrawingPanel->setVisible( value > 0 );
|
||||
}
|
||||
|
||||
|
@ -394,8 +394,8 @@ void QgsVectorLayerProperties::syncToLayer( void )
|
||||
|
||||
// get simplify drawing configuration
|
||||
mSimplifyDrawingGroupBox->setChecked( layer->simplifyDrawingHints() != QgsVectorLayer::NoSimplification );
|
||||
mSimplifyDrawingSlider->setValue( (int)(5.0f * (layer->simplifyDrawingTol()-1)) );
|
||||
mSimplifyDrawingPanel->setVisible( mSimplifyDrawingSlider->value()>0 );
|
||||
mSimplifyDrawingSlider->setValue(( int )( 5.0f * ( layer->simplifyDrawingTol() - 1 ) ) );
|
||||
mSimplifyDrawingPanel->setVisible( mSimplifyDrawingSlider->value() > 0 );
|
||||
|
||||
// load appropriate symbology page (V1 or V2)
|
||||
updateSymbologyPage();
|
||||
@ -1085,5 +1085,5 @@ void QgsVectorLayerProperties::on_mMaximumScaleSetCurrentPushButton_clicked()
|
||||
|
||||
void QgsVectorLayerProperties::on_mSimplifyDrawingSlider_valueChanged( int value )
|
||||
{
|
||||
mSimplifyDrawingPanel->setVisible( value>0 );
|
||||
mSimplifyDrawingPanel->setVisible( value > 0 );
|
||||
}
|
||||
|
@ -45,8 +45,8 @@ const unsigned char* QgsClipper::clippedLineWKB( const unsigned char* wkb, const
|
||||
|
||||
bool hasZValue = ( wkbType == QGis::WKBLineString25D );
|
||||
|
||||
int sizeOfDoubleX = sizeof(double);
|
||||
int sizeOfDoubleY = hasZValue ? 2*sizeof(double) : sizeof(double);
|
||||
int sizeOfDoubleX = sizeof( double );
|
||||
int sizeOfDoubleY = hasZValue ? 2 * sizeof( double ) : sizeof( double );
|
||||
|
||||
double p0x, p0y, p1x = 0.0, p1y = 0.0; //original coordinates
|
||||
double p1x_c, p1y_c; //clipped end coordinates
|
||||
|
@ -1682,7 +1682,7 @@ int QgsCoordinateReferenceSystem::syncDb()
|
||||
|
||||
int inserted = 0, updated = 0, deleted = 0, errors = 0;
|
||||
|
||||
qDebug( "Load srs db from: %s", QgsApplication::srsDbFilePath().toLocal8Bit().constData());
|
||||
qDebug( "Load srs db from: %s", QgsApplication::srsDbFilePath().toLocal8Bit().constData() );
|
||||
|
||||
sqlite3 *database;
|
||||
if ( sqlite3_open( dbFilePath.toUtf8().constData(), &database ) != SQLITE_OK )
|
||||
|
@ -657,7 +657,7 @@ void QgsCoordinateTransform::transformCoords( const int& numPoints, double *x, d
|
||||
}
|
||||
}
|
||||
|
||||
dir = (direction == ForwardTransform) ? tr( "forward transform" ) : tr( "inverse transform" );
|
||||
dir = ( direction == ForwardTransform ) ? tr( "forward transform" ) : tr( "inverse transform" );
|
||||
|
||||
QString msg = tr( "%1 of\n"
|
||||
"%2"
|
||||
|
@ -190,19 +190,19 @@ bool QgsFeatureRequest::acceptFeature( const QgsFeature& feature )
|
||||
return true;
|
||||
}
|
||||
|
||||
QgsFeatureRequest& QgsFeatureRequest::setCoordinateTransform( const QgsCoordinateTransform* ct )
|
||||
QgsFeatureRequest& QgsFeatureRequest::setCoordinateTransform( const QgsCoordinateTransform* ct )
|
||||
{
|
||||
mMapCoordTransform = ct;
|
||||
return *this;
|
||||
}
|
||||
|
||||
QgsFeatureRequest& QgsFeatureRequest::setMapToPixel( const QgsMapToPixel* mtp )
|
||||
QgsFeatureRequest& QgsFeatureRequest::setMapToPixel( const QgsMapToPixel* mtp )
|
||||
{
|
||||
mMapToPixel = mtp;
|
||||
return *this;
|
||||
}
|
||||
|
||||
QgsFeatureRequest& QgsFeatureRequest::setMapToPixelTol( float map2pixelTol )
|
||||
QgsFeatureRequest& QgsFeatureRequest::setMapToPixelTol( float map2pixelTol )
|
||||
{
|
||||
mMapToPixelTol = map2pixelTol;
|
||||
return *this;
|
||||
|
@ -142,7 +142,7 @@ class CORE_EXPORT QgsFeatureRequest
|
||||
|
||||
const QgsCoordinateTransform* coordinateTransform() const { return mMapCoordTransform; }
|
||||
QgsFeatureRequest& setCoordinateTransform( const QgsCoordinateTransform* ct );
|
||||
|
||||
|
||||
const QgsMapToPixel* mapToPixel() const { return mMapToPixel; }
|
||||
QgsFeatureRequest& setMapToPixel( const QgsMapToPixel* mtp );
|
||||
|
||||
@ -159,7 +159,7 @@ class CORE_EXPORT QgsFeatureRequest
|
||||
QgsAttributeList mAttrs;
|
||||
|
||||
//! For transformation between coordinate systems from current layer to map target. Can be 0 if on-the-fly reprojection is not used
|
||||
const QgsCoordinateTransform* mMapCoordTransform;
|
||||
const QgsCoordinateTransform* mMapCoordTransform;
|
||||
//! For transformation between map coordinates and device coordinates
|
||||
const QgsMapToPixel* mMapToPixel;
|
||||
//! Factor tolterance to apply in transformation between map coordinates and device coordinates
|
||||
|
@ -20,13 +20,13 @@
|
||||
//! Returns whether the device-envelope can be replaced by its BBOX when is applied the specified tolerance
|
||||
bool QgsAbstractGeometrySimplifier::canbeGeneralizedByDeviceBoundingBox( const QgsRectangle& envelope, float mapToPixelTol )
|
||||
{
|
||||
return (envelope.xMaximum()-envelope.xMinimum()) < mapToPixelTol && (envelope.yMaximum()-envelope.yMinimum()) < mapToPixelTol;
|
||||
return ( envelope.xMaximum() - envelope.xMinimum() ) < mapToPixelTol && ( envelope.yMaximum() - envelope.yMinimum() ) < mapToPixelTol;
|
||||
}
|
||||
|
||||
//! Returns whether the device-geometry can be replaced by its BBOX when is applied the specified tolerance
|
||||
bool QgsAbstractGeometrySimplifier::canbeGeneralizedByDeviceBoundingBox( const QVector<QPointF>& points, float mapToPixelTol )
|
||||
{
|
||||
double xmin = std::numeric_limits<double>::max(), x,y;
|
||||
double xmin = std::numeric_limits<double>::max(), x, y;
|
||||
double ymin = std::numeric_limits<double>::max();
|
||||
double xmax = -std::numeric_limits<double>::max();
|
||||
double ymax = -std::numeric_limits<double>::max();
|
||||
@ -36,10 +36,10 @@ bool QgsAbstractGeometrySimplifier::canbeGeneralizedByDeviceBoundingBox( const Q
|
||||
x = points[i].x();
|
||||
y = points[i].y();
|
||||
|
||||
if (xmin>x) xmin = x;
|
||||
if (ymin>y) ymin = y;
|
||||
if (xmax<x) xmax = x;
|
||||
if (ymax<y) ymax = y;
|
||||
if ( xmin > x ) xmin = x;
|
||||
if ( ymin > y ) ymin = y;
|
||||
if ( xmax < x ) xmax = x;
|
||||
if ( ymax < y ) ymax = y;
|
||||
}
|
||||
return canbeGeneralizedByDeviceBoundingBox( QgsRectangle( xmin, ymin, xmax, ymax ), mapToPixelTol );
|
||||
}
|
||||
@ -69,7 +69,7 @@ bool QgsTopologyPreservingSimplifier::simplifyGeometry( QgsGeometry* geometry )
|
||||
if ( g )
|
||||
{
|
||||
size_t wkbSize = g->wkbSize();
|
||||
unsigned char* wkb = (unsigned char*)malloc( wkbSize );
|
||||
unsigned char* wkb = ( unsigned char* )malloc( wkbSize );
|
||||
memcpy( wkb, g->asWkb(), wkbSize );
|
||||
geometry->fromWkb( wkb, wkbSize );
|
||||
delete g;
|
||||
|
@ -30,7 +30,7 @@ class CORE_EXPORT QgsAbstractGeometrySimplifier
|
||||
//! Simplifies the specified geometry
|
||||
virtual bool simplifyGeometry( QgsGeometry* geometry ) = 0;
|
||||
|
||||
// MapToPixel simplification helper methods
|
||||
// MapToPixel simplification helper methods
|
||||
public:
|
||||
//! Returns whether the device-envelope can be replaced by its BBOX when is applied the specified tolerance
|
||||
static bool canbeGeneralizedByDeviceBoundingBox( const QgsRectangle& envelope, float mapToPixelTol = 1.0f );
|
||||
@ -42,7 +42,7 @@ class CORE_EXPORT QgsAbstractGeometrySimplifier
|
||||
/**
|
||||
* Implementation of GeometrySimplifier using the Douglas-Peucker algorithm
|
||||
*
|
||||
* Simplifies a geometry, ensuring that the result is a valid geometry having the same dimension and number of components as the input.
|
||||
* Simplifies a geometry, ensuring that the result is a valid geometry having the same dimension and number of components as the input.
|
||||
* The simplification uses a maximum distance difference algorithm similar to the one used in the Douglas-Peucker algorithm.
|
||||
*/
|
||||
class CORE_EXPORT QgsTopologyPreservingSimplifier : public QgsAbstractGeometrySimplifier
|
||||
|
@ -19,10 +19,10 @@
|
||||
#include "qgsapplication.h"
|
||||
|
||||
QgsMapToPixelSimplifier::QgsMapToPixelSimplifier( int simplifyFlags, const QgsCoordinateTransform* coordinateTransform, const QgsMapToPixel* mapTolPixel, float mapToPixelTol )
|
||||
: mSimplifyFlags( simplifyFlags )
|
||||
, mMapCoordTransform( coordinateTransform )
|
||||
, mMapToPixel( mapTolPixel )
|
||||
, mMapToPixelTol( mapToPixelTol )
|
||||
: mSimplifyFlags( simplifyFlags )
|
||||
, mMapCoordTransform( coordinateTransform )
|
||||
, mMapToPixel( mapTolPixel )
|
||||
, mMapToPixelTol( mapToPixelTol )
|
||||
{
|
||||
}
|
||||
QgsMapToPixelSimplifier::~QgsMapToPixelSimplifier()
|
||||
@ -35,8 +35,8 @@ QgsMapToPixelSimplifier::~QgsMapToPixelSimplifier()
|
||||
//! Returns the squared 2D-distance of the vector defined by the two points specified
|
||||
float QgsMapToPixelSimplifier::calculateLengthSquared2D( double x1, double y1, double x2, double y2 )
|
||||
{
|
||||
float vx = (float)( x2 - x1 );
|
||||
float vy = (float)( y2 - y1 );
|
||||
float vx = ( float )( x2 - x1 );
|
||||
float vy = ( float )( y2 - y1 );
|
||||
|
||||
return vx*vx + vy*vy;
|
||||
}
|
||||
@ -48,10 +48,10 @@ float QgsMapToPixelSimplifier::calculateViewPixelTolerance( const QgsRectangle&
|
||||
double mapUnitsFactor = 1;
|
||||
|
||||
// Calculate one aprox factor of the size of the BBOX from the source CoordinateSystem to the target CoordinateSystem
|
||||
if ( ct && !((QgsCoordinateTransform*)ct)->isShortCircuited() )
|
||||
if ( ct && !(( QgsCoordinateTransform* )ct )->isShortCircuited() )
|
||||
{
|
||||
QgsRectangle sourceRect = boundingRect;
|
||||
QgsRectangle targetRect = ct->transform(sourceRect);
|
||||
QgsRectangle targetRect = ct->transform( sourceRect );
|
||||
|
||||
QgsPoint minimumSrcPoint( sourceRect.xMinimum(), sourceRect.yMinimum() );
|
||||
QgsPoint maximumSrcPoint( sourceRect.xMaximum(), sourceRect.yMaximum() );
|
||||
@ -61,25 +61,25 @@ float QgsMapToPixelSimplifier::calculateViewPixelTolerance( const QgsRectangle&
|
||||
double sourceHypothenuse = sqrt( calculateLengthSquared2D( minimumSrcPoint.x(), minimumSrcPoint.y(), maximumSrcPoint.x(), maximumSrcPoint.y() ) );
|
||||
double targetHypothenuse = sqrt( calculateLengthSquared2D( minimumDstPoint.x(), minimumDstPoint.y(), maximumDstPoint.x(), maximumDstPoint.y() ) );
|
||||
|
||||
if (targetHypothenuse!=0)
|
||||
mapUnitsFactor = sourceHypothenuse/targetHypothenuse;
|
||||
if ( targetHypothenuse != 0 )
|
||||
mapUnitsFactor = sourceHypothenuse / targetHypothenuse;
|
||||
}
|
||||
return (float)( mapUnitsPerPixel * mapUnitsFactor );
|
||||
return ( float )( mapUnitsPerPixel * mapUnitsFactor );
|
||||
}
|
||||
|
||||
//! Returns the BBOX of the specified WKB-point stream
|
||||
inline static QgsRectangle calculateBoundingBox( QGis::WkbType wkbType, unsigned char* wkb, size_t numPoints )
|
||||
{
|
||||
unsigned char* wkb2 = wkb;
|
||||
|
||||
double xmin = std::numeric_limits<double>::max(), x,y;
|
||||
|
||||
double xmin = std::numeric_limits<double>::max(), x, y;
|
||||
double ymin = std::numeric_limits<double>::max();
|
||||
double xmax = -std::numeric_limits<double>::max();
|
||||
double ymax = -std::numeric_limits<double>::max();
|
||||
|
||||
int sizeOfDoubleX = sizeof(double);
|
||||
int sizeOfDoubleY = QGis::wkbDimensions(wkbType)==3 /*hasZValue*/ ? 2*sizeof(double) : sizeof(double);
|
||||
|
||||
int sizeOfDoubleX = sizeof( double );
|
||||
int sizeOfDoubleY = QGis::wkbDimensions( wkbType ) == 3 /*hasZValue*/ ? 2 * sizeof( double ) : sizeof( double );
|
||||
|
||||
for ( size_t i = 0; i < numPoints; ++i )
|
||||
{
|
||||
memcpy( &x, wkb, sizeof( double ) ); wkb += sizeOfDoubleX;
|
||||
@ -101,11 +101,11 @@ inline static bool generalizeWkbGeometry( QGis::WkbType wkbType, unsigned char*
|
||||
unsigned char* wkb2 = targetWkb;
|
||||
unsigned int geometryType = QGis::singleType( QGis::flatType( wkbType ) );
|
||||
|
||||
int sizeOfDoubleX = sizeof(double);
|
||||
int sizeOfDoubleY = QGis::wkbDimensions(wkbType)==3 /*hasZValue*/ ? 2*sizeof(double) : sizeof(double);
|
||||
int sizeOfDoubleX = sizeof( double );
|
||||
int sizeOfDoubleY = QGis::wkbDimensions( wkbType ) == 3 /*hasZValue*/ ? 2 * sizeof( double ) : sizeof( double );
|
||||
|
||||
// Skip the unnecesary generalization because of is a very single geometry
|
||||
size_t minimumSize = ( geometryType==QGis::WKBLineString ? 4 + 2*(sizeOfDoubleX+sizeOfDoubleY) : 8 + 5*(sizeOfDoubleX+sizeOfDoubleY) );
|
||||
size_t minimumSize = ( geometryType == QGis::WKBLineString ? 4 + 2 * ( sizeOfDoubleX + sizeOfDoubleY ) : 8 + 5 * ( sizeOfDoubleX + sizeOfDoubleY ) );
|
||||
if ( writeHeader ) minimumSize += 5;
|
||||
if ( sourceWkbSize <= minimumSize )
|
||||
{
|
||||
@ -132,7 +132,7 @@ inline static bool generalizeWkbGeometry( QGis::WkbType wkbType, unsigned char*
|
||||
{
|
||||
int numRings = 1;
|
||||
memcpy( targetWkb, &numRings, 4 );
|
||||
targetWkb += 4;
|
||||
targetWkb += 4;
|
||||
}
|
||||
}
|
||||
|
||||
@ -140,7 +140,7 @@ inline static bool generalizeWkbGeometry( QGis::WkbType wkbType, unsigned char*
|
||||
if ( geometryType == QGis::WKBLineString )
|
||||
{
|
||||
int numPoints = 2;
|
||||
memcpy( targetWkb, &numPoints, 4 ); // numPoints;
|
||||
memcpy( targetWkb, &numPoints, 4 ); // numPoints;
|
||||
targetWkb += 4;
|
||||
|
||||
memcpy( targetWkb, &x1, sizeof( double ) ); targetWkb += sizeof( double );
|
||||
@ -151,7 +151,7 @@ inline static bool generalizeWkbGeometry( QGis::WkbType wkbType, unsigned char*
|
||||
else
|
||||
{
|
||||
int numPoints = 5;
|
||||
memcpy( targetWkb, &numPoints, 4 ); // numPoints;
|
||||
memcpy( targetWkb, &numPoints, 4 ); // numPoints;
|
||||
targetWkb += 4;
|
||||
|
||||
memcpy( targetWkb, &x1, sizeof( double ) ); targetWkb += sizeof( double );
|
||||
@ -174,16 +174,16 @@ inline static bool generalizeWkbGeometry( QGis::WkbType wkbType, unsigned char*
|
||||
bool QgsMapToPixelSimplifier::simplifyWkbGeometry( int simplifyFlags, QGis::WkbType wkbType, unsigned char* sourceWkb, size_t sourceWkbSize, unsigned char* targetWkb, size_t& targetWkbSize, const QgsRectangle& envelope, float map2pixelTol, bool writeHeader, bool isaLinearRing )
|
||||
{
|
||||
bool canbeGeneralizable = true;
|
||||
bool hasZValue = QGis::wkbDimensions(wkbType)==3;
|
||||
bool hasZValue = QGis::wkbDimensions( wkbType ) == 3;
|
||||
bool result = false;
|
||||
|
||||
// Can replace the geometry by its BBOX ?
|
||||
if ( ( simplifyFlags & QgsMapToPixelSimplifier::SimplifyEnvelope ) && (envelope.xMaximum()-envelope.xMinimum()) < map2pixelTol && (envelope.yMaximum()-envelope.yMinimum()) < map2pixelTol )
|
||||
if (( simplifyFlags & QgsMapToPixelSimplifier::SimplifyEnvelope ) && ( envelope.xMaximum() - envelope.xMinimum() ) < map2pixelTol && ( envelope.yMaximum() - envelope.yMinimum() ) < map2pixelTol )
|
||||
{
|
||||
canbeGeneralizable = generalizeWkbGeometry( wkbType, sourceWkb, sourceWkbSize, targetWkb, targetWkbSize, envelope, writeHeader );
|
||||
if (canbeGeneralizable) return true;
|
||||
if ( canbeGeneralizable ) return true;
|
||||
}
|
||||
if (!( simplifyFlags & QgsMapToPixelSimplifier::SimplifyGeometry ) ) canbeGeneralizable = false;
|
||||
if ( !( simplifyFlags & QgsMapToPixelSimplifier::SimplifyGeometry ) ) canbeGeneralizable = false;
|
||||
|
||||
// Write the main header of the geometry
|
||||
if ( writeHeader )
|
||||
@ -194,8 +194,8 @@ bool QgsMapToPixelSimplifier::simplifyWkbGeometry( int simplifyFlags, QGis::WkbT
|
||||
|
||||
int geometryType;
|
||||
memcpy( &geometryType, sourceWkb, 4 );
|
||||
int flatType = QGis::flatType( (QGis::WkbType)geometryType );
|
||||
memcpy( targetWkb, &flatType, 4 ); // type
|
||||
int flatType = QGis::flatType(( QGis::WkbType )geometryType );
|
||||
memcpy( targetWkb, &flatType, 4 ); // type
|
||||
sourceWkb += 4;
|
||||
targetWkb += 4;
|
||||
|
||||
@ -209,132 +209,132 @@ bool QgsMapToPixelSimplifier::simplifyWkbGeometry( int simplifyFlags, QGis::WkbT
|
||||
// Write the geometry
|
||||
if ( flatType == QGis::WKBLineString || isaLinearRing )
|
||||
{
|
||||
double x,y, lastX=0,lastY=0;
|
||||
double x, y, lastX = 0, lastY = 0;
|
||||
|
||||
int sizeOfDoubleX = sizeof(double);
|
||||
int sizeOfDoubleY = QGis::wkbDimensions(wkbType)==3 /*hasZValue*/ ? 2*sizeof(double) : sizeof(double);
|
||||
int sizeOfDoubleX = sizeof( double );
|
||||
int sizeOfDoubleY = QGis::wkbDimensions( wkbType ) == 3 /*hasZValue*/ ? 2 * sizeof( double ) : sizeof( double );
|
||||
|
||||
int numPoints;
|
||||
memcpy( &numPoints, sourceWkb, 4);
|
||||
memcpy( &numPoints, sourceWkb, 4 );
|
||||
sourceWkb += 4;
|
||||
if (numPoints <= (isaLinearRing ? 5 : 2)) canbeGeneralizable = false;
|
||||
if ( numPoints <= ( isaLinearRing ? 5 : 2 ) ) canbeGeneralizable = false;
|
||||
|
||||
int numTargetPoints = 0;
|
||||
memcpy( targetWkb, &numTargetPoints, 4 );
|
||||
targetWkb += 4;
|
||||
targetWkbSize += 4;
|
||||
|
||||
double* ptr = (double*)targetWkb;
|
||||
double* ptr = ( double* )targetWkb;
|
||||
map2pixelTol *= map2pixelTol; //-> Use mappixelTol for 'LengthSquare' calculations.
|
||||
|
||||
// Process each vertex...
|
||||
for ( int i = 0, numPoints_i = (isaLinearRing ? numPoints-1 : numPoints); i < numPoints_i; ++i )
|
||||
for ( int i = 0, numPoints_i = ( isaLinearRing ? numPoints - 1 : numPoints ); i < numPoints_i; ++i )
|
||||
{
|
||||
memcpy( &x, sourceWkb, sizeof( double ) ); sourceWkb += sizeOfDoubleX;
|
||||
memcpy( &y, sourceWkb, sizeof( double ) ); sourceWkb += sizeOfDoubleY;
|
||||
|
||||
if ( i==0 || !canbeGeneralizable || QgsMapToPixelSimplifier::calculateLengthSquared2D(x,y,lastX,lastY)>map2pixelTol )
|
||||
|
||||
if ( i == 0 || !canbeGeneralizable || QgsMapToPixelSimplifier::calculateLengthSquared2D( x, y, lastX, lastY ) > map2pixelTol )
|
||||
{
|
||||
memcpy( ptr, &x, sizeof( double ) ); lastX = x; ptr++;
|
||||
memcpy( ptr, &y, sizeof( double ) ); lastY = y; ptr++;
|
||||
numTargetPoints++;
|
||||
}
|
||||
}
|
||||
targetWkb = wkb2+4;
|
||||
|
||||
targetWkb = wkb2 + 4;
|
||||
|
||||
// Fix the topology of the geometry
|
||||
if ( isaLinearRing )
|
||||
{
|
||||
memcpy( &x, targetWkb+0, sizeof( double ) );
|
||||
memcpy( &y, targetWkb+8, sizeof( double ) );
|
||||
memcpy( &x, targetWkb + 0, sizeof( double ) );
|
||||
memcpy( &y, targetWkb + 8, sizeof( double ) );
|
||||
memcpy( ptr, &x, sizeof( double ) ); ptr++;
|
||||
memcpy( ptr, &y, sizeof( double ) ); ptr++;
|
||||
numTargetPoints++;
|
||||
}
|
||||
targetWkbSize += numTargetPoints * 16;
|
||||
targetWkb = wkb2;
|
||||
targetWkb = wkb2;
|
||||
|
||||
memcpy( targetWkb, &numTargetPoints, 4 );
|
||||
result = numPoints!=numTargetPoints;
|
||||
result = numPoints != numTargetPoints;
|
||||
}
|
||||
else
|
||||
if ( flatType == QGis::WKBPolygon )
|
||||
{
|
||||
int numRings;
|
||||
memcpy( &numRings, sourceWkb, 4 );
|
||||
sourceWkb += 4;
|
||||
|
||||
memcpy( targetWkb, &numRings, 4 );
|
||||
targetWkb += 4;
|
||||
targetWkbSize += 4;
|
||||
|
||||
for ( int i = 0; i < numRings; ++i )
|
||||
if ( flatType == QGis::WKBPolygon )
|
||||
{
|
||||
int numPoints_i;
|
||||
memcpy( &numPoints_i, sourceWkb, 4 );
|
||||
QgsRectangle envelope_i = numRings==1 ? envelope : calculateBoundingBox( wkbType, sourceWkb+4, numPoints_i );
|
||||
int numRings;
|
||||
memcpy( &numRings, sourceWkb, 4 );
|
||||
sourceWkb += 4;
|
||||
|
||||
size_t sourceWkbSize_i = 4 + numPoints_i * (hasZValue ? 3 : 2) * sizeof(double);
|
||||
size_t targetWkbSize_i = 0;
|
||||
memcpy( targetWkb, &numRings, 4 );
|
||||
targetWkb += 4;
|
||||
targetWkbSize += 4;
|
||||
|
||||
result |= simplifyWkbGeometry( simplifyFlags, wkbType, sourceWkb, sourceWkbSize_i, targetWkb, targetWkbSize_i, envelope_i, map2pixelTol, false, true );
|
||||
sourceWkb += sourceWkbSize_i;
|
||||
targetWkb += targetWkbSize_i;
|
||||
|
||||
targetWkbSize += targetWkbSize_i;
|
||||
}
|
||||
}
|
||||
else
|
||||
if ( flatType == QGis::WKBMultiLineString || flatType == QGis::WKBMultiPolygon )
|
||||
{
|
||||
int numGeoms;
|
||||
memcpy( &numGeoms, sourceWkb, 4 );
|
||||
sourceWkb += 4;
|
||||
wkb1 += 4;
|
||||
|
||||
memcpy( targetWkb, &numGeoms, 4 );
|
||||
targetWkb += 4;
|
||||
targetWkbSize += 4;
|
||||
|
||||
for ( int i = 0; i < numGeoms; ++i )
|
||||
{
|
||||
size_t sourceWkbSize_i = 0;
|
||||
size_t targetWkbSize_i = 0;
|
||||
|
||||
// ... calculate the wkb-size of the current child complex geometry
|
||||
if ( flatType == QGis::WKBMultiLineString )
|
||||
for ( int i = 0; i < numRings; ++i )
|
||||
{
|
||||
int numPoints_i;
|
||||
memcpy( &numPoints_i, wkb1+5, 4 );
|
||||
int wkbSize_i = 4 + numPoints_i * (hasZValue ? 3 : 2) * sizeof(double);
|
||||
memcpy( &numPoints_i, sourceWkb, 4 );
|
||||
QgsRectangle envelope_i = numRings == 1 ? envelope : calculateBoundingBox( wkbType, sourceWkb + 4, numPoints_i );
|
||||
|
||||
sourceWkbSize_i += 5 + wkbSize_i;
|
||||
wkb1 += 5 + wkbSize_i;
|
||||
size_t sourceWkbSize_i = 4 + numPoints_i * ( hasZValue ? 3 : 2 ) * sizeof( double );
|
||||
size_t targetWkbSize_i = 0;
|
||||
|
||||
result |= simplifyWkbGeometry( simplifyFlags, wkbType, sourceWkb, sourceWkbSize_i, targetWkb, targetWkbSize_i, envelope_i, map2pixelTol, false, true );
|
||||
sourceWkb += sourceWkbSize_i;
|
||||
targetWkb += targetWkbSize_i;
|
||||
|
||||
targetWkbSize += targetWkbSize_i;
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
if ( flatType == QGis::WKBMultiLineString || flatType == QGis::WKBMultiPolygon )
|
||||
{
|
||||
int numPrings_i;
|
||||
memcpy( &numPrings_i, wkb1+5, 4 );
|
||||
sourceWkbSize_i = 9;
|
||||
wkb1 += 9;
|
||||
int numGeoms;
|
||||
memcpy( &numGeoms, sourceWkb, 4 );
|
||||
sourceWkb += 4;
|
||||
wkb1 += 4;
|
||||
|
||||
for (int j = 0; j < numPrings_i; ++j)
|
||||
memcpy( targetWkb, &numGeoms, 4 );
|
||||
targetWkb += 4;
|
||||
targetWkbSize += 4;
|
||||
|
||||
for ( int i = 0; i < numGeoms; ++i )
|
||||
{
|
||||
int numPoints_i;
|
||||
memcpy( &numPoints_i, wkb1, 4);
|
||||
int wkbSize_i = 4 + numPoints_i * (hasZValue ? 3 : 2) * sizeof(double);
|
||||
size_t sourceWkbSize_i = 0;
|
||||
size_t targetWkbSize_i = 0;
|
||||
|
||||
sourceWkbSize_i += wkbSize_i;
|
||||
wkb1 += wkbSize_i;
|
||||
// ... calculate the wkb-size of the current child complex geometry
|
||||
if ( flatType == QGis::WKBMultiLineString )
|
||||
{
|
||||
int numPoints_i;
|
||||
memcpy( &numPoints_i, wkb1 + 5, 4 );
|
||||
int wkbSize_i = 4 + numPoints_i * ( hasZValue ? 3 : 2 ) * sizeof( double );
|
||||
|
||||
sourceWkbSize_i += 5 + wkbSize_i;
|
||||
wkb1 += 5 + wkbSize_i;
|
||||
}
|
||||
else
|
||||
{
|
||||
int numPrings_i;
|
||||
memcpy( &numPrings_i, wkb1 + 5, 4 );
|
||||
sourceWkbSize_i = 9;
|
||||
wkb1 += 9;
|
||||
|
||||
for ( int j = 0; j < numPrings_i; ++j )
|
||||
{
|
||||
int numPoints_i;
|
||||
memcpy( &numPoints_i, wkb1, 4 );
|
||||
int wkbSize_i = 4 + numPoints_i * ( hasZValue ? 3 : 2 ) * sizeof( double );
|
||||
|
||||
sourceWkbSize_i += wkbSize_i;
|
||||
wkb1 += wkbSize_i;
|
||||
}
|
||||
}
|
||||
result |= simplifyWkbGeometry( simplifyFlags, QGis::singleType( wkbType ), sourceWkb, sourceWkbSize_i, targetWkb, targetWkbSize_i, envelope, map2pixelTol, true, false );
|
||||
sourceWkb += sourceWkbSize_i;
|
||||
targetWkb += targetWkbSize_i;
|
||||
|
||||
targetWkbSize += targetWkbSize_i;
|
||||
}
|
||||
}
|
||||
result |= simplifyWkbGeometry( simplifyFlags, QGis::singleType(wkbType), sourceWkb, sourceWkbSize_i, targetWkb, targetWkbSize_i, envelope, map2pixelTol, true, false );
|
||||
sourceWkb += sourceWkbSize_i;
|
||||
targetWkb += targetWkbSize_i;
|
||||
|
||||
targetWkbSize += targetWkbSize_i;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -346,7 +346,7 @@ bool QgsMapToPixelSimplifier::canbeGeneralizedByMapBoundingBox( const QgsRectang
|
||||
double map2pixelTol = mapToPixelTol * calculateViewPixelTolerance( envelope, coordinateTransform, mapToPixel );
|
||||
|
||||
// Can replace the geometry by its BBOX ?
|
||||
if ( (envelope.xMaximum()-envelope.xMinimum()) < map2pixelTol && (envelope.yMaximum()-envelope.yMinimum()) < map2pixelTol )
|
||||
if (( envelope.xMaximum() - envelope.xMinimum() ) < map2pixelTol && ( envelope.yMaximum() - envelope.yMinimum() ) < map2pixelTol )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -359,7 +359,7 @@ QgsGeometry* QgsMapToPixelSimplifier::simplify( QgsGeometry* geometry )
|
||||
QgsGeometry* g = new QgsGeometry();
|
||||
|
||||
size_t wkbSize = geometry->wkbSize();
|
||||
unsigned char* wkb = (unsigned char*)malloc( wkbSize );
|
||||
unsigned char* wkb = ( unsigned char* )malloc( wkbSize );
|
||||
memcpy( wkb, geometry->asWkb(), wkbSize );
|
||||
g->fromWkb( wkb, wkbSize );
|
||||
simplifyGeometry( g, mSimplifyFlags, mMapCoordTransform, mMapToPixel, mMapToPixelTol );
|
||||
@ -374,22 +374,22 @@ bool QgsMapToPixelSimplifier::simplifyGeometry( QgsGeometry* geometry, int simpl
|
||||
|
||||
// Check whether the geometry can be simplified using the map2pixel context
|
||||
QGis::GeometryType geometryType = geometry->type();
|
||||
if ( !(geometryType==QGis::Line || geometryType==QGis::Polygon) ) return false;
|
||||
if ( !( geometryType == QGis::Line || geometryType == QGis::Polygon ) ) return false;
|
||||
|
||||
QgsRectangle envelope = geometry->boundingBox();
|
||||
QGis::WkbType wkbType = geometry->wkbType();
|
||||
double map2pixelTol = mapToPixelTol * calculateViewPixelTolerance( envelope, coordinateTransform, mapToPixel );
|
||||
|
||||
unsigned char* wkb = (unsigned char*)geometry->asWkb( );
|
||||
unsigned char* wkb = ( unsigned char* )geometry->asWkb( );
|
||||
size_t wkbSize = geometry->wkbSize( );
|
||||
|
||||
// Simplify the geometry rewriting temporally its WKB-stream for saving calloc's.
|
||||
if ( simplifyWkbGeometry( simplifyFlags, wkbType, wkb, wkbSize, wkb, targetWkbSize, envelope, map2pixelTol ) )
|
||||
{
|
||||
unsigned char* targetWkb = (unsigned char*)malloc( targetWkbSize );
|
||||
unsigned char* targetWkb = ( unsigned char* )malloc( targetWkbSize );
|
||||
memcpy( targetWkb, wkb, targetWkbSize );
|
||||
geometry->fromWkb( targetWkb, targetWkbSize );
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -397,5 +397,5 @@ bool QgsMapToPixelSimplifier::simplifyGeometry( QgsGeometry* geometry, int simpl
|
||||
//! Simplifies the geometry (Removing duplicated points) when is applied the specified map2pixel context
|
||||
bool QgsMapToPixelSimplifier::simplifyGeometry( QgsGeometry* geometry )
|
||||
{
|
||||
return simplifyGeometry( geometry, mSimplifyFlags, mMapCoordTransform, mMapToPixel, mMapToPixelTol );
|
||||
return simplifyGeometry( geometry, mSimplifyFlags, mMapCoordTransform, mMapToPixel, mMapToPixelTol );
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ class CORE_EXPORT QgsMapToPixelSimplifier : public QgsAbstractGeometrySimplifier
|
||||
int mSimplifyFlags;
|
||||
|
||||
//! For transformation between coordinate systems from current layer to map target. Can be 0 if on-the-fly reprojection is not used
|
||||
const QgsCoordinateTransform* mMapCoordTransform;
|
||||
const QgsCoordinateTransform* mMapCoordTransform;
|
||||
//! For transformation between map coordinates and device coordinates
|
||||
const QgsMapToPixel* mMapToPixel;
|
||||
//! Factor tolterance to apply in transformation between map coordinates and device coordinates
|
||||
@ -81,18 +81,18 @@ class CORE_EXPORT QgsMapToPixelSimplifier : public QgsAbstractGeometrySimplifier
|
||||
//! Simplifies the specified geometry
|
||||
virtual bool simplifyGeometry( QgsGeometry* geometry );
|
||||
|
||||
// MapToPixel simplification helper methods
|
||||
// MapToPixel simplification helper methods
|
||||
public:
|
||||
|
||||
//! Returns whether the envelope can be replaced by its BBOX when is applied the specified map2pixel context
|
||||
static bool canbeGeneralizedByMapBoundingBox( const QgsRectangle& envelope,
|
||||
const QgsCoordinateTransform* coordinateTransform, const QgsMapToPixel* mapToPixel, float mapToPixelTol = 1.0f );
|
||||
const QgsCoordinateTransform* coordinateTransform, const QgsMapToPixel* mapToPixel, float mapToPixelTol = 1.0f );
|
||||
|
||||
//! Returns whether the envelope can be replaced by its BBOX when is applied the specified map2pixel context
|
||||
inline bool canbeGeneralizedByMapBoundingBox( const QgsRectangle& envelope ) const { return canbeGeneralizedByMapBoundingBox( envelope, mMapCoordTransform, mMapToPixel, mMapToPixelTol ); }
|
||||
|
||||
//! Simplifies the geometry when is applied the specified map2pixel context
|
||||
static bool simplifyGeometry( QgsGeometry* geometry,
|
||||
static bool simplifyGeometry( QgsGeometry* geometry,
|
||||
int simplifyFlags, const QgsCoordinateTransform* coordinateTransform, const QgsMapToPixel* mapToPixel, float mapToPixelTol = 1.0f );
|
||||
|
||||
};
|
||||
|
@ -1370,7 +1370,7 @@ QString QgsProject::readPath( QString src ) const
|
||||
QString vsiPrefix = qgsVsiPrefix( src );
|
||||
if ( ! vsiPrefix.isEmpty() )
|
||||
{
|
||||
src.remove(0, vsiPrefix.size());
|
||||
src.remove( 0, vsiPrefix.size() );
|
||||
}
|
||||
|
||||
// relative path should always start with ./ or ../
|
||||
@ -1465,7 +1465,7 @@ QString QgsProject::readPath( QString src ) const
|
||||
// return the absolute or relative path to write it to the project file
|
||||
QString QgsProject::writePath( QString src ) const
|
||||
{
|
||||
if ( readBoolEntry( "Paths", "/Absolute", false ) || src.isEmpty() )
|
||||
if ( readBoolEntry( "Paths", "/Absolute", false ) || src.isEmpty() )
|
||||
{
|
||||
return src;
|
||||
}
|
||||
@ -1474,7 +1474,7 @@ QString QgsProject::writePath( QString src ) const
|
||||
QString projPath = fileName();
|
||||
|
||||
if ( projPath.isEmpty() )
|
||||
{
|
||||
{
|
||||
return src;
|
||||
}
|
||||
|
||||
@ -1482,7 +1482,7 @@ QString QgsProject::writePath( QString src ) const
|
||||
QString vsiPrefix = qgsVsiPrefix( src );
|
||||
if ( ! vsiPrefix.isEmpty() )
|
||||
{
|
||||
srcPath.remove(0, vsiPrefix.size());
|
||||
srcPath.remove( 0, vsiPrefix.size() );
|
||||
}
|
||||
|
||||
#if defined( Q_OS_WIN )
|
||||
|
@ -186,7 +186,7 @@ QgsVectorLayer::QgsVectorLayer( QString vectorLayerPath,
|
||||
|
||||
// Default simplify drawing configuration
|
||||
QSettings settings;
|
||||
setSimplifyDrawingHints( settings.value( "/qgis/simplifyDrawingHints", (int)mSimplifyDrawingHints ).toInt() );
|
||||
setSimplifyDrawingHints( settings.value( "/qgis/simplifyDrawingHints", ( int )mSimplifyDrawingHints ).toInt() );
|
||||
setSimplifyDrawingTol( settings.value( "/qgis/simplifyDrawingTol", mSimplifyDrawingTol ).toFloat() );
|
||||
|
||||
} // QgsVectorLayer ctor
|
||||
@ -698,17 +698,17 @@ bool QgsVectorLayer::draw( QgsRenderContext& rendererContext )
|
||||
mRendererV2->startRender( rendererContext, this );
|
||||
|
||||
QgsFeatureRequest& featureRequest = QgsFeatureRequest()
|
||||
.setFilterRect( rendererContext.extent() )
|
||||
.setSubsetOfAttributes( attributes );
|
||||
.setFilterRect( rendererContext.extent() )
|
||||
.setSubsetOfAttributes( attributes );
|
||||
|
||||
QgsFeatureIterator fit = QgsFeatureIterator();
|
||||
|
||||
// Enable the simplification of the geometries (Using the current map2pixel context) before fetch the features.
|
||||
if ( simplifyDrawingCanbeApplied( QgsVectorLayer::GeometrySimplification | QgsVectorLayer::EnvelopeSimplification ) && !(featureRequest.flags() & QgsFeatureRequest::NoGeometry) && !rendererContext.renderingPrintComposition() )
|
||||
if ( simplifyDrawingCanbeApplied( QgsVectorLayer::GeometrySimplification | QgsVectorLayer::EnvelopeSimplification ) && !( featureRequest.flags() & QgsFeatureRequest::NoGeometry ) && !rendererContext.renderingPrintComposition() )
|
||||
{
|
||||
QPainter* p = rendererContext.painter();
|
||||
float dpi = ( p->device()->logicalDpiX() + p->device()->logicalDpiY() ) / 2;
|
||||
float map2pixelTol = mSimplifyDrawingTol * 96.0f/dpi;
|
||||
float map2pixelTol = mSimplifyDrawingTol * 96.0f / dpi;
|
||||
|
||||
int simplifyFlags = QgsMapToPixelSimplifier::NoFlags;
|
||||
if ( mSimplifyDrawingHints & QgsVectorLayer::GeometrySimplification ) simplifyFlags |= QgsMapToPixelSimplifier::SimplifyGeometry;
|
||||
@ -723,7 +723,7 @@ bool QgsVectorLayer::draw( QgsRenderContext& rendererContext )
|
||||
featureRequest.setMapToPixel( &rendererContext.mapToPixel() );
|
||||
featureRequest.setMapToPixelTol( map2pixelTol );
|
||||
|
||||
QgsMapToPixelSimplifier* simplifier =
|
||||
QgsMapToPixelSimplifier* simplifier =
|
||||
new QgsMapToPixelSimplifier( simplifyFlags, rendererContext.coordinateTransform(), &rendererContext.mapToPixel(), map2pixelTol );
|
||||
|
||||
fit = QgsFeatureIterator( new QgsSimplifiedVectorLayerFeatureIterator( this, featureRequest, simplifier ) );
|
||||
@ -1247,9 +1247,9 @@ bool QgsVectorLayer::setSubsetString( QString subset )
|
||||
return res;
|
||||
}
|
||||
|
||||
bool QgsVectorLayer::simplifyDrawingCanbeApplied( int simplifyHint ) const
|
||||
bool QgsVectorLayer::simplifyDrawingCanbeApplied( int simplifyHint ) const
|
||||
{
|
||||
return mDataProvider && ( mSimplifyDrawingHints & simplifyHint ) && !mEditBuffer && ( !mCurrentRendererContext || !mCurrentRendererContext->renderingPrintComposition() );
|
||||
return mDataProvider && ( mSimplifyDrawingHints & simplifyHint ) && !mEditBuffer && ( !mCurrentRendererContext || !mCurrentRendererContext->renderingPrintComposition() );
|
||||
}
|
||||
|
||||
QgsFeatureIterator QgsVectorLayer::getFeatures( const QgsFeatureRequest& request )
|
||||
|
@ -607,8 +607,8 @@ void QgsVectorLayerFeatureIterator::updateFeatureGeometry( QgsFeature &f )
|
||||
***************************************************************************/
|
||||
|
||||
QgsSimplifiedVectorLayerFeatureIterator::QgsSimplifiedVectorLayerFeatureIterator( QgsVectorLayer* layer, const QgsFeatureRequest& request, QgsAbstractGeometrySimplifier* simplifier )
|
||||
: QgsVectorLayerFeatureIterator( layer, request )
|
||||
, mSimplifier( simplifier )
|
||||
: QgsVectorLayerFeatureIterator( layer, request )
|
||||
, mSimplifier( simplifier )
|
||||
{
|
||||
mSupportsPresimplify = layer->dataProvider()->capabilities() & QgsVectorDataProvider::SimplifyGeometries;
|
||||
}
|
||||
@ -624,7 +624,7 @@ QgsSimplifiedVectorLayerFeatureIterator::~QgsSimplifiedVectorLayerFeatureIterato
|
||||
//! fetch next feature, return true on success
|
||||
bool QgsSimplifiedVectorLayerFeatureIterator::fetchFeature( QgsFeature& feature )
|
||||
{
|
||||
if (QgsVectorLayerFeatureIterator::fetchFeature( feature ))
|
||||
if ( QgsVectorLayerFeatureIterator::fetchFeature( feature ) )
|
||||
{
|
||||
const QgsMapToPixel* mtp = mRequest.mapToPixel();
|
||||
if ( mtp && !mSupportsPresimplify && mSimplifier ) mSimplifier->simplifyGeometry( feature.geometry() );
|
||||
|
@ -139,7 +139,7 @@ class CORE_EXPORT QgsSimplifiedVectorLayerFeatureIterator : public QgsVectorLaye
|
||||
{
|
||||
public:
|
||||
QgsSimplifiedVectorLayerFeatureIterator( QgsVectorLayer* layer, const QgsFeatureRequest& request, QgsAbstractGeometrySimplifier* simplifier );
|
||||
~QgsSimplifiedVectorLayerFeatureIterator( );
|
||||
~QgsSimplifiedVectorLayerFeatureIterator( );
|
||||
|
||||
protected:
|
||||
//! fetch next feature, return true on success
|
||||
|
@ -182,7 +182,7 @@ void QgsSimpleLineSymbolLayerV2::renderPolyline( const QPolygonF& points, QgsSym
|
||||
p->setPen( context.selected() ? mSelPen : mPen );
|
||||
|
||||
// Disable 'Antialiasing' if the geometry was generalized in the current RenderContext (We known that it must have least #2 points).
|
||||
if ( points.size()<=2 && context.layer() && context.layer()->simplifyDrawingCanbeApplied( QgsVectorLayer::AntialiasingSimplification ) && QgsAbstractGeometrySimplifier::canbeGeneralizedByDeviceBoundingBox( points, context.layer()->simplifyDrawingTol() ) && (p->renderHints() & QPainter::Antialiasing) )
|
||||
if ( points.size() <= 2 && context.layer() && context.layer()->simplifyDrawingCanbeApplied( QgsVectorLayer::AntialiasingSimplification ) && QgsAbstractGeometrySimplifier::canbeGeneralizedByDeviceBoundingBox( points, context.layer()->simplifyDrawingTol() ) && ( p->renderHints() & QPainter::Antialiasing ) )
|
||||
{
|
||||
p->setRenderHint( QPainter::Antialiasing, false );
|
||||
p->drawPolyline( points );
|
||||
|
@ -68,8 +68,8 @@ const unsigned char* QgsFeatureRendererV2::_getLineString( QPolygonF& pts, QgsRe
|
||||
|
||||
bool hasZValue = ( wkbType == QGis::WKBLineString25D );
|
||||
|
||||
int sizeOfDoubleX = sizeof(double);
|
||||
int sizeOfDoubleY = hasZValue ? 2*sizeof(double) : sizeof(double);
|
||||
int sizeOfDoubleX = sizeof( double );
|
||||
int sizeOfDoubleY = hasZValue ? 2 * sizeof( double ) : sizeof( double );
|
||||
|
||||
double x, y;
|
||||
const QgsCoordinateTransform* ct = context.coordinateTransform();
|
||||
@ -126,8 +126,8 @@ const unsigned char* QgsFeatureRendererV2::_getPolygon( QPolygonF& pts, QList<QP
|
||||
|
||||
bool hasZValue = ( wkbType == QGis::WKBPolygon25D );
|
||||
|
||||
int sizeOfDoubleX = sizeof(double);
|
||||
int sizeOfDoubleY = hasZValue ? 2*sizeof(double) : sizeof(double);
|
||||
int sizeOfDoubleX = sizeof( double );
|
||||
int sizeOfDoubleY = hasZValue ? 2 * sizeof( double ) : sizeof( double );
|
||||
|
||||
double x, y;
|
||||
holes.clear();
|
||||
@ -160,7 +160,7 @@ const unsigned char* QgsFeatureRendererV2::_getPolygon( QPolygonF& pts, QList<QP
|
||||
|
||||
//clip close to view extent, if needed
|
||||
QRectF ptsRect = poly.boundingRect();
|
||||
if (!context.extent().contains( ptsRect )) QgsClipper::trimPolygon( poly, clipRect );
|
||||
if ( !context.extent().contains( ptsRect ) ) QgsClipper::trimPolygon( poly, clipRect );
|
||||
|
||||
//transform the QPolygonF to screen coordinates
|
||||
if ( ct )
|
||||
|
@ -174,9 +174,9 @@ QgsMarkerSymbolLayerV2::QgsMarkerSymbolLayerV2( bool locked )
|
||||
: QgsSymbolLayerV2( QgsSymbolV2::Marker, locked ), mSizeUnit( QgsSymbolV2::MM ), mOffsetUnit( QgsSymbolV2::MM ),
|
||||
mHorizontalAnchorPoint( HCenter ), mVerticalAnchorPoint( VCenter )
|
||||
{
|
||||
mOffsetExpression = NULL;
|
||||
mHorizontalAnchorExpression = NULL;
|
||||
mVerticalAnchorExpression = NULL;
|
||||
mOffsetExpression = NULL;
|
||||
mHorizontalAnchorExpression = NULL;
|
||||
mVerticalAnchorExpression = NULL;
|
||||
}
|
||||
|
||||
QgsLineSymbolLayerV2::QgsLineSymbolLayerV2( bool locked )
|
||||
@ -359,9 +359,9 @@ void QgsFillSymbolLayerV2::_renderPolygon( QPainter* p, const QPolygonF& points,
|
||||
}
|
||||
|
||||
// Disable 'Antialiasing' if the geometry was generalized in the current RenderContext (We known that it must have least #5 points).
|
||||
if ( points.size()<=5 && context.layer() && context.layer()->simplifyDrawingCanbeApplied( QgsVectorLayer::AntialiasingSimplification ) && QgsAbstractGeometrySimplifier::canbeGeneralizedByDeviceBoundingBox( points, context.layer()->simplifyDrawingTol() ) && (p->renderHints() & QPainter::Antialiasing) )
|
||||
if ( points.size() <= 5 && context.layer() && context.layer()->simplifyDrawingCanbeApplied( QgsVectorLayer::AntialiasingSimplification ) && QgsAbstractGeometrySimplifier::canbeGeneralizedByDeviceBoundingBox( points, context.layer()->simplifyDrawingTol() ) && ( p->renderHints() & QPainter::Antialiasing ) )
|
||||
{
|
||||
p->setRenderHint( QPainter::Antialiasing, false );
|
||||
p->setRenderHint( QPainter::Antialiasing, false );
|
||||
p->drawRect( points.boundingRect() );
|
||||
p->setRenderHint( QPainter::Antialiasing, true );
|
||||
return;
|
||||
|
@ -440,7 +440,7 @@ int main( int argc, char * argv[] )
|
||||
delete theServer;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( serviceString == "WFS" )
|
||||
{
|
||||
delete theServer;
|
||||
|
@ -331,7 +331,7 @@ void QgsProjectParser::wcsContentMetadata( QDomElement& parentElement, QDomDocum
|
||||
|
||||
//lonLatEnvelope
|
||||
const QgsCoordinateReferenceSystem& layerCrs = layer->crs();
|
||||
QgsCoordinateTransform t( layerCrs, QgsCoordinateReferenceSystem(4326) );
|
||||
QgsCoordinateTransform t( layerCrs, QgsCoordinateReferenceSystem( 4326 ) );
|
||||
//transform
|
||||
QgsRectangle BBox = t.transformBoundingBox( layer->extent() );
|
||||
QDomElement lonLatElem = doc.createElement( "lonLatEnvelope" );
|
||||
@ -696,7 +696,7 @@ void QgsProjectParser::describeCoverage( const QString& aCoveName, QDomElement&
|
||||
|
||||
//lonLatEnvelope
|
||||
const QgsCoordinateReferenceSystem& layerCrs = layer->crs();
|
||||
QgsCoordinateTransform t( layerCrs, QgsCoordinateReferenceSystem(4326) );
|
||||
QgsCoordinateTransform t( layerCrs, QgsCoordinateReferenceSystem( 4326 ) );
|
||||
//transform
|
||||
QgsRectangle BBox = t.transformBoundingBox( layer->extent() );
|
||||
QDomElement lonLatElem = doc.createElement( "lonLatEnvelope" );
|
||||
@ -742,7 +742,7 @@ void QgsProjectParser::describeCoverage( const QString& aCoveName, QDomElement&
|
||||
lowElem.appendChild( lowText );
|
||||
gridEnvElem.appendChild( lowElem );
|
||||
QDomElement highElem = doc.createElement( "gml:high" );
|
||||
QDomText highText = doc.createTextNode( QString::number( rLayer->width() )+" "+QString::number( rLayer->height() ) );
|
||||
QDomText highText = doc.createTextNode( QString::number( rLayer->width() ) + " " + QString::number( rLayer->height() ) );
|
||||
highElem.appendChild( highText );
|
||||
gridEnvElem.appendChild( highElem );
|
||||
spatialDomainElem.appendChild( rectGridElem );
|
||||
@ -764,12 +764,12 @@ void QgsProjectParser::describeCoverage( const QString& aCoveName, QDomElement&
|
||||
spatialDomainElem.appendChild( originElem );
|
||||
|
||||
QDomElement xOffsetElem = doc.createElement( "gml:offsetVector" );
|
||||
QDomText xOffsetText = doc.createTextNode( QString::number( rLayer->rasterUnitsPerPixelX() )+" 0" );
|
||||
QDomText xOffsetText = doc.createTextNode( QString::number( rLayer->rasterUnitsPerPixelX() ) + " 0" );
|
||||
xOffsetElem.appendChild( xOffsetText );
|
||||
spatialDomainElem.appendChild( xOffsetElem );
|
||||
|
||||
QDomElement yOffsetElem = doc.createElement( "gml:offsetVector" );
|
||||
QDomText yOffsetText = doc.createTextNode( "0 "+QString::number( rLayer->rasterUnitsPerPixelY() ) );
|
||||
QDomText yOffsetText = doc.createTextNode( "0 " + QString::number( rLayer->rasterUnitsPerPixelY() ) );
|
||||
yOffsetElem.appendChild( yOffsetText );
|
||||
spatialDomainElem.appendChild( yOffsetElem );
|
||||
|
||||
@ -3105,7 +3105,7 @@ void QgsProjectParser::serviceWCSCapabilities( QDomElement& parentElement, QDomD
|
||||
serviceElem.appendChild( wcsKeywordsElem );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Fees
|
||||
QDomElement feesElem = propertiesElem.firstChildElement( "WMSFees" );
|
||||
if ( !feesElem.isNull() )
|
||||
|
@ -69,7 +69,7 @@ QDomDocument QgsWCSServer::getCapabilities()
|
||||
{
|
||||
mConfigParser->serviceCapabilities( wcsCapabilitiesElement, doc );
|
||||
}
|
||||
|
||||
|
||||
//INSERT Service
|
||||
|
||||
//wcs:Capability element
|
||||
@ -149,7 +149,7 @@ QDomDocument QgsWCSServer::describeCoverage()
|
||||
coveDescElement.setAttribute( "version", "1.0.0" );
|
||||
coveDescElement.setAttribute( "updateSequence", "0" );
|
||||
doc.appendChild( coveDescElement );
|
||||
|
||||
|
||||
//defining coverage name
|
||||
QString coveName = "";
|
||||
//read COVERAGE
|
||||
@ -158,7 +158,8 @@ QDomDocument QgsWCSServer::describeCoverage()
|
||||
{
|
||||
coveName = cove_name_it.value();
|
||||
}
|
||||
if ( coveName == "" ) {
|
||||
if ( coveName == "" )
|
||||
{
|
||||
QMap<QString, QString>::const_iterator cove_name_it = mParameterMap.find( "IDENTIFIER" );
|
||||
if ( cove_name_it != mParameterMap.end() )
|
||||
{
|
||||
@ -183,7 +184,8 @@ QByteArray* QgsWCSServer::getCoverage()
|
||||
{
|
||||
coveName = cove_name_it.value();
|
||||
}
|
||||
if ( coveName == "" ) {
|
||||
if ( coveName == "" )
|
||||
{
|
||||
QMap<QString, QString>::const_iterator cove_name_it = mParameterMap.find( "IDENTIFIER" );
|
||||
if ( cove_name_it != mParameterMap.end() )
|
||||
{
|
||||
@ -191,12 +193,13 @@ QByteArray* QgsWCSServer::getCoverage()
|
||||
}
|
||||
}
|
||||
|
||||
if ( coveName == "" ) {
|
||||
if ( coveName == "" )
|
||||
{
|
||||
mErrors << QString( "COVERAGE is mandatory" );
|
||||
}
|
||||
|
||||
layerList = mConfigParser->mapLayerFromCoverage( coveName );
|
||||
if ( layerList.size() < 1 )
|
||||
if ( layerList.size() < 1 )
|
||||
{
|
||||
mErrors << QString( "The layer for the COVERAGE '%1' is not found" ).arg( coveName );
|
||||
}
|
||||
@ -229,7 +232,7 @@ QByteArray* QgsWCSServer::getCoverage()
|
||||
maxy = bbString.section( ",", 3, 3 ).toDouble( &conversionSuccess );
|
||||
if ( !conversionSuccess ) {bboxOk = false;}
|
||||
}
|
||||
if ( !bboxOk )
|
||||
if ( !bboxOk )
|
||||
{
|
||||
mErrors << QString( "The BBOX is mandatory and has to be xx.xxx,yy.yyy,xx.xxx,yy.yyy" );
|
||||
}
|
||||
@ -244,7 +247,7 @@ QByteArray* QgsWCSServer::getCoverage()
|
||||
{
|
||||
height = 0;
|
||||
}
|
||||
|
||||
|
||||
if ( width < 0 || height < 0 )
|
||||
{
|
||||
mErrors << QString( "The WIDTH and HEIGHT are mandatory and have to be integer" );
|
||||
@ -260,7 +263,7 @@ QByteArray* QgsWCSServer::getCoverage()
|
||||
{
|
||||
mErrors << QString( "Could not create output CRS" );
|
||||
}
|
||||
|
||||
|
||||
if ( mErrors.count() != 0 )
|
||||
{
|
||||
throw QgsMapServiceException( "RequestNotWellFormed", mErrors.join( ". " ) );
|
||||
@ -270,7 +273,8 @@ QByteArray* QgsWCSServer::getCoverage()
|
||||
|
||||
QgsMapLayer* layer = layerList.at( 0 );
|
||||
QgsRasterLayer* rLayer = dynamic_cast<QgsRasterLayer*>( layer );
|
||||
if ( rLayer ) {
|
||||
if ( rLayer )
|
||||
{
|
||||
QTemporaryFile tempFile;
|
||||
tempFile.open();
|
||||
QgsRasterFileWriter fileWriter( tempFile.fileName() );
|
||||
@ -294,7 +298,7 @@ QByteArray* QgsWCSServer::getCoverage()
|
||||
throw QgsMapServiceException( "RequestNotWellFormed", mErrors.join( ". " ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QgsRasterFileWriter::WriterError err = fileWriter.writeRaster( pipe, width, height, rect, outputCRS );
|
||||
if ( err != QgsRasterFileWriter::NoError )
|
||||
{
|
||||
|
@ -212,7 +212,7 @@ const QgsGraphDirector* RoadGraphPlugin::director() const
|
||||
if ( layer == NULL )
|
||||
return NULL;
|
||||
if ( layer->wkbType() == QGis::WKBLineString
|
||||
|| layer->wkbType() == QGis::WKBMultiLineString)
|
||||
|| layer->wkbType() == QGis::WKBMultiLineString )
|
||||
{
|
||||
QgsVectorDataProvider *provider = dynamic_cast< QgsVectorDataProvider* >( layer->dataProvider() );
|
||||
if ( provider == NULL )
|
||||
|
@ -299,9 +299,9 @@ void QgsOgrFeatureIterator::fetchedFeature( OGRFeatureH feature, OGRGeometryH ge
|
||||
***************************************************************************/
|
||||
|
||||
//! Provides a specialized FeatureIterator for enable simplification of the geometries
|
||||
QgsOgrSimplifiedFeatureIterator::QgsOgrSimplifiedFeatureIterator( QgsOgrProvider* p, const QgsFeatureRequest& request )
|
||||
: QgsOgrFeatureIterator( p, request )
|
||||
, mSimplifier( NULL )
|
||||
QgsOgrSimplifiedFeatureIterator::QgsOgrSimplifiedFeatureIterator( QgsOgrProvider* p, const QgsFeatureRequest& request )
|
||||
: QgsOgrFeatureIterator( p, request )
|
||||
, mSimplifier( NULL )
|
||||
{
|
||||
QgsFeatureRequest::Flags requestFlags = request.flags();
|
||||
|
||||
@ -326,9 +326,9 @@ QgsOgrSimplifiedFeatureIterator::~QgsOgrSimplifiedFeatureIterator( )
|
||||
//! Notified a new OGRFeatureH fecthed from data provider
|
||||
void QgsOgrSimplifiedFeatureIterator::fetchedFeature( OGRFeatureH feature, OGRGeometryH geometry )
|
||||
{
|
||||
if ( mSimplifier && (mSimplifier->simplifyFlags() & (QgsMapToPixelSimplifier::SimplifyGeometry | QgsMapToPixelSimplifier::SimplifyEnvelope) ) )
|
||||
if ( mSimplifier && ( mSimplifier->simplifyFlags() & ( QgsMapToPixelSimplifier::SimplifyGeometry | QgsMapToPixelSimplifier::SimplifyEnvelope ) ) )
|
||||
{
|
||||
mSimplifier->simplifyGeometry( (OGRGeometry*) geometry );
|
||||
mSimplifier->simplifyGeometry(( OGRGeometry* ) geometry );
|
||||
}
|
||||
QgsOgrFeatureIterator::fetchedFeature( feature, geometry );
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ class QgsOgrSimplifiedFeatureIterator : public QgsOgrFeatureIterator
|
||||
{
|
||||
public:
|
||||
QgsOgrSimplifiedFeatureIterator( QgsOgrProvider* p, const QgsFeatureRequest& request );
|
||||
~QgsOgrSimplifiedFeatureIterator( );
|
||||
~QgsOgrSimplifiedFeatureIterator( );
|
||||
|
||||
protected:
|
||||
//! Notified a new OGRFeatureH fecthed from data provider
|
||||
|
@ -20,7 +20,7 @@
|
||||
QgsOgrMapToPixelSimplifier::QgsOgrMapToPixelSimplifier( int simplifyFlags, const QgsCoordinateTransform* coordinateTransform, const QgsMapToPixel* mapTolPixel, float mapToPixelTol ) : QgsMapToPixelSimplifier( simplifyFlags, coordinateTransform, mapTolPixel, mapToPixelTol )
|
||||
{
|
||||
mPointBufferCount = 512;
|
||||
mPointBufferPtr = (OGRRawPoint*)OGRMalloc( mPointBufferCount * sizeof(OGRRawPoint) );
|
||||
mPointBufferPtr = ( OGRRawPoint* )OGRMalloc( mPointBufferCount * sizeof( OGRRawPoint ) );
|
||||
}
|
||||
QgsOgrMapToPixelSimplifier::~QgsOgrMapToPixelSimplifier()
|
||||
{
|
||||
@ -39,10 +39,10 @@ OGRRawPoint* QgsOgrMapToPixelSimplifier::mallocPoints( int numPoints )
|
||||
OGRFree( mPointBufferPtr );
|
||||
mPointBufferPtr = NULL;
|
||||
}
|
||||
if ( mPointBufferPtr==NULL )
|
||||
if ( mPointBufferPtr == NULL )
|
||||
{
|
||||
mPointBufferCount = numPoints;
|
||||
mPointBufferPtr = (OGRRawPoint*)OGRMalloc( mPointBufferCount * sizeof(OGRRawPoint) );
|
||||
mPointBufferPtr = ( OGRRawPoint* )OGRMalloc( mPointBufferCount * sizeof( OGRRawPoint ) );
|
||||
}
|
||||
return mPointBufferPtr;
|
||||
}
|
||||
@ -51,7 +51,7 @@ OGRRawPoint* QgsOgrMapToPixelSimplifier::mallocPoints( int numPoints )
|
||||
// Helper simplification methods
|
||||
|
||||
//! Simplifies the OGR-geometry (Removing duplicated points) when is applied the specified map2pixel context
|
||||
bool QgsOgrMapToPixelSimplifier::simplifyOgrGeometry( QGis::GeometryType geometryType, const QgsRectangle& envelope, double* xptr, int xStride, double* yptr, int yStride, int pointCount, int& pointSimplifiedCount)
|
||||
bool QgsOgrMapToPixelSimplifier::simplifyOgrGeometry( QGis::GeometryType geometryType, const QgsRectangle& envelope, double* xptr, int xStride, double* yptr, int yStride, int pointCount, int& pointSimplifiedCount )
|
||||
{
|
||||
bool canbeGeneralizable = ( mSimplifyFlags & QgsMapToPixelSimplifier::SimplifyGeometry );
|
||||
|
||||
@ -61,19 +61,19 @@ bool QgsOgrMapToPixelSimplifier::simplifyOgrGeometry( QGis::GeometryType geometr
|
||||
|
||||
double map2pixelTol = mMapToPixelTol * QgsMapToPixelSimplifier::calculateViewPixelTolerance( envelope, mMapCoordTransform, mMapToPixel );
|
||||
map2pixelTol *= map2pixelTol; //-> Use mappixelTol for 'LengthSquare' calculations.
|
||||
double x,y, lastX=0, lastY=0;
|
||||
double x, y, lastX = 0, lastY = 0;
|
||||
|
||||
char* xsourcePtr = (char*)xptr;
|
||||
char* ysourcePtr = (char*)yptr;
|
||||
char* xtargetPtr = (char*)xptr;
|
||||
char* ytargetPtr = (char*)yptr;
|
||||
char* xsourcePtr = ( char* )xptr;
|
||||
char* ysourcePtr = ( char* )yptr;
|
||||
char* xtargetPtr = ( char* )xptr;
|
||||
char* ytargetPtr = ( char* )yptr;
|
||||
|
||||
for ( int i = 0, numPoints = geometryType==QGis::Polygon ? pointCount-1 : pointCount; i < numPoints; ++i )
|
||||
for ( int i = 0, numPoints = geometryType == QGis::Polygon ? pointCount - 1 : pointCount; i < numPoints; ++i )
|
||||
{
|
||||
memcpy( &x, xsourcePtr, sizeof( double ) ); xsourcePtr += xStride;
|
||||
memcpy( &y, ysourcePtr, sizeof( double ) ); ysourcePtr += yStride;
|
||||
|
||||
if ( i==0 || !canbeGeneralizable || QgsMapToPixelSimplifier::calculateLengthSquared2D(x,y,lastX,lastY)>map2pixelTol )
|
||||
if ( i == 0 || !canbeGeneralizable || QgsMapToPixelSimplifier::calculateLengthSquared2D( x, y, lastX, lastY ) > map2pixelTol )
|
||||
{
|
||||
memcpy( xtargetPtr, &x, sizeof( double ) ); lastX = x; xtargetPtr += xStride;
|
||||
memcpy( ytargetPtr, &y, sizeof( double ) ); lastY = y; ytargetPtr += yStride;
|
||||
@ -86,7 +86,7 @@ bool QgsOgrMapToPixelSimplifier::simplifyOgrGeometry( QGis::GeometryType geometr
|
||||
memcpy( ytargetPtr, yptr, sizeof( double ) );
|
||||
pointSimplifiedCount++;
|
||||
}
|
||||
return pointSimplifiedCount!=pointCount;
|
||||
return pointSimplifiedCount != pointCount;
|
||||
}
|
||||
|
||||
//! Simplifies the OGR-geometry (Removing duplicated points) when is applied the specified map2pixel context
|
||||
@ -97,17 +97,17 @@ bool QgsOgrMapToPixelSimplifier::simplifyOgrGeometry( OGRGeometry* geometry, boo
|
||||
// Simplify the geometry rewriting temporally its WKB-stream for saving calloc's.
|
||||
if ( wkbGeometryType == wkbLineString )
|
||||
{
|
||||
OGRLineString* lineString = (OGRLineString*)geometry;
|
||||
OGRLineString* lineString = ( OGRLineString* )geometry;
|
||||
|
||||
int numPoints = lineString->getNumPoints();
|
||||
if ( (isaLinearRing && numPoints<=5) || (!isaLinearRing && numPoints<=2) ) return false;
|
||||
if (( isaLinearRing && numPoints <= 5 ) || ( !isaLinearRing && numPoints <= 2 ) ) return false;
|
||||
|
||||
OGREnvelope env;
|
||||
geometry->getEnvelope( &env );
|
||||
QgsRectangle envelope( env.MinX, env.MinY, env.MaxX, env.MaxY );
|
||||
|
||||
// Can replace the geometry by its BBOX ?
|
||||
if ( (mSimplifyFlags & QgsMapToPixelSimplifier::SimplifyEnvelope) && canbeGeneralizedByMapBoundingBox( envelope ) )
|
||||
if (( mSimplifyFlags & QgsMapToPixelSimplifier::SimplifyEnvelope ) && canbeGeneralizedByMapBoundingBox( envelope ) )
|
||||
{
|
||||
OGRRawPoint* points = NULL;
|
||||
int numPoints = 0;
|
||||
@ -139,50 +139,50 @@ bool QgsOgrMapToPixelSimplifier::simplifyOgrGeometry( OGRGeometry* geometry, boo
|
||||
return true;
|
||||
}
|
||||
else
|
||||
if ( mSimplifyFlags & QgsMapToPixelSimplifier::SimplifyGeometry )
|
||||
{
|
||||
QGis::GeometryType geometryType = isaLinearRing ? QGis::Polygon : QGis::Line;
|
||||
int numSimplifiedPoints = 0;
|
||||
|
||||
OGRRawPoint* points = mallocPoints( numPoints );
|
||||
double* xptr = (double*)points;
|
||||
double* yptr = xptr+1;
|
||||
lineString->getPoints( points );
|
||||
|
||||
if ( simplifyOgrGeometry( geometryType, envelope, xptr, 16, yptr, 16, numPoints, numSimplifiedPoints ) )
|
||||
if ( mSimplifyFlags & QgsMapToPixelSimplifier::SimplifyGeometry )
|
||||
{
|
||||
lineString->setPoints( numSimplifiedPoints, points );
|
||||
lineString->flattenTo2D();
|
||||
QGis::GeometryType geometryType = isaLinearRing ? QGis::Polygon : QGis::Line;
|
||||
int numSimplifiedPoints = 0;
|
||||
|
||||
OGRRawPoint* points = mallocPoints( numPoints );
|
||||
double* xptr = ( double* )points;
|
||||
double* yptr = xptr + 1;
|
||||
lineString->getPoints( points );
|
||||
|
||||
if ( simplifyOgrGeometry( geometryType, envelope, xptr, 16, yptr, 16, numPoints, numSimplifiedPoints ) )
|
||||
{
|
||||
lineString->setPoints( numSimplifiedPoints, points );
|
||||
lineString->flattenTo2D();
|
||||
}
|
||||
return numSimplifiedPoints != numPoints;
|
||||
}
|
||||
return numSimplifiedPoints!=numPoints;
|
||||
}
|
||||
}
|
||||
else
|
||||
if ( wkbGeometryType == wkbPolygon )
|
||||
{
|
||||
OGRPolygon* polygon = (OGRPolygon*)geometry;
|
||||
bool result = simplifyOgrGeometry( polygon->getExteriorRing(), true );
|
||||
|
||||
for ( int i = 0, numInteriorRings = polygon->getNumInteriorRings(); i < numInteriorRings; ++i )
|
||||
if ( wkbGeometryType == wkbPolygon )
|
||||
{
|
||||
result |= simplifyOgrGeometry( polygon->getInteriorRing(i), true );
|
||||
}
|
||||
if ( result ) polygon->flattenTo2D();
|
||||
return result;
|
||||
}
|
||||
else
|
||||
if ( wkbGeometryType == wkbMultiLineString || wkbGeometryType == wkbMultiPolygon )
|
||||
{
|
||||
OGRGeometryCollection* collection = (OGRGeometryCollection*)geometry;
|
||||
bool result = false;
|
||||
OGRPolygon* polygon = ( OGRPolygon* )geometry;
|
||||
bool result = simplifyOgrGeometry( polygon->getExteriorRing(), true );
|
||||
|
||||
for ( int i = 0, numGeometries = collection->getNumGeometries(); i < numGeometries; ++i )
|
||||
{
|
||||
result |= simplifyOgrGeometry( collection->getGeometryRef(i), wkbGeometryType==wkbMultiPolygon );
|
||||
for ( int i = 0, numInteriorRings = polygon->getNumInteriorRings(); i < numInteriorRings; ++i )
|
||||
{
|
||||
result |= simplifyOgrGeometry( polygon->getInteriorRing( i ), true );
|
||||
}
|
||||
if ( result ) polygon->flattenTo2D();
|
||||
return result;
|
||||
}
|
||||
if ( result ) collection->flattenTo2D();
|
||||
return result;
|
||||
}
|
||||
else
|
||||
if ( wkbGeometryType == wkbMultiLineString || wkbGeometryType == wkbMultiPolygon )
|
||||
{
|
||||
OGRGeometryCollection* collection = ( OGRGeometryCollection* )geometry;
|
||||
bool result = false;
|
||||
|
||||
for ( int i = 0, numGeometries = collection->getNumGeometries(); i < numGeometries; ++i )
|
||||
{
|
||||
result |= simplifyOgrGeometry( collection->getGeometryRef( i ), wkbGeometryType == wkbMultiPolygon );
|
||||
}
|
||||
if ( result ) collection->flattenTo2D();
|
||||
return result;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -195,7 +195,7 @@ bool QgsOgrMapToPixelSimplifier::simplifyGeometry( OGRGeometry* geometry )
|
||||
|
||||
if ( wkbGeometryType == wkbLineString || wkbGeometryType == wkbPolygon )
|
||||
{
|
||||
return simplifyOgrGeometry( geometry, wkbGeometryType==wkbPolygon );
|
||||
return simplifyOgrGeometry( geometry, wkbGeometryType == wkbPolygon );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ class QgsOgrMapToPixelSimplifier : public QgsMapToPixelSimplifier
|
||||
int mPointBufferCount;
|
||||
|
||||
//! Simplifies the OGR-geometry (Removing duplicated points) when is applied the specified map2pixel context
|
||||
bool simplifyOgrGeometry( QGis::GeometryType geometryType, const QgsRectangle& envelope, double* xptr, int xStride, double* yptr, int yStride, int pointCount, int& pointSimplifiedCount);
|
||||
bool simplifyOgrGeometry( QGis::GeometryType geometryType, const QgsRectangle& envelope, double* xptr, int xStride, double* yptr, int yStride, int pointCount, int& pointSimplifiedCount );
|
||||
//! Simplifies the OGR-geometry (Removing duplicated points) when is applied the specified map2pixel context
|
||||
bool simplifyOgrGeometry( OGRGeometry* geometry, bool isaLinearRing );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user