Skip to content

Commit 2cfe27b

Browse files
committedNov 7, 2013
Merge remote-tracking branch 'upstream/master' into Issue_8725-OGR
2 parents e63e92e + 866cee4 commit 2cfe27b

File tree

16 files changed

+328
-394
lines changed

16 files changed

+328
-394
lines changed
 

‎i18n/qgis_lt.ts

Lines changed: 220 additions & 209 deletions
Large diffs are not rendered by default.

‎python/plugins/processing/algs/mmqgisx/MMQGISXAlgorithms.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,8 @@ def processAlgorithm(self, progress):
11361136

11371137
filename = self.getParameterValue(self.LAYERNAME)
11381138
layer = dataobjects.getObjectFromUri(filename)
1139-
1139+
provider = layer.dataProvider()
1140+
fields = provider.fields()
11401141
attribute = self.getParameterValue(self.ATTRIBUTE)
11411142
comparison = self.comparisons[self.getParameterValue(self.COMPARISON)]
11421143
comparisonvalue = self.getParameterValue(self.COMPARISONVALUE)
@@ -1146,8 +1147,8 @@ def processAlgorithm(self, progress):
11461147
features = vector.features(layer)
11471148
featureCount = len(features)
11481149
output = self.getOutputFromName(self.OUTPUT)
1149-
writer = output.getVectorWriter(layer.fields(),
1150-
layer.geometryType(), layer.crs())
1150+
writer = output.getVectorWriter(fields,
1151+
provider.geometryType(), layer.crs())
11511152
for (i, feat) in enumerate(features):
11521153
if feat.id() in selected:
11531154
writer.addFeature(feat)

‎python/plugins/processing/script/ScriptAlgorithm.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
from processing.outputs.OutputFactory import OutputFactory
5353
from processing.script.WrongScriptException import WrongScriptException
5454

55-
5655
class ScriptAlgorithm(GeoAlgorithm):
5756

5857
def __init__(self, descriptionFile, script=None):
@@ -141,6 +140,15 @@ def processParameterLine(self, line):
141140
elif tokens[1].lower().strip() == 'vector':
142141
param = ParameterVector(tokens[0], desc,
143142
[ParameterVector.VECTOR_TYPE_ANY])
143+
elif tokens[1].lower().strip() == 'vector point':
144+
param = ParameterVector(tokens[0], desc,
145+
[ParameterVector.VECTOR_TYPE_POINT])
146+
elif tokens[1].lower().strip() == 'vector line':
147+
param = ParameterVector(tokens[0], desc,
148+
[ParameterVector.VECTOR_TYPE_LINE])
149+
elif tokens[1].lower().strip() == 'vector polygon':
150+
param = ParameterVector(tokens[0], desc,
151+
[ParameterVector.VECTOR_TYPE_POLYGON])
144152
elif tokens[1].lower().strip() == 'table':
145153
param = ParameterTable(tokens[0], desc, False)
146154
elif tokens[1].lower().strip() == 'multiple raster':

‎python/plugins/processing/tools/vector.py

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -43,34 +43,16 @@ class Features:
4343

4444
def __init__(self, layer):
4545
self.layer = layer
46-
self.iter = layer.getFeatures()
4746
self.selection = False
47+
self.iter = layer.getFeatures()
4848
if ProcessingConfig.getSetting(ProcessingConfig.USE_SELECTED):
49-
self.selected = layer.selectedFeatures()
50-
if len(self.selected) > 0:
49+
selected = layer.selectedFeatures()
50+
if len(selected) > 0:
5151
self.selection = True
52-
self.idx = 0
52+
self.iter = iter(selected)
5353

5454
def __iter__(self):
55-
return self
56-
57-
def next(self):
58-
if self.selection:
59-
if self.idx < len(self.selected):
60-
feature = self.selected[self.idx]
61-
self.idx += 1
62-
return feature
63-
else:
64-
raise StopIteration()
65-
else:
66-
if self.iter.isClosed():
67-
raise StopIteration()
68-
f = QgsFeature()
69-
if self.iter.nextFeature(f):
70-
return f
71-
else:
72-
self.iter.close()
73-
raise StopIteration()
55+
return self.iter
7456

7557
def __len__(self):
7658
if self.selection:

‎src/app/legend/qgslegend.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,9 @@ void QgsLegend::removeAll()
292292
updateMapCanvasLayerSet();
293293
setIconSize( mMinimumIconSize );
294294
mDropTarget = 0;
295+
mUpdateDrawingOrder = true;
296+
emit updateDrawingOrderChecked( true );
297+
emit updateDrawingOrderUnchecked( false );
295298
}
296299

297300
void QgsLegend::setLayersVisible( bool visible )

‎src/core/pal/costcalculator.cpp

Lines changed: 8 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -216,151 +216,31 @@ namespace pal
216216

217217
PolygonCostCalculator::PolygonCostCalculator( LabelPosition *lp ) : lp( lp )
218218
{
219-
int i;
220-
double hyp = max( lp->feature->xmax - lp->feature->xmin, lp->feature->ymax - lp->feature->ymin );
221-
hyp *= 10;
222-
223219
px = ( lp->x[0] + lp->x[2] ) / 2.0;
224220
py = ( lp->y[0] + lp->y[2] ) / 2.0;
225221

226-
/*
227-
3 2 1
228-
\ | /
229-
4 --x -- 0
230-
/ | \
231-
5 6 7
232-
*/
233-
234-
double alpha = lp->getAlpha();
235-
for ( i = 0; i < 8; i++, alpha += M_PI_4 )
236-
{
237-
dist[i] = DBL_MAX;
238-
ok[i] = false;
239-
rpx[i] = px + cos( alpha ) * hyp;
240-
rpy[i] = py + sin( alpha ) * hyp;
241-
}
222+
dist = DBL_MAX;
223+
ok = false;
242224
}
243225

244226
void PolygonCostCalculator::update( PointSet *pset )
245227
{
246-
if ( pset->type == GEOS_POINT )
228+
double rx, ry;
229+
pset->getDist( px, py, &rx, &ry );
230+
double d = dist_euc2d_sq( px, py, rx, ry );
231+
if ( d < dist )
247232
{
248-
updatePoint( pset );
249-
}
250-
else
251-
{
252-
double rx, ry;
253-
if ( pset->getDist( px, py, &rx, &ry ) < updateLinePoly( pset ) )
254-
{
255-
PointSet *point = new PointSet( ry, ry );
256-
update( point );
257-
delete point;
258-
}
259-
}
260-
}
261-
262-
void PolygonCostCalculator::updatePoint( PointSet *pset )
263-
{
264-
double beta = atan2( pset->y[0] - py, pset->x[0] - px ) - lp->getAlpha();
265-
266-
while ( beta < 0.0 )
267-
{
268-
beta += 2 * M_PI;
269-
}
270-
271-
int i = ( int ) floor( beta / M_PI_4 ) % 8;
272-
273-
for ( int j = 0; j < 2; j++, i = ( i + 1 ) % 8 )
274-
{
275-
double rx, ry;
276-
rx = px - rpy[i] + py;
277-
ry = py + rpx[i] - px;
278-
double ix, iy; // the point that we look for
279-
if ( computeLineIntersection( px, py, rpx[i], rpy[i], pset->x[0], pset->y[0], rx, ry, &ix, &iy ) )
280-
{
281-
double d = dist_euc2d_sq( px, py, ix, iy );
282-
if ( d < dist[i] )
283-
{
284-
dist[i] = d;
285-
ok[i] = true;
286-
}
287-
}
288-
else
289-
{
290-
std::cout << "this shouldn't occur!!!" << std::endl;
291-
}
233+
dist = d;
292234
}
293235
}
294236

295-
double PolygonCostCalculator::updateLinePoly( PointSet *pset )
296-
{
297-
int i, j, k;
298-
int nbP = ( pset->type == GEOS_POLYGON ? pset->nbPoints : pset->nbPoints - 1 );
299-
double min_dist = DBL_MAX;
300-
301-
for ( i = 0; i < nbP; i++ )
302-
{
303-
j = ( i + 1 ) % pset->nbPoints;
304-
305-
for ( k = 0; k < 8; k++ )
306-
{
307-
double ix, iy;
308-
if ( computeSegIntersection( px, py, rpx[k], rpy[k], pset->x[i], pset->y[i], pset->x[j], pset->y[j], &ix, &iy ) )
309-
{
310-
double d = dist_euc2d_sq( px, py, ix, iy );
311-
if ( d < dist[k] )
312-
{
313-
dist[k] = d;
314-
ok[k] = true;
315-
}
316-
if ( d < min_dist )
317-
{
318-
min_dist = d;
319-
}
320-
}
321-
}
322-
}
323-
return min_dist;
324-
}
325-
326237
LabelPosition* PolygonCostCalculator::getLabel()
327238
{
328239
return lp;
329240
}
330241

331242
double PolygonCostCalculator::getCost()
332243
{
333-
int i;
334-
335-
for ( i = 0; i < 8; i++ )
336-
{
337-
#if 0
338-
if ( i == 0 || i == 4 ) // horizontal directions
339-
dist[i] -= lp->w / 2;
340-
else if ( i == 2 || i == 6 ) // vertical directions
341-
dist[i] -= lp->h / 2;
342-
else // other directions
343-
dist[i] -= ( lp->w / 2 ) / cos( M_PI_4 );
344-
#endif
345-
346-
if ( !ok[i] || dist[i] < EPSILON )
347-
{
348-
dist[i] = EPSILON;
349-
}
350-
}
351-
352-
double a, b, c, d;
353-
354-
a = min( dist[0], dist[4] );
355-
b = min( dist[1], dist[5] );
356-
c = min( dist[2], dist[6] );
357-
d = min( dist[3], dist[7] );
358-
359-
#if 0
360-
if ( a != EPSILON || b != EPSILON || c != EPSILON || d != EPSILON )
361-
std::cout << "res " << ( a*b*c*d ) << " " << a << " " << b << " " << c << " " << d << std::endl;
362-
#endif
363-
return ( a*b*c*d );
244+
return ( 4 * dist );
364245
}
365-
366246
}

‎src/core/pal/costcalculator.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,9 @@ namespace pal
4747
{
4848
LabelPosition *lp;
4949
double px, py;
50-
double dist[8];
51-
double rpx[8];
52-
double rpy[8];
53-
bool ok[8];
50+
double dist;
51+
bool ok;
5452

55-
void updatePoint( PointSet *pset );
56-
double updateLinePoly( PointSet *pset );
5753
public:
5854
PolygonCostCalculator( LabelPosition *lp );
5955

‎src/core/pal/feature.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,10 @@ namespace pal
11031103
j++;
11041104
}
11051105

1106-
dx = dy = min( yrm, xrm ) / 2;
1106+
//dx = dy = min( yrm, xrm ) / 2;
1107+
dx = xrm / 2.0;
1108+
dy = yrm / 2.0;
1109+
11071110

11081111
int num_try = 0;
11091112
int max_try = 10;

‎src/core/qgsgeometry.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2890,9 +2890,12 @@ int QgsGeometry::addRing( const QList<QgsPoint>& ring )
28902890
return 0;
28912891
}
28922892

2893-
int QgsGeometry::addPart( const QList<QgsPoint> &points )
2893+
int QgsGeometry::addPart( const QList<QgsPoint> &points, QGis::GeometryType geomType )
28942894
{
2895-
QGis::GeometryType geomType = type();
2895+
if ( geomType == QGis::UnknownGeometry )
2896+
{
2897+
geomType = type();
2898+
}
28962899

28972900
switch ( geomType )
28982901
{
@@ -2977,6 +2980,11 @@ int QgsGeometry::addPart( const QList<QgsPoint> &points )
29772980
return 2;
29782981
}
29792982

2983+
if ( type() == QGis::UnknownGeometry )
2984+
{
2985+
fromGeos( newPart );
2986+
return 0;
2987+
}
29802988
return addPart( newPart );
29812989
}
29822990

‎src/core/qgsgeometry.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ class CORE_EXPORT QgsGeometry
265265
/**Adds a new island polygon to a multipolygon feature
266266
@return 0 in case of success, 1 if not a multipolygon, 2 if ring is not a valid geometry, 3 if new polygon ring
267267
not disjoint with existing polygons of the feature*/
268-
int addPart( const QList<QgsPoint> &points );
268+
int addPart( const QList<QgsPoint> &points, QGis::GeometryType geomType = QGis::UnknownGeometry );
269269

270270
/**Adds a new island polygon to a multipolygon feature
271271
@return 0 in case of success, 1 if not a multipolygon, 2 if ring is not a valid geometry, 3 if new polygon ring

‎src/core/qgsvectorlayereditutils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ int QgsVectorLayerEditUtils::addPart( const QList<QgsPoint> &points, QgsFeatureI
130130
geometry = *f.geometry();
131131
}
132132

133-
int errorCode = geometry.addPart( points );
133+
int errorCode = geometry.addPart( points, L->geometryType() );
134134
if ( errorCode == 0 )
135135
{
136136
L->editBuffer()->changeGeometry( featureId, &geometry );

‎src/gui/qgsnewhttpconnection.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ QgsNewHttpConnection::QgsNewHttpConnection(
114114

115115
cmbDpiMode->setVisible( false );
116116
mGroupBox->layout()->removeWidget( cmbDpiMode );
117+
lblDpiMode->setVisible( false );
118+
mGroupBox->layout()->removeWidget( lblDpiMode );
117119

118120
txtReferer->setVisible( false );
119121
mGroupBox->layout()->removeWidget( txtReferer );

‎src/providers/oracle/qgsoracleprovider.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1993,6 +1993,28 @@ QgsRectangle QgsOracleProvider::extent()
19931993
QString sql;
19941994
QSqlQuery qry( *mConnection );
19951995

1996+
if ( mUseEstimatedMetadata )
1997+
{
1998+
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'" )
1999+
.arg( quotedValue( mOwnerName ) )
2000+
.arg( quotedValue( mTableName ) )
2001+
.arg( quotedValue( mGeometryColumn ) ) ) && qry.next() )
2002+
{
2003+
mLayerExtent.setXMinimum( qry.value( 0 ).toDouble() );
2004+
mLayerExtent.setXMaximum( qry.value( 1 ).toDouble() );
2005+
2006+
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'" )
2007+
.arg( quotedValue( mOwnerName ) )
2008+
.arg( quotedValue( mTableName ) )
2009+
.arg( quotedValue( mGeometryColumn ) ) ) && qry.next() )
2010+
{
2011+
mLayerExtent.setYMinimum( qry.value( 0 ).toDouble() );
2012+
mLayerExtent.setYMaximum( qry.value( 1 ).toDouble() );
2013+
return mLayerExtent;
2014+
}
2015+
}
2016+
}
2017+
19962018
bool ok = false;
19972019

19982020
if ( !mSpatialIndex.isNull() && ( mUseEstimatedMetadata || mSqlWhereClause.isEmpty() ) )

‎src/providers/wms/qgswmsprovider.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,6 +1132,8 @@ void QgsWmsProvider::tileReplyFinished()
11321132
int tileReqNo = reply->request().attribute( static_cast<QNetworkRequest::Attribute>( TileReqNo ) ).toInt();
11331133
int tileNo = reply->request().attribute( static_cast<QNetworkRequest::Attribute>( TileIndex ) ).toInt();
11341134
QRectF r = reply->request().attribute( static_cast<QNetworkRequest::Attribute>( TileRect ) ).toRectF();
1135+
1136+
#ifdef QGISDEBUG
11351137
int retry = reply->request().attribute( static_cast<QNetworkRequest::Attribute>( TileRetry ) ).toInt();
11361138

11371139
#if QT_VERSION >= 0x40500
@@ -1149,6 +1151,7 @@ void QgsWmsProvider::tileReplyFinished()
11491151
.arg( reply->errorString() )
11501152
.arg( reply->url().toString() )
11511153
);
1154+
#endif
11521155
#endif
11531156

11541157
if ( reply->error() == QNetworkReply::NoError )

‎src/providers/wms/qgswmssourceselect.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ bool QgsWMSSourceSelect::populateLayerList( QgsWmsProvider *wmsProvider )
387387
item->setData( Qt::UserRole + 2, style.identifier );
388388
item->setData( Qt::UserRole + 3, setLink.tileMatrixSet );
389389
item->setData( Qt::UserRole + 4, tileMatrixSets[ setLink.tileMatrixSet ].crs );
390+
item->setData( Qt::UserRole + 5, l.title );
390391

391392
lstTilesets->setItem( row, 0, item );
392393
lstTilesets->setItem( row, 1, new QTableWidgetItem( format ) );
@@ -571,7 +572,6 @@ void QgsWMSSourceSelect::addClicked()
571572
emit addRasterLayer( uri.encodedUri(),
572573
leLayerName->text().isEmpty() ? layers.join( "/" ) : leLayerName->text(),
573574
"wms" );
574-
575575
}
576576

577577
void QgsWMSSourceSelect::enableLayersForCrs( QTreeWidgetItem *item )
@@ -950,10 +950,21 @@ void QgsWMSSourceSelect::updateButtons()
950950
{
951951
if ( mAddButton->isEnabled() )
952952
{
953-
QStringList layers, styles;
954-
collectSelectedLayers( layers, styles );
955-
mLastLayerName = layers.join( "/" );
956-
leLayerName->setText( mLastLayerName );
953+
if ( !lstTilesets->selectedItems().isEmpty() )
954+
{
955+
QTableWidgetItem *item = lstTilesets->selectedItems().first();
956+
mLastLayerName = item->data( Qt::UserRole + 5 ).toString();
957+
if ( mLastLayerName.isEmpty() )
958+
mLastLayerName = item->data( Qt::UserRole + 0 ).toString();
959+
leLayerName->setText( mLastLayerName );
960+
}
961+
else
962+
{
963+
QStringList layers, styles;
964+
collectSelectedLayers( layers, styles );
965+
mLastLayerName = layers.join( "/" );
966+
leLayerName->setText( mLastLayerName );
967+
}
957968
}
958969
else
959970
{

‎src/ui/qgswmssourceselectbase.ui

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<bool>true</bool>
2525
</property>
2626
<layout class="QGridLayout" name="gridLayout_2">
27-
<item row="3" column="0">
27+
<item row="2" column="0">
2828
<widget class="QDialogButtonBox" name="buttonBox">
2929
<property name="standardButtons">
3030
<set>QDialogButtonBox::Close|QDialogButtonBox::Help</set>
@@ -207,19 +207,6 @@
207207
<string>Options</string>
208208
</property>
209209
<layout class="QGridLayout">
210-
<item row="0" column="0">
211-
<widget class="QLabel" name="label">
212-
<property name="text">
213-
<string>Layer name</string>
214-
</property>
215-
<property name="buddy">
216-
<cstring>leLayerName</cstring>
217-
</property>
218-
</widget>
219-
</item>
220-
<item row="0" column="1" colspan="2">
221-
<widget class="QLineEdit" name="leLayerName"/>
222-
</item>
223210
<item row="3" column="0" colspan="2">
224211
<widget class="QLabel" name="labelCoordRefSys">
225212
<property name="text">
@@ -451,6 +438,23 @@
451438
</widget>
452439
</widget>
453440
</item>
441+
<item row="1" column="0">
442+
<layout class="QHBoxLayout" name="horizontalLayout">
443+
<item>
444+
<widget class="QLabel" name="label">
445+
<property name="text">
446+
<string>Layer name</string>
447+
</property>
448+
<property name="buddy">
449+
<cstring>leLayerName</cstring>
450+
</property>
451+
</widget>
452+
</item>
453+
<item>
454+
<widget class="QLineEdit" name="leLayerName"/>
455+
</item>
456+
</layout>
457+
</item>
454458
</layout>
455459
</widget>
456460
<layoutdefault spacing="6" margin="11"/>

0 commit comments

Comments
 (0)
Please sign in to comment.