Skip to content
Permalink
Browse files
qgis server fixes:
* support edit types based on edit widgets (adds qgis_gui dependency; fixes #12091)
* show null values (fixes #12114)
* only quote non-numeric non-null values in feature info
* fix crash on exit
* remove obsolete parser method and debug output
  • Loading branch information
jef-n committed Feb 13, 2015
1 parent 3294505 commit 1e9774fdcf3fca2f9d1fa9165f874e7f450c34ff
@@ -47,9 +47,9 @@ QgsEditorWidgetRegistry* QgsEditorWidgetRegistry::instance()
return &sInstance;
}

void QgsEditorWidgetRegistry::initEditors( QgsMapCanvas* mapCanvas, QgsMessageBar* messageBar )
void QgsEditorWidgetRegistry::initEditors( QgsMapCanvas *mapCanvas, QgsMessageBar *messageBar )
{
QgsEditorWidgetRegistry* reg = instance();
QgsEditorWidgetRegistry *reg = instance();
reg->registerWidget( "Classification", new QgsClassificationWidgetWrapperFactory( tr( "Classification" ) ) );
reg->registerWidget( "Range", new QgsRangeWidgetFactory( tr( "Range" ) ) );
reg->registerWidget( "UniqueValues", new QgsUniqueValueWidgetFactory( tr( "Unique Values" ) ) );
@@ -88,7 +88,7 @@ ENDIF (WIN32)

QT4_WRAP_CPP(qgis_mapserv_MOC_SRCS ${qgis_mapserv_MOC_HDRS})

ADD_LIBRARY(qgis_server SHARED ${qgis_mapserv_SRCS} ${qgis_mapserv_MOC_SRCS} ${qgis_mapserv_HDRS} ${qgis_mapserv_MOC_HDRS} )
ADD_LIBRARY(qgis_server SHARED ${qgis_mapserv_SRCS} ${qgis_mapserv_MOC_SRCS} ${qgis_mapserv_HDRS} ${qgis_mapserv_MOC_HDRS})

#generate unversioned libs for android
IF (NOT ANDROID)
@@ -100,6 +100,7 @@ ENDIF (NOT ANDROID)

TARGET_LINK_LIBRARIES(qgis_server
qgis_core
qgis_gui
qgis_analysis
qgispython
${PROJ_LIBRARY}
@@ -155,13 +156,17 @@ INCLUDE_DIRECTORIES(
../core/symbology-ng
../core/composer
../core/layertree
../gui
../gui/editorwidgets
../gui/editorwidgets/core
../analysis/interpolation
../plugins/diagram_overlay
.
)

TARGET_LINK_LIBRARIES(qgis_mapserv.fcgi
qgis_core
qgis_gui
qgis_analysis
${PROJ_LIBRARY}
${FCGI_LIBRARY}
@@ -37,6 +37,7 @@
#include "qgsnetworkaccessmanager.h"
#include "qgsmaplayerregistry.h"
#include "qgsserverlogger.h"
#include "qgseditorwidgetregistry.h"

#ifdef HAVE_SERVER_PYTHON_PLUGINS
#include "qgsserverplugins.h"
@@ -287,8 +288,6 @@ int main( int argc, char * argv[] )
QgsDebugMsg( "User DB PATH: " + QgsApplication::qgisUserDbFilePath() );
QgsDebugMsg( "SVG PATHS: " + QgsApplication::svgPaths().join( ":" ) );

// FIXME: what is this debug line for?
QgsDebugMsg( qgsapp.applicationDirPath() + "/qgis_wms_server.log" );
QgsApplication::createDB(); //init qgis.db (e.g. necessary for user crs)

QString defaultConfigFilePath;
@@ -337,6 +336,8 @@ int main( int argc, char * argv[] )
QMultiMap<int, QgsServerFilter*> pluginFilters = serverIface.filters();
#endif

QgsEditorWidgetRegistry::initEditors();

while ( fcgi_accept() >= 0 )
{
QgsMapLayerRegistry::instance()->removeAllMapLayers();
@@ -27,8 +27,12 @@

QgsConfigCache* QgsConfigCache::instance()
{
static QgsConfigCache mInstance;
return &mInstance;
static QgsConfigCache *instance = 0;

if ( !instance )
instance = new QgsConfigCache();

return instance;
}

QgsConfigCache::QgsConfigCache()
@@ -44,7 +44,6 @@ class QgsConfigCache: public QObject

private:
QgsConfigCache();
static QgsConfigCache* mInstance;

/**Check for configuration file updates (remove entry from cache if file changes)*/
QFileSystemWatcher mFileSystemWatcher;
@@ -368,8 +368,8 @@ void QgsHttpRequestHandler::setGetFeatureInfoResponse( const QDomDocument& infoD
QDomElement attributeElement = attributeNodeList.at( k ).toElement();
if ( infoFormat == "text/plain" )
{
featureInfoString.append( attributeElement.attribute( "name" ) + " = '" +
attributeElement.attribute( "value" ) + "'\n" );
featureInfoString.append( attributeElement.attribute( "name" ) + " = " +
attributeElement.attribute( "value" ) + "\n" );
}
else if ( infoFormat == "text/html" )
{
@@ -24,6 +24,7 @@
#include "qgsmaplayerregistry.h"
#include "qgsmslayercache.h"
#include "qgsrasterlayer.h"
#include "qgseditorwidgetregistry.h"

#include <QDomDocument>
#include <QFileInfo>
@@ -241,6 +242,12 @@ QgsMapLayer* QgsServerProjectParser::createLayerFromElement( const QDomElement&

if ( layer )
{
if ( layer->type() == QgsMapLayer::VectorLayer )
{
// see QgsEditorWidgetRegistry::mapLayerAdded()
QObject::connect( layer, SIGNAL( readCustomSymbology( const QDomElement&, QString& ) ), QgsEditorWidgetRegistry::instance(), SLOT( readSymbology( const QDomElement&, QString& ) ) );
}

layer->readLayerXML( const_cast<QDomElement&>( elem ) ); //should be changed to const in QgsMapLayer
layer->setLayerName( layerName( elem ) );
if ( useCache )
@@ -919,50 +926,6 @@ QStringList QgsServerProjectParser::supportedOutputCrsList() const
return crsList;
}

//not very nice, needs to be kept in sync with QgsVectorLayer class...
QString QgsServerProjectParser::editTypeString( QgsVectorLayer::EditType type )
{
switch ( type )
{
case QgsVectorLayer::LineEdit:
return "LineEdit";
case QgsVectorLayer::UniqueValues:
return "UniqueValues";
case QgsVectorLayer::UniqueValuesEditable:
return "UniqueValuesEditable";
case QgsVectorLayer::ValueMap:
return "ValueMap";
case QgsVectorLayer::Classification:
return "Classification";
case QgsVectorLayer::EditRange:
return "EditRange";
case QgsVectorLayer::SliderRange:
return "SliderRange";
case QgsVectorLayer::CheckBox:
return "CheckBox";
case QgsVectorLayer::FileName:
return "FileName";
case QgsVectorLayer::Enumeration:
return "Enumeration";
case QgsVectorLayer::Immutable:
return "Immutable";
case QgsVectorLayer::Hidden:
return "Hidden";
case QgsVectorLayer::TextEdit:
return "TextEdit";
case QgsVectorLayer::Calendar:
return "Calendar";
case QgsVectorLayer::DialRange:
return "DialRange";
case QgsVectorLayer::ValueRelation:
return "ValueRelation";
case QgsVectorLayer::UuidGenerator:
return "UuidGenerator";
default:
return "Unknown";
}
}

QString QgsServerProjectParser::projectTitle() const
{
if ( !mXMLDoc )
@@ -70,8 +70,6 @@ class QgsServerProjectParser

QStringList supportedOutputCrsList() const;

static QString editTypeString( QgsVectorLayer::EditType type );

const QList<QDomElement>& projectLayerElements() const { return mProjectLayerElements; }

const QList<QDomElement>& legendGroupElements() const { return mLegendGroupElements; }
@@ -2094,7 +2094,26 @@ int QgsWMSServer::featureInfoFromVectorLayer( QgsVectorLayer* layer,

QDomElement attributeElement = infoDocument.createElement( "Attribute" );
attributeElement.setAttribute( "name", attributeName );
attributeElement.setAttribute( "value", replaceValueMapAndRelation( layer, i, QgsExpression::replaceExpressionText( featureAttributes[i].toString(), &feature, layer ) ) );

QString value;
if ( featureAttributes[i].isNull() )
value = QSettings().value( "qgis/nullValue", "NULL" ).toString();
else
{
value = replaceValueMapAndRelation( layer, i, QgsExpression::replaceExpressionText( featureAttributes[i].toString(), &feature, layer ) );

switch ( featureAttributes[i].type() )
{
case QVariant::Int:
case QVariant::LongLong:
case QVariant::Double:
break;
default:
value = "'" + value + "'";
}
}

attributeElement.setAttribute( "value", value );
featureElement.appendChild( attributeElement );
}

@@ -3054,42 +3073,43 @@ QString QgsWMSServer::replaceValueMapAndRelation( QgsVectorLayer* vl, int idx, c
QMap<QString, QVariant>::const_iterator vmapIt = cfg.constBegin();
for ( ; vmapIt != cfg.constEnd(); ++vmapIt )
{
if ( vmapIt.value().toString() == attributeVal )
if ( vmapIt.key() == attributeVal )
{
return vmapIt.key();
return vmapIt.value().toString();
}
}
return QString( "(%1)" ).arg( attributeVal );
}
else if ( type == "ValueRelation" )
{
QgsEditorWidgetConfig cfg( vl->editorWidgetV2Config( idx ) );
QgsVectorLayer* layer = qobject_cast<QgsVectorLayer*>( QgsMapLayerRegistry::instance()->mapLayer( cfg.value( "Layer" ).toString() ) );
if ( !layer )
{
return attributeVal;
return QString( "(%1)" ).arg( attributeVal );
}

QString outputString;
if ( cfg.value( "AllowMulti" ).toBool() )
QString valueString = attributeVal;
QStringList valueList = cfg.value( "AllowMulti" ).toBool()
? valueString.remove( QChar( '{' ) ).remove( QChar( '}' ) ).split( "," )
: QStringList( valueString );
for ( int i = 0; i < valueList.size(); ++i )
{
QString valueString = attributeVal;
QStringList valueList = valueString.remove( QChar( '{' ) ).remove( QChar( '}' ) ).split( "," );
for ( int i = 0; i < valueList.size(); ++i )
if ( i > 0 )
{
if ( i > 0 )
{
outputString += ";";
}
outputString += relationValue(
valueList.at( i ),
layer,
cfg.value( "Key" ).toString(),
cfg.value( "Value" ).toString()
);
outputString += ";";
}
outputString += relationValue(
valueList.at( i ),
layer,
cfg.value( "Key" ).toString(),
cfg.value( "Value" ).toString()
);
}
return outputString;
}

return attributeVal;
}

0 comments on commit 1e9774f

Please sign in to comment.