Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into Issue_8725-OGR
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuarte47 committed Nov 7, 2013
2 parents e63e92e + 866cee4 commit 2cfe27b
Show file tree
Hide file tree
Showing 16 changed files with 328 additions and 394 deletions.
429 changes: 220 additions & 209 deletions i18n/qgis_lt.ts

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions python/plugins/processing/algs/mmqgisx/MMQGISXAlgorithms.py
Expand Up @@ -1136,7 +1136,8 @@ def processAlgorithm(self, progress):

filename = self.getParameterValue(self.LAYERNAME)
layer = dataobjects.getObjectFromUri(filename)

provider = layer.dataProvider()
fields = provider.fields()
attribute = self.getParameterValue(self.ATTRIBUTE)
comparison = self.comparisons[self.getParameterValue(self.COMPARISON)]
comparisonvalue = self.getParameterValue(self.COMPARISONVALUE)
Expand All @@ -1146,8 +1147,8 @@ def processAlgorithm(self, progress):
features = vector.features(layer)
featureCount = len(features)
output = self.getOutputFromName(self.OUTPUT)
writer = output.getVectorWriter(layer.fields(),
layer.geometryType(), layer.crs())
writer = output.getVectorWriter(fields,
provider.geometryType(), layer.crs())
for (i, feat) in enumerate(features):
if feat.id() in selected:
writer.addFeature(feat)
Expand Down
10 changes: 9 additions & 1 deletion python/plugins/processing/script/ScriptAlgorithm.py
Expand Up @@ -52,7 +52,6 @@
from processing.outputs.OutputFactory import OutputFactory
from processing.script.WrongScriptException import WrongScriptException


class ScriptAlgorithm(GeoAlgorithm):

def __init__(self, descriptionFile, script=None):
Expand Down Expand Up @@ -141,6 +140,15 @@ def processParameterLine(self, line):
elif tokens[1].lower().strip() == 'vector':
param = ParameterVector(tokens[0], desc,
[ParameterVector.VECTOR_TYPE_ANY])
elif tokens[1].lower().strip() == 'vector point':
param = ParameterVector(tokens[0], desc,
[ParameterVector.VECTOR_TYPE_POINT])
elif tokens[1].lower().strip() == 'vector line':
param = ParameterVector(tokens[0], desc,
[ParameterVector.VECTOR_TYPE_LINE])
elif tokens[1].lower().strip() == 'vector polygon':
param = ParameterVector(tokens[0], desc,
[ParameterVector.VECTOR_TYPE_POLYGON])
elif tokens[1].lower().strip() == 'table':
param = ParameterTable(tokens[0], desc, False)
elif tokens[1].lower().strip() == 'multiple raster':
Expand Down
28 changes: 5 additions & 23 deletions python/plugins/processing/tools/vector.py
Expand Up @@ -43,34 +43,16 @@ class Features:

def __init__(self, layer):
self.layer = layer
self.iter = layer.getFeatures()
self.selection = False
self.iter = layer.getFeatures()
if ProcessingConfig.getSetting(ProcessingConfig.USE_SELECTED):
self.selected = layer.selectedFeatures()
if len(self.selected) > 0:
selected = layer.selectedFeatures()
if len(selected) > 0:
self.selection = True
self.idx = 0
self.iter = iter(selected)

def __iter__(self):
return self

def next(self):
if self.selection:
if self.idx < len(self.selected):
feature = self.selected[self.idx]
self.idx += 1
return feature
else:
raise StopIteration()
else:
if self.iter.isClosed():
raise StopIteration()
f = QgsFeature()
if self.iter.nextFeature(f):
return f
else:
self.iter.close()
raise StopIteration()
return self.iter

def __len__(self):
if self.selection:
Expand Down
3 changes: 3 additions & 0 deletions src/app/legend/qgslegend.cpp
Expand Up @@ -292,6 +292,9 @@ void QgsLegend::removeAll()
updateMapCanvasLayerSet();
setIconSize( mMinimumIconSize );
mDropTarget = 0;
mUpdateDrawingOrder = true;
emit updateDrawingOrderChecked( true );
emit updateDrawingOrderUnchecked( false );
}

void QgsLegend::setLayersVisible( bool visible )
Expand Down
136 changes: 8 additions & 128 deletions src/core/pal/costcalculator.cpp
Expand Up @@ -216,151 +216,31 @@ namespace pal

PolygonCostCalculator::PolygonCostCalculator( LabelPosition *lp ) : lp( lp )
{
int i;
double hyp = max( lp->feature->xmax - lp->feature->xmin, lp->feature->ymax - lp->feature->ymin );
hyp *= 10;

px = ( lp->x[0] + lp->x[2] ) / 2.0;
py = ( lp->y[0] + lp->y[2] ) / 2.0;

/*
3 2 1
\ | /
4 --x -- 0
/ | \
5 6 7
*/

double alpha = lp->getAlpha();
for ( i = 0; i < 8; i++, alpha += M_PI_4 )
{
dist[i] = DBL_MAX;
ok[i] = false;
rpx[i] = px + cos( alpha ) * hyp;
rpy[i] = py + sin( alpha ) * hyp;
}
dist = DBL_MAX;
ok = false;
}

void PolygonCostCalculator::update( PointSet *pset )
{
if ( pset->type == GEOS_POINT )
double rx, ry;
pset->getDist( px, py, &rx, &ry );
double d = dist_euc2d_sq( px, py, rx, ry );
if ( d < dist )
{
updatePoint( pset );
}
else
{
double rx, ry;
if ( pset->getDist( px, py, &rx, &ry ) < updateLinePoly( pset ) )
{
PointSet *point = new PointSet( ry, ry );
update( point );
delete point;
}
}
}

void PolygonCostCalculator::updatePoint( PointSet *pset )
{
double beta = atan2( pset->y[0] - py, pset->x[0] - px ) - lp->getAlpha();

while ( beta < 0.0 )
{
beta += 2 * M_PI;
}

int i = ( int ) floor( beta / M_PI_4 ) % 8;

for ( int j = 0; j < 2; j++, i = ( i + 1 ) % 8 )
{
double rx, ry;
rx = px - rpy[i] + py;
ry = py + rpx[i] - px;
double ix, iy; // the point that we look for
if ( computeLineIntersection( px, py, rpx[i], rpy[i], pset->x[0], pset->y[0], rx, ry, &ix, &iy ) )
{
double d = dist_euc2d_sq( px, py, ix, iy );
if ( d < dist[i] )
{
dist[i] = d;
ok[i] = true;
}
}
else
{
std::cout << "this shouldn't occur!!!" << std::endl;
}
dist = d;
}
}

double PolygonCostCalculator::updateLinePoly( PointSet *pset )
{
int i, j, k;
int nbP = ( pset->type == GEOS_POLYGON ? pset->nbPoints : pset->nbPoints - 1 );
double min_dist = DBL_MAX;

for ( i = 0; i < nbP; i++ )
{
j = ( i + 1 ) % pset->nbPoints;

for ( k = 0; k < 8; k++ )
{
double ix, iy;
if ( computeSegIntersection( px, py, rpx[k], rpy[k], pset->x[i], pset->y[i], pset->x[j], pset->y[j], &ix, &iy ) )
{
double d = dist_euc2d_sq( px, py, ix, iy );
if ( d < dist[k] )
{
dist[k] = d;
ok[k] = true;
}
if ( d < min_dist )
{
min_dist = d;
}
}
}
}
return min_dist;
}

LabelPosition* PolygonCostCalculator::getLabel()
{
return lp;
}

double PolygonCostCalculator::getCost()
{
int i;

for ( i = 0; i < 8; i++ )
{
#if 0
if ( i == 0 || i == 4 ) // horizontal directions
dist[i] -= lp->w / 2;
else if ( i == 2 || i == 6 ) // vertical directions
dist[i] -= lp->h / 2;
else // other directions
dist[i] -= ( lp->w / 2 ) / cos( M_PI_4 );
#endif

if ( !ok[i] || dist[i] < EPSILON )
{
dist[i] = EPSILON;
}
}

double a, b, c, d;

a = min( dist[0], dist[4] );
b = min( dist[1], dist[5] );
c = min( dist[2], dist[6] );
d = min( dist[3], dist[7] );

#if 0
if ( a != EPSILON || b != EPSILON || c != EPSILON || d != EPSILON )
std::cout << "res " << ( a*b*c*d ) << " " << a << " " << b << " " << c << " " << d << std::endl;
#endif
return ( a*b*c*d );
return ( 4 * dist );
}

}
8 changes: 2 additions & 6 deletions src/core/pal/costcalculator.h
Expand Up @@ -47,13 +47,9 @@ namespace pal
{
LabelPosition *lp;
double px, py;
double dist[8];
double rpx[8];
double rpy[8];
bool ok[8];
double dist;
bool ok;

void updatePoint( PointSet *pset );
double updateLinePoly( PointSet *pset );
public:
PolygonCostCalculator( LabelPosition *lp );

Expand Down
5 changes: 4 additions & 1 deletion src/core/pal/feature.cpp
Expand Up @@ -1103,7 +1103,10 @@ namespace pal
j++;
}

dx = dy = min( yrm, xrm ) / 2;
//dx = dy = min( yrm, xrm ) / 2;
dx = xrm / 2.0;
dy = yrm / 2.0;


int num_try = 0;
int max_try = 10;
Expand Down
12 changes: 10 additions & 2 deletions src/core/qgsgeometry.cpp
Expand Up @@ -2890,9 +2890,12 @@ int QgsGeometry::addRing( const QList<QgsPoint>& ring )
return 0;
}

int QgsGeometry::addPart( const QList<QgsPoint> &points )
int QgsGeometry::addPart( const QList<QgsPoint> &points, QGis::GeometryType geomType )
{
QGis::GeometryType geomType = type();
if ( geomType == QGis::UnknownGeometry )
{
geomType = type();
}

switch ( geomType )
{
Expand Down Expand Up @@ -2977,6 +2980,11 @@ int QgsGeometry::addPart( const QList<QgsPoint> &points )
return 2;
}

if ( type() == QGis::UnknownGeometry )
{
fromGeos( newPart );
return 0;
}
return addPart( newPart );
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsgeometry.h
Expand Up @@ -265,7 +265,7 @@ class CORE_EXPORT QgsGeometry
/**Adds a new island polygon to a multipolygon feature
@return 0 in case of success, 1 if not a multipolygon, 2 if ring is not a valid geometry, 3 if new polygon ring
not disjoint with existing polygons of the feature*/
int addPart( const QList<QgsPoint> &points );
int addPart( const QList<QgsPoint> &points, QGis::GeometryType geomType = QGis::UnknownGeometry );

/**Adds a new island polygon to a multipolygon feature
@return 0 in case of success, 1 if not a multipolygon, 2 if ring is not a valid geometry, 3 if new polygon ring
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectorlayereditutils.cpp
Expand Up @@ -130,7 +130,7 @@ int QgsVectorLayerEditUtils::addPart( const QList<QgsPoint> &points, QgsFeatureI
geometry = *f.geometry();
}

int errorCode = geometry.addPart( points );
int errorCode = geometry.addPart( points, L->geometryType() );
if ( errorCode == 0 )
{
L->editBuffer()->changeGeometry( featureId, &geometry );
Expand Down
2 changes: 2 additions & 0 deletions src/gui/qgsnewhttpconnection.cpp
Expand Up @@ -114,6 +114,8 @@ QgsNewHttpConnection::QgsNewHttpConnection(

cmbDpiMode->setVisible( false );
mGroupBox->layout()->removeWidget( cmbDpiMode );
lblDpiMode->setVisible( false );
mGroupBox->layout()->removeWidget( lblDpiMode );

txtReferer->setVisible( false );
mGroupBox->layout()->removeWidget( txtReferer );
Expand Down
22 changes: 22 additions & 0 deletions src/providers/oracle/qgsoracleprovider.cpp
Expand Up @@ -1993,6 +1993,28 @@ QgsRectangle QgsOracleProvider::extent()
QString sql;
QSqlQuery qry( *mConnection );

if ( mUseEstimatedMetadata )
{
if ( exec( qry, QString( "SELECT sdo_lb,sdo_ub FROM mdsys.all_sdo_geom_metadata m, table(m.diminfo) WHERE owner=%1 AND table_name=%2 AND column_name=%3 AND sdo_dimname='X'" )
.arg( quotedValue( mOwnerName ) )
.arg( quotedValue( mTableName ) )
.arg( quotedValue( mGeometryColumn ) ) ) && qry.next() )
{
mLayerExtent.setXMinimum( qry.value( 0 ).toDouble() );
mLayerExtent.setXMaximum( qry.value( 1 ).toDouble() );

if ( exec( qry, QString( "SELECT sdo_lb,sdo_ub FROM mdsys.all_sdo_geom_metadata m, table(m.diminfo) WHERE owner=%1 AND table_name=%2 AND column_name=%3 AND sdo_dimname='Y'" )
.arg( quotedValue( mOwnerName ) )
.arg( quotedValue( mTableName ) )
.arg( quotedValue( mGeometryColumn ) ) ) && qry.next() )
{
mLayerExtent.setYMinimum( qry.value( 0 ).toDouble() );
mLayerExtent.setYMaximum( qry.value( 1 ).toDouble() );
return mLayerExtent;
}
}
}

bool ok = false;

if ( !mSpatialIndex.isNull() && ( mUseEstimatedMetadata || mSqlWhereClause.isEmpty() ) )
Expand Down
3 changes: 3 additions & 0 deletions src/providers/wms/qgswmsprovider.cpp
Expand Up @@ -1132,6 +1132,8 @@ void QgsWmsProvider::tileReplyFinished()
int tileReqNo = reply->request().attribute( static_cast<QNetworkRequest::Attribute>( TileReqNo ) ).toInt();
int tileNo = reply->request().attribute( static_cast<QNetworkRequest::Attribute>( TileIndex ) ).toInt();
QRectF r = reply->request().attribute( static_cast<QNetworkRequest::Attribute>( TileRect ) ).toRectF();

#ifdef QGISDEBUG
int retry = reply->request().attribute( static_cast<QNetworkRequest::Attribute>( TileRetry ) ).toInt();

#if QT_VERSION >= 0x40500
Expand All @@ -1149,6 +1151,7 @@ void QgsWmsProvider::tileReplyFinished()
.arg( reply->errorString() )
.arg( reply->url().toString() )
);
#endif
#endif

if ( reply->error() == QNetworkReply::NoError )
Expand Down

0 comments on commit 2cfe27b

Please sign in to comment.