Skip to content

Commit 974e60c

Browse files
committed
Merge branch 'master' into MultiColumnPK_DbManagerQuery
2 parents d8deb8c + cc9c789 commit 974e60c

31 files changed

+391
-109
lines changed

cmake/FindGRASS.cmake

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,25 @@ MACRO (CHECK_GRASS G_PREFIX)
6262

6363
# LIB_PATH is only temporary variable, so hide it (is it possible to delete a variable?)
6464
UNSET(LIB_PATH CACHE)
65+
66+
# Find off_t size
67+
IF( (GRASS_MAJOR_VERSION${GRASS_FIND_VERSION} EQUAL 7) AND (GRASS_MINOR_VERSION${GRASS_FIND_VERSION} GREATER 0) )
68+
SET(GRASS_TEST_MAPSET ${CMAKE_BINARY_DIR}/grass-location/PERMANENT)
69+
FILE(MAKE_DIRECTORY ${GRASS_TEST_MAPSET})
70+
FILE(WRITE ${GRASS_TEST_MAPSET}/DEFAULT_WIND "")
71+
FILE(WRITE ${GRASS_TEST_MAPSET}/WIND "")
72+
# grass command is not in G_PREFIX but in some bin dir, so it must be in PATH
73+
SET(GRASS_EXE grass7${GRASS_MINOR_VERSION${GRASS_FIND_VERSION}})
74+
#MESSAGE(STATUS "GRASS_EXE = ${GRASS_EXE}")
75+
EXECUTE_PROCESS(COMMAND ${GRASS_EXE} ${GRASS_TEST_MAPSET} --exec g.version -g
76+
COMMAND grep build_off_t_size
77+
COMMAND sed "s/.*\\([0-9]\\).*/\\1/"
78+
ERROR_VARIABLE GRASS_TMP_ERROR
79+
OUTPUT_VARIABLE GRASS_OFF_T_SIZE${GRASS_FIND_VERSION}
80+
)
81+
STRING(STRIP ${GRASS_OFF_T_SIZE${GRASS_FIND_VERSION}} GRASS_OFF_T_SIZE${GRASS_FIND_VERSION})
82+
#MESSAGE(STATUS "GRASS_OFF_T_SIZE${GRASS_FIND_VERSION} = ${GRASS_OFF_T_SIZE${GRASS_FIND_VERSION}}")
83+
ENDIF( (GRASS_MAJOR_VERSION${GRASS_FIND_VERSION} EQUAL 7) AND (GRASS_MINOR_VERSION${GRASS_FIND_VERSION} GREATER 0) )
6584

6685
IF(GRASS_LIBRARIES_FOUND${GRASS_FIND_VERSION})
6786
SET(GRASS_FOUND${GRASS_FIND_VERSION} TRUE)
@@ -127,7 +146,7 @@ ENDIF (WITH_GRASS${GRASS_CACHE_VERSION})
127146

128147
IF (GRASS_FOUND${GRASS_FIND_VERSION})
129148
IF (NOT GRASS_FIND_QUIETLY)
130-
MESSAGE(STATUS "Found GRASS ${GRASS_FIND_VERSION}: ${GRASS_PREFIX${GRASS_CACHE_VERSION}} (${GRASS_VERSION${GRASS_FIND_VERSION}})")
149+
MESSAGE(STATUS "Found GRASS ${GRASS_FIND_VERSION}: ${GRASS_PREFIX${GRASS_CACHE_VERSION}} (${GRASS_VERSION${GRASS_FIND_VERSION}}, off_t size = ${GRASS_OFF_T_SIZE${GRASS_FIND_VERSION}})")
131150
ENDIF (NOT GRASS_FIND_QUIETLY)
132151

133152
ELSE (GRASS_FOUND${GRASS_FIND_VERSION})

python/core/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import inspect
22
import string
33
from qgis._core import *
4+
from PyQt4.QtCore import QCoreApplication
45

56

67
def register_function(function, arg_count, group, usesgeometry=False, **kwargs):
@@ -66,7 +67,10 @@ def func(self, values, feature, parent):
6667
register = kwargs.get('register', True)
6768
if register and QgsExpression.isFunctionName(name):
6869
if not QgsExpression.unregisterFunction(name):
69-
raise TypeError("Unable to unregister function")
70+
msgtitle = QCoreApplication.translate("UserExpressions", "User expressions")
71+
msg = QCoreApplication.translate("UserExpressions", "The user expression {0} already exists and could not be unregistered.").format(name)
72+
QgsMessageLog.logMessage(msg + "\n", msgtitle, QgsMessageLog.WARNING)
73+
return None
7074

7175
function.__name__ = name
7276
helptext = helptemplate.safe_substitute(name=name, doc=helptext)

python/core/conversions.sip

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1834,6 +1834,110 @@ template <TYPE>
18341834
%End
18351835
};
18361836

1837+
// QList<QgsField> is implemented as a Python list of QgsField.
1838+
%MappedType QList<QgsField> /DocType="list-of-qgsfield"/
1839+
{
1840+
%TypeHeaderCode
1841+
#include <qgsfield.h>
1842+
%End
1843+
1844+
%ConvertFromTypeCode
1845+
PyObject *l = PyList_New(sipCpp->size());
1846+
1847+
if (!l)
1848+
return 0;
1849+
1850+
for (int i = 0; i < sipCpp->size(); ++i)
1851+
{
1852+
QgsField *t = new QgsField(sipCpp->at(i));
1853+
PyObject *tobj = sipConvertFromNewType(t, sipType_QgsField, sipTransferObj);
1854+
1855+
if (!tobj)
1856+
{
1857+
delete t;
1858+
Py_DECREF(l);
1859+
1860+
return 0;
1861+
}
1862+
1863+
PyList_SET_ITEM(l, i, tobj);
1864+
}
1865+
1866+
return l;
1867+
%End
1868+
1869+
%ConvertToTypeCode
1870+
PyObject *iter = PyObject_GetIter(sipPy);
1871+
1872+
if (!sipIsErr)
1873+
{
1874+
Py_XDECREF(iter);
1875+
1876+
return (iter
1877+
#if PY_MAJOR_VERSION < 3
1878+
&& !PyString_Check(sipPy)
1879+
#endif
1880+
&& !PyUnicode_Check(sipPy));
1881+
}
1882+
1883+
if (!iter)
1884+
{
1885+
*sipIsErr = 1;
1886+
1887+
return 0;
1888+
}
1889+
1890+
QList<QgsField> *ql = new QList<QgsField>;
1891+
1892+
for (SIP_SSIZE_T i = 0; ; ++i)
1893+
{
1894+
PyErr_Clear();
1895+
PyObject *itm = PyIter_Next(iter);
1896+
1897+
if (!itm)
1898+
{
1899+
if (PyErr_Occurred())
1900+
{
1901+
delete ql;
1902+
Py_DECREF(iter);
1903+
*sipIsErr = 1;
1904+
1905+
return 0;
1906+
}
1907+
1908+
break;
1909+
}
1910+
1911+
int state;
1912+
QgsField *t = reinterpret_cast<QgsField *>( sipForceConvertToType(itm, sipType_QgsField, sipTransferObj, SIP_NOT_NONE, &state, sipIsErr));
1913+
1914+
if (*sipIsErr)
1915+
{
1916+
PyErr_Format(PyExc_TypeError,
1917+
"index %ld has type '%s' but 'QgsField' is expected",
1918+
(long) i, Py_TYPE(itm)->tp_name);
1919+
1920+
Py_DECREF(itm);
1921+
delete ql;
1922+
Py_DECREF(iter);
1923+
1924+
return 0;
1925+
}
1926+
1927+
ql->append(*t);
1928+
1929+
sipReleaseType(t, sipType_QgsField, state);
1930+
Py_DECREF(itm);
1931+
}
1932+
1933+
Py_DECREF(iter);
1934+
1935+
*sipCppPtr = ql;
1936+
1937+
return sipGetState(sipTransferObj);
1938+
%End
1939+
};
1940+
18371941
%If (QVECTORINT_CONVERSION)
18381942
// QVector<int> is implemented as a Python list of integers.
18391943
%MappedType QVector<int> /DocType="list-of-int"/

python/core/geometry/qgsabstractgeometryv2.sip

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,16 @@ class QgsAbstractGeometryV2
4949
sipClass = sipClass_QgsCurvePolygonV2;
5050
else if (dynamic_cast<QgsMultiPointV2*>(sipCpp) != NULL )
5151
sipClass = sipClass_QgsMultiPointV2;
52-
else if (dynamic_cast<QgsLineStringV2*>(sipCpp) != NULL )
53-
sipClass = sipClass_QgsLineStringV2;
52+
else if (dynamic_cast<QgsMultiLineStringV2*>(sipCpp) != NULL )
53+
sipClass = sipClass_QgsMultiLineStringV2;
5454
else if (dynamic_cast<QgsMultiPolygonV2*>(sipCpp) != NULL )
5555
sipClass = sipClass_QgsMultiPolygonV2;
5656
else if (dynamic_cast<QgsMultiSurfaceV2*>(sipCpp) != NULL )
5757
sipClass = sipClass_QgsMultiSurfaceV2;
5858
else if (dynamic_cast<QgsMultiCurveV2*>(sipCpp) != NULL )
5959
sipClass = sipClass_QgsMultiCurveV2;
60+
else if (dynamic_cast<QgsGeometryCollectionV2*>(sipCpp) != NULL )
61+
sipClass = sipClass_QgsGeometryCollectionV2;
6062
else
6163
sipClass = 0;
6264
%End
@@ -116,8 +118,22 @@ class QgsAbstractGeometryV2
116118
virtual bool moveVertex( const QgsVertexId& position, const QgsPointV2& newPos ) = 0;
117119
virtual bool deleteVertex( const QgsVertexId& position ) = 0;
118120

119-
/** Length for linear geometries,perimeter for area geometries*/
121+
/** Returns the length of the geometry.
122+
* @see area()
123+
* @see perimeter()
124+
*/
120125
virtual double length() const;
126+
127+
/** Returns the perimeter of the geometry.
128+
* @see area()
129+
* @see length()
130+
*/
131+
virtual double perimeter() const;
132+
133+
/** Returns the area of the geometry.
134+
* @see length()
135+
* @see perimeter()
136+
*/
121137
virtual double area() const;
122138

123139
/** Returns the centroid of the geometry*/

python/core/geometry/qgscurvepolygonv2.sip

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class QgsCurvePolygonV2: public QgsSurfaceV2
2929

3030
//surface interface
3131
virtual double area() const;
32-
virtual double length() const;
32+
virtual double perimeter() const;
3333
QgsPointV2 pointOnSurface() const;
3434
QgsPolygonV2* surfaceToPolygon() const;
3535

python/core/geometry/qgsgeometrycollectionv2.sip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class QgsGeometryCollectionV2: public QgsAbstractGeometryV2
5858

5959
virtual double length() const;
6060
virtual double area() const;
61+
virtual double perimeter() const;
6162

6263
bool hasCurvedSegments() const;
6364

python/core/qgsfield.sip

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,13 @@ class QgsFields
249249

250250
//! Get field at particular index (must be in range 0..N-1)
251251
// const QgsField& operator[]( int i ) const;
252-
QgsField& operator[](int i) /Factory/;
252+
QgsField& operator[](int i);
253253
%MethodCode
254254
SIP_SSIZE_T idx = sipConvertFromSequenceIndex(a0, sipCpp->count());
255255
if (idx < 0)
256256
sipIsErr = 1;
257257
else
258-
sipRes = new QgsField(sipCpp->operator[](idx));
258+
sipRes = &(*sipCpp)[idx];
259259
%End
260260

261261
//! Get field at particular index (must be in range 0..N-1)

python/user.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,5 @@ def func(value1, feature, parent):
6868
except ImportError:
6969
# We get a import error and crash for some reason even if we make the expressions package
7070
# TODO Fix the crash on first load with no expressions folder
71-
# But for now it's not the end of the world if it doesn't laod the first time
71+
# But for now it's not the end of the world if it doesn't load the first time
7272
pass

src/app/qgsattributetypedialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ QgsAttributeTypeDialog::~QgsAttributeTypeDialog()
8080
QSettings settings;
8181
settings.setValue( "/Windows/QgsAttributeTypeDialog/geometry", saveGeometry() );
8282

83-
qDeleteAll( mEditorConfigWidgets.values() );
83+
qDeleteAll( mEditorConfigWidgets );
8484
}
8585

8686
const QString QgsAttributeTypeDialog::editorWidgetV2Type()

src/auth/identcert/qgsauthidentcertmethod.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ QgsAuthIdentCertMethod::QgsAuthIdentCertMethod()
4848

4949
QgsAuthIdentCertMethod::~QgsAuthIdentCertMethod()
5050
{
51-
qDeleteAll( mPkiConfigBundleCache.values() );
51+
qDeleteAll( mPkiConfigBundleCache );
5252
mPkiConfigBundleCache.clear();
5353
}
5454

0 commit comments

Comments
 (0)