Skip to content
Permalink
Browse files

Merge branch 'master' into MultiColumnPK_DbManagerQuery

  • Loading branch information
SebDieBln committed Oct 18, 2015
2 parents d8deb8c + cc9c789 commit 974e60c36ee39ca90d1fba32ec858f118772eb7b
@@ -62,6 +62,25 @@ MACRO (CHECK_GRASS G_PREFIX)

# LIB_PATH is only temporary variable, so hide it (is it possible to delete a variable?)
UNSET(LIB_PATH CACHE)

# Find off_t size
IF( (GRASS_MAJOR_VERSION${GRASS_FIND_VERSION} EQUAL 7) AND (GRASS_MINOR_VERSION${GRASS_FIND_VERSION} GREATER 0) )
SET(GRASS_TEST_MAPSET ${CMAKE_BINARY_DIR}/grass-location/PERMANENT)
FILE(MAKE_DIRECTORY ${GRASS_TEST_MAPSET})
FILE(WRITE ${GRASS_TEST_MAPSET}/DEFAULT_WIND "")
FILE(WRITE ${GRASS_TEST_MAPSET}/WIND "")
# grass command is not in G_PREFIX but in some bin dir, so it must be in PATH
SET(GRASS_EXE grass7${GRASS_MINOR_VERSION${GRASS_FIND_VERSION}})
#MESSAGE(STATUS "GRASS_EXE = ${GRASS_EXE}")
EXECUTE_PROCESS(COMMAND ${GRASS_EXE} ${GRASS_TEST_MAPSET} --exec g.version -g
COMMAND grep build_off_t_size
COMMAND sed "s/.*\\([0-9]\\).*/\\1/"
ERROR_VARIABLE GRASS_TMP_ERROR
OUTPUT_VARIABLE GRASS_OFF_T_SIZE${GRASS_FIND_VERSION}
)
STRING(STRIP ${GRASS_OFF_T_SIZE${GRASS_FIND_VERSION}} GRASS_OFF_T_SIZE${GRASS_FIND_VERSION})
#MESSAGE(STATUS "GRASS_OFF_T_SIZE${GRASS_FIND_VERSION} = ${GRASS_OFF_T_SIZE${GRASS_FIND_VERSION}}")
ENDIF( (GRASS_MAJOR_VERSION${GRASS_FIND_VERSION} EQUAL 7) AND (GRASS_MINOR_VERSION${GRASS_FIND_VERSION} GREATER 0) )

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

IF (GRASS_FOUND${GRASS_FIND_VERSION})
IF (NOT GRASS_FIND_QUIETLY)
MESSAGE(STATUS "Found GRASS ${GRASS_FIND_VERSION}: ${GRASS_PREFIX${GRASS_CACHE_VERSION}} (${GRASS_VERSION${GRASS_FIND_VERSION}})")
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}})")
ENDIF (NOT GRASS_FIND_QUIETLY)

ELSE (GRASS_FOUND${GRASS_FIND_VERSION})
@@ -1,6 +1,7 @@
import inspect
import string
from qgis._core import *
from PyQt4.QtCore import QCoreApplication


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

function.__name__ = name
helptext = helptemplate.safe_substitute(name=name, doc=helptext)
@@ -1834,6 +1834,110 @@ template <TYPE>
%End
};

// QList<QgsField> is implemented as a Python list of QgsField.
%MappedType QList<QgsField> /DocType="list-of-qgsfield"/
{
%TypeHeaderCode
#include <qgsfield.h>
%End

%ConvertFromTypeCode
PyObject *l = PyList_New(sipCpp->size());

if (!l)
return 0;

for (int i = 0; i < sipCpp->size(); ++i)
{
QgsField *t = new QgsField(sipCpp->at(i));
PyObject *tobj = sipConvertFromNewType(t, sipType_QgsField, sipTransferObj);

if (!tobj)
{
delete t;
Py_DECREF(l);

return 0;
}

PyList_SET_ITEM(l, i, tobj);
}

return l;
%End

%ConvertToTypeCode
PyObject *iter = PyObject_GetIter(sipPy);

if (!sipIsErr)
{
Py_XDECREF(iter);

return (iter
#if PY_MAJOR_VERSION < 3
&& !PyString_Check(sipPy)
#endif
&& !PyUnicode_Check(sipPy));
}

if (!iter)
{
*sipIsErr = 1;

return 0;
}

QList<QgsField> *ql = new QList<QgsField>;

for (SIP_SSIZE_T i = 0; ; ++i)
{
PyErr_Clear();
PyObject *itm = PyIter_Next(iter);

if (!itm)
{
if (PyErr_Occurred())
{
delete ql;
Py_DECREF(iter);
*sipIsErr = 1;

return 0;
}

break;
}

int state;
QgsField *t = reinterpret_cast<QgsField *>( sipForceConvertToType(itm, sipType_QgsField, sipTransferObj, SIP_NOT_NONE, &state, sipIsErr));

if (*sipIsErr)
{
PyErr_Format(PyExc_TypeError,
"index %ld has type '%s' but 'QgsField' is expected",
(long) i, Py_TYPE(itm)->tp_name);

Py_DECREF(itm);
delete ql;
Py_DECREF(iter);

return 0;
}

ql->append(*t);

sipReleaseType(t, sipType_QgsField, state);
Py_DECREF(itm);
}

Py_DECREF(iter);

*sipCppPtr = ql;

return sipGetState(sipTransferObj);
%End
};

%If (QVECTORINT_CONVERSION)
// QVector<int> is implemented as a Python list of integers.
%MappedType QVector<int> /DocType="list-of-int"/
@@ -49,14 +49,16 @@ class QgsAbstractGeometryV2
sipClass = sipClass_QgsCurvePolygonV2;
else if (dynamic_cast<QgsMultiPointV2*>(sipCpp) != NULL )
sipClass = sipClass_QgsMultiPointV2;
else if (dynamic_cast<QgsLineStringV2*>(sipCpp) != NULL )
sipClass = sipClass_QgsLineStringV2;
else if (dynamic_cast<QgsMultiLineStringV2*>(sipCpp) != NULL )
sipClass = sipClass_QgsMultiLineStringV2;
else if (dynamic_cast<QgsMultiPolygonV2*>(sipCpp) != NULL )
sipClass = sipClass_QgsMultiPolygonV2;
else if (dynamic_cast<QgsMultiSurfaceV2*>(sipCpp) != NULL )
sipClass = sipClass_QgsMultiSurfaceV2;
else if (dynamic_cast<QgsMultiCurveV2*>(sipCpp) != NULL )
sipClass = sipClass_QgsMultiCurveV2;
else if (dynamic_cast<QgsGeometryCollectionV2*>(sipCpp) != NULL )
sipClass = sipClass_QgsGeometryCollectionV2;
else
sipClass = 0;
%End
@@ -116,8 +118,22 @@ class QgsAbstractGeometryV2
virtual bool moveVertex( const QgsVertexId& position, const QgsPointV2& newPos ) = 0;
virtual bool deleteVertex( const QgsVertexId& position ) = 0;

/** Length for linear geometries,perimeter for area geometries*/
/** Returns the length of the geometry.
* @see area()
* @see perimeter()
*/
virtual double length() const;

/** Returns the perimeter of the geometry.
* @see area()
* @see length()
*/
virtual double perimeter() const;

/** Returns the area of the geometry.
* @see length()
* @see perimeter()
*/
virtual double area() const;

/** Returns the centroid of the geometry*/
@@ -29,7 +29,7 @@ class QgsCurvePolygonV2: public QgsSurfaceV2

//surface interface
virtual double area() const;
virtual double length() const;
virtual double perimeter() const;
QgsPointV2 pointOnSurface() const;
QgsPolygonV2* surfaceToPolygon() const;

@@ -58,6 +58,7 @@ class QgsGeometryCollectionV2: public QgsAbstractGeometryV2

virtual double length() const;
virtual double area() const;
virtual double perimeter() const;

bool hasCurvedSegments() const;

@@ -249,13 +249,13 @@ class QgsFields

//! Get field at particular index (must be in range 0..N-1)
// const QgsField& operator[]( int i ) const;
QgsField& operator[](int i) /Factory/;
QgsField& operator[](int i);
%MethodCode
SIP_SSIZE_T idx = sipConvertFromSequenceIndex(a0, sipCpp->count());
if (idx < 0)
sipIsErr = 1;
else
sipRes = new QgsField(sipCpp->operator[](idx));
sipRes = &(*sipCpp)[idx];
%End

//! Get field at particular index (must be in range 0..N-1)
@@ -68,5 +68,5 @@ def func(value1, feature, parent):
except ImportError:
# We get a import error and crash for some reason even if we make the expressions package
# TODO Fix the crash on first load with no expressions folder
# But for now it's not the end of the world if it doesn't laod the first time
# But for now it's not the end of the world if it doesn't load the first time
pass
@@ -80,7 +80,7 @@ QgsAttributeTypeDialog::~QgsAttributeTypeDialog()
QSettings settings;
settings.setValue( "/Windows/QgsAttributeTypeDialog/geometry", saveGeometry() );

qDeleteAll( mEditorConfigWidgets.values() );
qDeleteAll( mEditorConfigWidgets );
}

const QString QgsAttributeTypeDialog::editorWidgetV2Type()
@@ -48,7 +48,7 @@ QgsAuthIdentCertMethod::QgsAuthIdentCertMethod()

QgsAuthIdentCertMethod::~QgsAuthIdentCertMethod()
{
qDeleteAll( mPkiConfigBundleCache.values() );
qDeleteAll( mPkiConfigBundleCache );
mPkiConfigBundleCache.clear();
}

@@ -48,7 +48,7 @@ QgsAuthPkiPathsMethod::QgsAuthPkiPathsMethod()

QgsAuthPkiPathsMethod::~QgsAuthPkiPathsMethod()
{
qDeleteAll( mPkiConfigBundleCache.values() );
qDeleteAll( mPkiConfigBundleCache );
mPkiConfigBundleCache.clear();
}

@@ -48,7 +48,7 @@ QgsAuthPkcs12Method::QgsAuthPkcs12Method()

QgsAuthPkcs12Method::~QgsAuthPkcs12Method()
{
qDeleteAll( mPkiConfigBundleCache.values() );
qDeleteAll( mPkiConfigBundleCache );
mPkiConfigBundleCache.clear();
}

@@ -746,7 +746,7 @@ bool QgsAuthManager::registerCoreAuthMethods()
if ( isDisabled() )
return false;

qDeleteAll( mAuthMethods.values() );
qDeleteAll( mAuthMethods );
mAuthMethods.clear();
Q_FOREACH ( const QString& authMethodKey, QgsAuthMethodRegistry::instance()->authMethodList() )
{
@@ -2819,7 +2819,7 @@ QgsAuthManager::~QgsAuthManager()
if ( !isDisabled() )
{
delete QgsAuthMethodRegistry::instance();
qDeleteAll( mAuthMethods.values() );
qDeleteAll( mAuthMethods );

QSqlDatabase authConn = authDbConnection();
if ( authConn.isValid() && authConn.isOpen() )
@@ -259,13 +259,21 @@ class CORE_EXPORT QgsAbstractGeometryV2
*/
virtual bool deleteVertex( const QgsVertexId& position ) = 0;

/** Returns the length (or perimeter for area geometries) of the geometry.
* @see area
/** Returns the length of the geometry.
* @see area()
* @see perimeter()
*/
virtual double length() const { return 0.0; }

/** Returns the perimeter of the geometry.
* @see area()
* @see length()
*/
virtual double perimeter() const { return 0.0; }

/** Returns the area of the geometry.
* @see length
* @see length()
* @see perimeter()
*/
virtual double area() const { return 0.0; }

@@ -336,16 +336,16 @@ double QgsCurvePolygonV2::area() const
return area;
}

double QgsCurvePolygonV2::length() const
double QgsCurvePolygonV2::perimeter() const
{
//sum perimeter of rings
double length = mExteriorRing->length();
double perimeter = mExteriorRing->length();
QList<QgsCurveV2*>::const_iterator ringIt = mInteriorRings.constBegin();
for ( ; ringIt != mInteriorRings.constEnd(); ++ringIt )
{
length += ( *ringIt )->length();
perimeter += ( *ringIt )->length();
}
return length;
return perimeter;
}

QgsPointV2 QgsCurvePolygonV2::pointOnSurface() const
@@ -55,7 +55,7 @@ class CORE_EXPORT QgsCurvePolygonV2: public QgsSurfaceV2

//surface interface
virtual double area() const override;
virtual double length() const override;
virtual double perimeter() const override;
QgsPointV2 pointOnSurface() const override;
QgsPolygonV2* surfaceToPolygon() const override;

@@ -454,6 +454,17 @@ double QgsGeometryCollectionV2::area() const
return area;
}

double QgsGeometryCollectionV2::perimeter() const
{
double perimeter = 0.0;
QVector< QgsAbstractGeometryV2* >::const_iterator geomIt = mGeometries.constBegin();
for ( ; geomIt != mGeometries.constEnd(); ++geomIt )
{
perimeter += ( *geomIt )->perimeter();
}
return perimeter;
}

bool QgsGeometryCollectionV2::fromCollectionWkt( const QString &wkt, const QList<QgsAbstractGeometryV2*>& subtypes, const QString& defaultChildWkbType )
{
clear();
@@ -103,6 +103,7 @@ class CORE_EXPORT QgsGeometryCollectionV2: public QgsAbstractGeometryV2

virtual double length() const override;
virtual double area() const override;
virtual double perimeter() const override;

bool hasCurvedSegments() const override;

@@ -384,7 +384,7 @@ double QgsDistanceArea::measurePerimeter( const QgsGeometry* geometry ) const

if ( !mEllipsoidalMode || mEllipsoid == GEO_NONE )
{
return geomV2->length();
return geomV2->perimeter();
}

//create list with (single) surfaces

0 comments on commit 974e60c

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