Skip to content
Permalink
Browse files

[FEATURE]: possibility to segmentize feature info geometry in server

  • Loading branch information
mhugent committed Aug 19, 2016
1 parent e30ff62 commit 24cc0e2febe76de1a11bb3db7edc24d3cbcac38f
@@ -53,6 +53,9 @@ class QgsWmsConfigParser
/** True if the feature info response should contain the wkt geometry for vector features*/
virtual bool featureInfoWithWktGeometry() const = 0;

/** True if the feature info wkt geometry is delivered with segmentized curve types*/
virtual bool segmentizeFeatureInfoWktGeometry() const = 0;

/** Returns map with layer aliases for GetFeatureInfo (or 0 pointer if not supported). Key: layer name, Value: layer alias*/
virtual QHash<QString, QString> featureInfoLayerAliasMap() const = 0;

@@ -83,6 +83,10 @@ class QgsWmsProjectParser : public QgsWmsConfigParser
/** True if the feature info response should contain the wkt geometry for vector features*/
bool featureInfoWithWktGeometry() const /*override*/ ;

/** True if the feature info wkt geometry is delivered with segmentized curve types*/
bool segmentizeFeatureInfoWktGeometry() const /*override*/ ;


/** Returns map with layer aliases for GetFeatureInfo (or 0 pointer if not supported). Key: layer name, Value: layer alias*/
QHash<QString, QString> featureInfoLayerAliasMap() const /*override*/ ;

@@ -528,6 +528,9 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
bool addWktGeometry = QgsProject::instance()->readBoolEntry( "WMSAddWktGeometry", "/" );
mAddWktGeometryCheckBox->setChecked( addWktGeometry );

bool segmentizeFeatureInfoGeometry = QgsProject::instance()->readBoolEntry( "WMSSegmentizeFeatureInfoGeometry", "/" );
mSegmentizeFeatureInfoGeometryCheckBox->setChecked( segmentizeFeatureInfoGeometry );

bool useLayerIDs = QgsProject::instance()->readBoolEntry( "WMSUseLayerIDs", "/" );
mWmsUseLayerIDs->setChecked( useLayerIDs );

@@ -1075,6 +1078,7 @@ void QgsProjectProperties::apply()
}

QgsProject::instance()->writeEntry( "WMSAddWktGeometry", "/", mAddWktGeometryCheckBox->isChecked() );
QgsProject::instance()->writeEntry( "WMSSegmentizeFeatureInfoGeometry", "/", mSegmentizeFeatureInfoGeometryCheckBox->isChecked() );
QgsProject::instance()->writeEntry( "WMSUseLayerIDs", "/", mWmsUseLayerIDs->isChecked() );

QString maxWidthText = mMaxWidthLineEdit->text();
@@ -512,6 +512,15 @@ bool QgsSLDConfigParser::featureInfoWithWktGeometry() const
return false;
}

bool QgsSLDConfigParser::segmentizeFeatureInfoWktGeometry() const
{
if ( mFallbackParser )
{
return mFallbackParser->segmentizeFeatureInfoWktGeometry();
}
return false;
}


QHash<QString, QString> QgsSLDConfigParser::featureInfoLayerAliasMap() const
{
@@ -64,6 +64,9 @@ class QgsSLDConfigParser : public QgsWmsConfigParser
/** True if the feature info response should contain the wkt geometry for vector features*/
bool featureInfoWithWktGeometry() const override;

/** True if the feature info wkt geometry is delivered with segmentized curve types*/
bool segmentizeFeatureInfoWktGeometry() const override;

/** Returns map with layer aliases for GetFeatureInfo (or 0 pointer if not supported). Key: layer name, Value: layer alias*/
QHash<QString, QString> featureInfoLayerAliasMap() const override;

@@ -64,6 +64,9 @@ class SERVER_EXPORT QgsWmsConfigParser
/** True if the feature info response should contain the wkt geometry for vector features*/
virtual bool featureInfoWithWktGeometry() const = 0;

/** True if the feature info wkt geometry is delivered with segmentized curve types*/
virtual bool segmentizeFeatureInfoWktGeometry() const = 0;

/** Returns map with layer aliases for GetFeatureInfo (or 0 pointer if not supported). Key: layer name, Value: layer alias*/
virtual QHash<QString, QString> featureInfoLayerAliasMap() const = 0;

@@ -2012,6 +2012,28 @@ bool QgsWmsProjectParser::featureInfoWithWktGeometry() const
return ( wktElem.text().compare( "true", Qt::CaseInsensitive ) == 0 );
}

bool QgsWmsProjectParser::segmentizeFeatureInfoWktGeometry() const
{
if ( !mProjectParser->xmlDocument() )
{
return false;
}

QDomElement propertiesElem = mProjectParser->propertiesElem();
if ( propertiesElem.isNull() )
{
return false;
}

QDomElement segmentizeElem = propertiesElem.firstChildElement( "WMSSegmentizeFeatureInfoGeometry" );
if ( segmentizeElem.isNull() )
{
return false;
}

return( segmentizeElem.text().compare( "true", Qt::CaseInsensitive ) == 0 );
}

QHash<QString, QString> QgsWmsProjectParser::featureInfoLayerAliasMap() const
{
QHash<QString, QString> aliasMap;
@@ -100,6 +100,9 @@ class SERVER_EXPORT QgsWmsProjectParser : public QgsWmsConfigParser
/** True if the feature info response should contain the wkt geometry for vector features*/
bool featureInfoWithWktGeometry() const override;

/** True if the feature info wkt geometry is delivered with segmentized curve types*/
bool segmentizeFeatureInfoWktGeometry() const override;

/** Returns map with layer aliases for GetFeatureInfo (or 0 pointer if not supported). Key: layer name, Value: layer alias*/
QHash<QString, QString> featureInfoLayerAliasMap() const override;

@@ -2194,6 +2194,7 @@ int QgsWmsServer::featureInfoFromVectorLayer( QgsVectorLayer* layer,
layer->updateFields();
const QgsFields& fields = layer->pendingFields();
bool addWktGeometry = mConfigParser && mConfigParser->featureInfoWithWktGeometry();
bool segmentizeWktGeometry = mConfigParser && mConfigParser->segmentizeFeatureInfoWktGeometry();
const QSet<QString>& excludedAttributes = layer->excludeAttributesWms();

QgsFeatureRequest fReq;
@@ -2365,6 +2366,19 @@ int QgsWmsServer::featureInfoFromVectorLayer( QgsVectorLayer* layer,
if ( transform.isValid() )
geom.transform( transform );
}

if ( segmentizeWktGeometry )
{
QgsAbstractGeometry* abstractGeom = geom.geometry();
if ( abstractGeom )
{
if ( QgsWkbTypes::isCurvedType( abstractGeom->wkbType() ) )
{
QgsAbstractGeometry* segmentizedGeom = abstractGeom-> segmentize();
geom.setGeometry( segmentizedGeom );
}
}
}
QDomElement geometryElement = infoDocument.createElement( "Attribute" );
geometryElement.setAttribute( "name", "geometry" );
geometryElement.setAttribute( "value", geom.exportToWkt( getWMSPrecision( 8 ) ) );

0 comments on commit 24cc0e2

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