Skip to content
Permalink
Browse files
WMS identify feature support - get vector features from GML GetFeatur…
…eInfo
  • Loading branch information
blazek committed Feb 6, 2013
1 parent 1fe82b2 commit 50d4bb6d4d2a0c7548273d5567882519dc22790a
Showing with 2,217 additions and 356 deletions.
  1. +86 −1 python/core/conversions.sip
  2. +2 −0 python/core/core.sip
  3. +22 −0 python/core/qgsgml.sip
  4. +28 −0 python/core/qgsgmlschema.sip
  5. +5 −4 python/core/raster/qgsrasterdataprovider.sip
  6. +8 −6 python/gui/qgsmaptoolidentify.sip
  7. +7 −0 src/app/qgisapp.cpp
  8. +5 −0 src/app/qgisapp.h
  9. +17 −3 src/app/qgsclipboard.cpp
  10. +11 −0 src/app/qgsclipboard.h
  11. +284 −36 src/app/qgsidentifyresultsdialog.cpp
  12. +62 −15 src/app/qgsidentifyresultsdialog.h
  13. +29 −1 src/app/qgsmaptoolidentifyaction.cpp
  14. +11 −3 src/app/qgsmaptoolidentifyaction.h
  15. +8 −3 src/core/CMakeLists.txt
  16. +1 −2 src/core/qgsexpression.h
  17. +2 −0 src/core/qgsfeature.h
  18. +39 −0 src/core/qgsfeaturestore.cpp
  19. +80 −0 src/core/qgsfeaturestore.h
  20. +2 −0 src/core/qgsgeometry.h
  21. +85 −80 src/core/{qgswfsdata.cpp → qgsgml.cpp}
  22. +56 −37 src/core/{qgswfsdata.h → qgsgml.h}
  23. +531 −0 src/core/qgsgmlschema.cpp
  24. +206 −0 src/core/qgsgmlschema.h
  25. +19 −10 src/core/qgsnetworkreplyparser.cpp
  26. +9 −1 src/core/qgsnetworkreplyparser.h
  27. +60 −0 src/core/raster/qgsrasterdataprovider.cpp
  28. +18 −6 src/core/raster/qgsrasterdataprovider.h
  29. +21 −0 src/core/raster/qgsrasterlayer.cpp
  30. +184 −87 src/gui/qgsmaptoolidentify.cpp
  31. +25 −3 src/gui/qgsmaptoolidentify.h
  32. +10 −4 src/providers/wfs/qgswfsprovider.cpp
  33. +217 −39 src/providers/wms/qgswmsprovider.cpp
  34. +14 −2 src/providers/wms/qgswmsprovider.h
  35. +27 −10 src/providers/wms/qgswmssourceselect.cpp
  36. +4 −0 src/providers/wms/qgswmssourceselect.h
  37. +21 −2 src/ui/qgsidentifyresultsbase.ui
  38. +1 −1 tests/src/providers/testqgswcspublicservers.cpp
@@ -18,6 +18,7 @@ which are not wrapped by PyQt:
- QMap<qint64, QgsOverlayObject*>
- QList< QPair< QString, QList<QString> > >
- QVector<TYPE*>
- QMap<qint64, QgsFeature*>
*/

%Feature QSETINT_CONVERSION
@@ -1386,7 +1387,8 @@ template<double, TYPE2>
while (PyDict_Next(sipPy, &i, &t1obj, &t2obj))
{
int state;
int t1 = (int)(PyFloat_AsDouble(t1obj));
//int t1 = (int)(PyFloat_AsDouble(t1obj));
qint64 t1 = PyLong_AsLongLong(t1obj);
QgsOverlayObject* t2 = reinterpret_cast<QgsOverlayObject*>(sipConvertToInstance(t2obj, sipClass_QgsOverlayObject, sipTransferObj, SIP_NOT_NONE, &state, sipIsErr));

if (*sipIsErr)
@@ -1581,3 +1583,86 @@ template <TYPE>
return sipGetState(sipTransferObj);
%End
};

%MappedType QMap<qint64, QgsFeature*>
{
%TypeHeaderCode
#include <QMap>
#if (SIP_VERSION >= 0x040900)
#define sipClass_QString ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QString))
#endif
#if (SIP_VERSION >= 0x040900 && SIP_VERSION < 0x040c01)
#define sipClass_QVariant ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QVariant))
#endif
%End

%ConvertFromTypeCode

//convert map to a python dictionary
PyObject *d;

if ((d = PyDict_New()) == NULL)
return NULL;

for (QMap<qint64, QgsFeature*>::iterator it = sipCpp->begin(); it != sipCpp->end(); ++it)
{
QgsFeature* oobj = new QgsFeature(*it.value());

PyObject* keyobj = PyInt_FromLong(it.key());
PyObject* pyOobj = sipConvertFromInstance(oobj, sipClass_QgsFeature, sipTransferObj);
PyDict_SetItem(d, keyobj, pyOobj);

if(pyOobj == NULL || keyobj == NULL || PyDict_SetItem(d, keyobj, pyOobj) < 0)
{
Py_DECREF(d);

if (pyOobj)
{
Py_DECREF(pyOobj);
}

if (keyobj)
{
Py_DECREF(keyobj);
}
return NULL;
}
Py_DECREF(pyOobj);
Py_DECREF(keyobj);
}
return d;

%End
%ConvertToTypeCode
PyObject *t1obj, *t2obj;
#if PY_VERSION_HEX >= 0x02050000
Py_ssize_t i = 0;
#else
int i = 0;
#endif

QMap<qint64, QgsFeature*> *qm = new QMap<qint64, QgsFeature*>;

while (PyDict_Next(sipPy, &i, &t1obj, &t2obj))
{
int state;
qint64 t1 = PyLong_AsLongLong(t1obj);
QgsFeature* t2 = reinterpret_cast<QgsFeature*>(sipConvertToInstance(t2obj, sipClass_QgsFeature, sipTransferObj, SIP_NOT_NONE, &state, sipIsErr));

if (*sipIsErr)
{
sipReleaseInstance(t2, sipClass_QgsFeature, state);
delete qm;
return 0;
}

qm->insert(t1, t2);

sipReleaseInstance(t2, sipClass_QgsFeature, state);
}

*sipCppPtr = qm;

return sipGetState(sipTransferObj);
%End
};
@@ -31,6 +31,8 @@
%Include qgsfield.sip
%Include qgsgeometry.sip
%Include qgsgeometryvalidator.sip
%Include qgsgml.sip
%Include qgsgmlschema.sip
%Include qgshttptransaction.sip
%Include qgslabel.sip
%Include qgslabelattributes.sip
@@ -0,0 +1,22 @@
class QgsGml: QObject
{

%TypeHeaderCode
#include <qgsgml.h>
%End

public:

QgsGml(
const QString& typeName,
const QString& geometryAttribute,
const QgsFields & fields );

~QgsGml();

/** Read from GML data. */
int getFeatures( const QByteArray &data, QGis::WkbType* wkbType, QgsRectangle* extent = 0 );

QMap<qint64, QgsFeature* > featuresMap() const;

};
@@ -0,0 +1,28 @@
//typedef QMap<int, QgsField> QgsFieldMap;

class QgsGmlSchema: QObject
{

%TypeHeaderCode
#include <qgsgmlschema.h>
%End

public:
QgsGmlSchema();
~QgsGmlSchema();

/** Get fields info from XSD */
bool parseXSD( const QByteArray &xml );

/** Guess GML schema from data if XSD does not exist.
* Currently only recognizes UMN Mapserver GetFeatureInfo GML response.
* @param data GML data
* @return true in case of success */
bool guessSchema( const QByteArray &data );

QStringList typeNames() const;

QList<QgsField> fields( const QString & typeName );

QStringList geometryAttributes( const QString & typeName );
};
@@ -41,10 +41,11 @@ class QgsRasterDataProvider : QgsDataProvider, QgsRasterInterface

enum IdentifyFormat
{
IdentifyFormatValue,
IdentifyFormatText,
IdentifyFormatHtml,
IdentifyFormatFeature
IdentifyFormatUndefined = 0,
IdentifyFormatValue = 1,
IdentifyFormatText = 2,
IdentifyFormatHtml = 4,
IdentifyFormatFeature = 8
};

// Progress types
@@ -32,12 +32,14 @@ class QgsMapToolIdentify : QgsMapTool

struct RasterResult
{
RasterResult();
RasterResult( QgsRasterLayer* layer, QString label, QMap< QString, QString > attributes, QMap< QString, QString > derivedAttributes);
QgsRasterLayer* mLayer;
QString mLabel;
QMap< QString, QString > mAttributes;
QMap< QString, QString > mDerivedAttributes;
RasterResult();
RasterResult( QgsRasterLayer * layer, QString label, QgsFields fields, QgsFeature feature, QMap< QString, QString > derivedAttributes );
QgsRasterLayer* mLayer;
QString mLabel;
QgsFields mFields;
QgsFeature mFeature;
QMap< QString, QString > mAttributes;
QMap< QString, QString > mDerivedAttributes;
};

struct IdentifyResults
@@ -1863,6 +1863,8 @@ void QgisApp::createCanvasTools()
#endif
mMapTools.mIdentify = new QgsMapToolIdentifyAction( mMapCanvas );
mMapTools.mIdentify->setAction( mActionIdentify );
connect( mMapTools.mIdentify, SIGNAL( copyToClipboard( QgsFeatureStore & ) ),
this, SLOT( copyFeatures( QgsFeatureStore & ) ) );
mMapTools.mFeatureAction = new QgsMapToolFeatureAction( mMapCanvas );
mMapTools.mFeatureAction->setAction( mActionFeatureAction );
mMapTools.mMeasureDist = new QgsMeasureTool( mMapCanvas, false /* area */ );
@@ -5260,6 +5262,11 @@ void QgisApp::pasteTransformations()
}
#endif

void QgisApp::copyFeatures( QgsFeatureStore & featureStore )
{
clipboard()->replaceWithCopyOf( featureStore );
}

void QgisApp::refreshMapCanvas()
{
//clear all caches first
@@ -87,6 +87,7 @@ class QgsTileScaleWidget;

#include "qgsconfig.h"
#include "qgsfeature.h"
#include "qgsfeaturestore.h"
#include "qgspoint.h"
#include "qgsrasterlayer.h"
#include "qgssnappingdialog.h"
@@ -522,6 +523,10 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
(defaults to the active layer on the legend)
*/
void pasteStyle( QgsMapLayer * destinationLayer = 0 );

//! copies features to internal clipboard
void copyFeatures( QgsFeatureStore & featureStore );

void loadOGRSublayers( QString layertype, QString uri, QStringList list );
void loadGDALSublayers( QString uri, QStringList list );

@@ -47,17 +47,31 @@ void QgsClipboard::replaceWithCopyOf( QgsVectorLayer *src )
if ( !src )
return;

QSettings settings;
bool copyWKT = settings.value( "qgis/copyGeometryAsWKT", true ).toBool();

// Replace the QGis clipboard.
mFeatureFields = src->pendingFields();
mFeatureClipboard = src->selectedFeatures();
mCRS = src->crs();

QgsDebugMsg( "replaced QGis clipboard." );

setSystemClipboard();
}

void QgsClipboard::replaceWithCopyOf( QgsFeatureStore & featureStore )
{
QgsDebugMsg( QString( "features count = %1" ).arg( featureStore.features().size() ) );
mFeatureFields = featureStore.fields();
mFeatureClipboard = featureStore.features();
mCRS = featureStore.crs();
setSystemClipboard();
}

void QgsClipboard::setSystemClipboard()
{
// Replace the system clipboard.
QSettings settings;
bool copyWKT = settings.value( "qgis/copyGeometryAsWKT", true ).toBool();

QStringList textLines;
QStringList textFields;

@@ -23,6 +23,7 @@

#include "qgsfield.h"
#include "qgsfeature.h"
#include "qgsfeaturestore.h"
#include "qgscoordinatereferencesystem.h"

/**
@@ -65,6 +66,12 @@ class QgsClipboard
*/
void replaceWithCopyOf( QgsVectorLayer *src );

/*
* Place a copy of features on the internal clipboard,
* destroying the previous contents.
*/
void replaceWithCopyOf( QgsFeatureStore & featureStore );

/*
* Returns a copy of features on the internal clipboard,
* the caller assumes responsibility for destroying the contents
@@ -133,6 +140,10 @@ class QgsClipboard
const QgsFields &fields() { return mFeatureFields; }

private:
/*
* Set system clipboard from previously set features.
*/
void setSystemClipboard();

/** QGIS-internal vector feature clipboard.
Stored as values not pointers as each clipboard operation
Loading

0 comments on commit 50d4bb6

Please sign in to comment.