mirror of
https://github.com/qgis/QGIS.git
synced 2025-07-03 00:03:10 -04:00
Compare commits
4 Commits
a3a97a6648
...
18e38abd84
Author | SHA1 | Date | |
---|---|---|---|
|
18e38abd84 | ||
|
fdae3f318e | ||
|
b3afdad933 | ||
|
0293fe42e2 |
@ -542,6 +542,27 @@ bool QgsMeshLayer::isFaceActive( const QgsMeshDatasetIndex &index, int faceIndex
|
||||
return mDatasetGroupStore->isFaceActive( index, faceIndex );
|
||||
}
|
||||
|
||||
QgsMeshDatasetValue QgsMeshLayer::datasetValueUncached( const QgsRenderContext &renderContext, const QgsMeshDatasetIndex &index, const QgsPointXY &point, double searchRadius )
|
||||
{
|
||||
QGIS_PROTECT_QOBJECT_THREAD_ACCESS
|
||||
|
||||
QgsMeshDatasetValue value;
|
||||
const QgsTriangularMesh *mesh = triangularMesh();
|
||||
|
||||
if ( !mesh )
|
||||
{
|
||||
updateTriangularMesh( renderContext.coordinateTransform() );
|
||||
mesh = triangularMesh();
|
||||
}
|
||||
|
||||
if ( mesh && index.isValid() )
|
||||
{
|
||||
value = datasetValue( index, point, searchRadius );
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
QgsMeshDatasetValue QgsMeshLayer::datasetValue( const QgsMeshDatasetIndex &index, const QgsPointXY &point, double searchRadius ) const
|
||||
{
|
||||
QGIS_PROTECT_QOBJECT_THREAD_ACCESS
|
||||
|
@ -522,6 +522,7 @@ class CORE_EXPORT QgsMeshLayer : public QgsMapLayer, public QgsAbstractProfileSo
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
QgsMeshDatasetValue datasetValue( const QgsMeshDatasetIndex &index, const QgsPointXY &point, double searchRadius = 0 ) const;
|
||||
QgsMeshDatasetValue datasetValueUncached( const QgsRenderContext &renderContext, const QgsMeshDatasetIndex &index, const QgsPointXY &point, double searchRadius = 0 );
|
||||
|
||||
/**
|
||||
* Returns the 3d values of stacked 3d mesh defined by the given point
|
||||
|
@ -38,6 +38,8 @@
|
||||
#include "qgsrasteridentifyresult.h"
|
||||
#include "qgsrasterlayer.h"
|
||||
#include "qgsrasterrenderer.h"
|
||||
#include "qgsmeshlayer.h"
|
||||
#include "qgsmeshlayertemporalproperties.h"
|
||||
#include "qgsscalecalculator.h"
|
||||
#include "qgsmaplayertemporalproperties.h"
|
||||
#include "qgscoordinatereferencesystem.h"
|
||||
@ -1698,7 +1700,8 @@ namespace QgsWms
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if ( layer->type() == Qgis::LayerType::Raster )
|
||||
{
|
||||
QgsRasterLayer *rasterLayer = qobject_cast<QgsRasterLayer *>( layer );
|
||||
if ( !rasterLayer )
|
||||
@ -1719,10 +1722,16 @@ namespace QgsWms
|
||||
layerElement = result.createElement( QStringLiteral( "gml:featureMember" ) /*wfs:FeatureMember*/ );
|
||||
getFeatureInfoElement.appendChild( layerElement );
|
||||
}
|
||||
|
||||
( void ) featureInfoFromRasterLayer( rasterLayer, mapSettings, &layerInfoPoint, renderContext, result, layerElement, version );
|
||||
}
|
||||
break;
|
||||
|
||||
if ( layer->type() == Qgis::LayerType::Mesh )
|
||||
{
|
||||
QgsMeshLayer *meshLayer = qobject_cast<QgsMeshLayer *>( layer );
|
||||
QgsPointXY layerInfoPoint = mapSettings.mapToLayerCoordinates( layer, *( infoPoint.get() ) );
|
||||
( void ) featureInfoFromMeshLayer( meshLayer, mapSettings, &layerInfoPoint, renderContext, result, layerElement, version );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if ( !validLayer && !mContext.isValidLayer( queryLayer ) && !mContext.isValidGroup( queryLayer ) )
|
||||
@ -2165,6 +2174,141 @@ namespace QgsWms
|
||||
featureElem.appendChild( attributeElement );
|
||||
}
|
||||
|
||||
bool QgsRenderer::featureInfoFromMeshLayer( QgsMeshLayer *layer, const QgsMapSettings &mapSettings, const QgsPointXY *infoPoint, const QgsRenderContext &renderContext, QDomDocument &infoDocument, QDomElement &layerElement, const QString &version ) const
|
||||
{
|
||||
Q_UNUSED( version )
|
||||
Q_UNUSED( mapSettings )
|
||||
|
||||
if ( !infoPoint || !layer || !layer->dataProvider() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isTemporal = layer->temporalProperties()->isActive();
|
||||
QgsDateTimeRange range, layerRange;
|
||||
const QString dateFormat = QStringLiteral( "yyyy-MM-ddTHH:mm:ss" );
|
||||
|
||||
QList<QgsMeshDatasetIndex> datasetIndexList;
|
||||
int activeScalarGroup = layer->rendererSettings().activeScalarDatasetGroup();
|
||||
int activeVectorGroup = layer->rendererSettings().activeVectorDatasetGroup();
|
||||
|
||||
const QList<int> allGroup = layer->enabledDatasetGroupsIndexes();
|
||||
|
||||
if ( isTemporal )
|
||||
{
|
||||
range = renderContext.temporalRange();
|
||||
layerRange = static_cast<QgsMeshLayerTemporalProperties *>( layer->temporalProperties() )->timeExtent();
|
||||
|
||||
if ( activeScalarGroup >= 0 )
|
||||
{
|
||||
QgsMeshDatasetIndex indice;
|
||||
indice = layer->activeScalarDatasetAtTime( range );
|
||||
datasetIndexList.append( indice );
|
||||
}
|
||||
|
||||
if ( activeVectorGroup >= 0 && activeVectorGroup != activeScalarGroup )
|
||||
datasetIndexList.append( layer->activeVectorDatasetAtTime( range ) );
|
||||
|
||||
for ( int groupIndex : allGroup )
|
||||
{
|
||||
if ( groupIndex != activeScalarGroup && groupIndex != activeVectorGroup )
|
||||
datasetIndexList.append( layer->datasetIndexAtTime( range, groupIndex ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( activeScalarGroup >= 0 )
|
||||
datasetIndexList.append( layer->staticScalarDatasetIndex() );
|
||||
if ( activeVectorGroup >= 0 && activeVectorGroup != activeScalarGroup )
|
||||
datasetIndexList.append( layer->staticVectorDatasetIndex() );
|
||||
|
||||
for ( int groupIndex : allGroup )
|
||||
{
|
||||
if ( groupIndex != activeScalarGroup && groupIndex != activeVectorGroup )
|
||||
{
|
||||
if ( !layer->datasetGroupMetadata( groupIndex ).isTemporal() )
|
||||
datasetIndexList.append( groupIndex );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double searchRadius = Qgis::DEFAULT_SEARCH_RADIUS_MM * renderContext.scaleFactor() * renderContext.mapToPixel().mapUnitsPerPixel();
|
||||
|
||||
double scalarDoubleValue = 0.0;
|
||||
|
||||
for ( const QgsMeshDatasetIndex &index : datasetIndexList )
|
||||
{
|
||||
if ( !index.isValid() )
|
||||
continue;
|
||||
|
||||
const QgsMeshDatasetGroupMetadata &groupMeta = layer->datasetGroupMetadata( index );
|
||||
QMap<QString, QString> derivedAttributes;
|
||||
|
||||
QMap<QString, QString> attribute;
|
||||
|
||||
if ( groupMeta.isScalar() )
|
||||
{
|
||||
const QgsMeshDatasetValue scalarValue = layer->datasetValueUncached( renderContext, index, *infoPoint, searchRadius ); //
|
||||
scalarDoubleValue = scalarValue.scalar();
|
||||
attribute.insert( "Scalar Value", std::isnan( scalarDoubleValue ) ? "no data" : QLocale().toString( scalarDoubleValue ) );
|
||||
}
|
||||
|
||||
if ( groupMeta.isVector() )
|
||||
{
|
||||
const QgsMeshDatasetValue vectorValue = layer->datasetValueUncached( renderContext, index, *infoPoint, searchRadius ); //
|
||||
const double vectorX = vectorValue.x();
|
||||
const double vectorY = vectorValue.y();
|
||||
if ( std::isnan( vectorX ) || std::isnan( vectorY ) )
|
||||
{
|
||||
attribute.insert( "Vector Value", "no data" );
|
||||
}
|
||||
else
|
||||
{
|
||||
attribute.insert( "Vector Magnitude", QLocale().toString( vectorValue.scalar() ) );
|
||||
derivedAttributes.insert( "Vector x-component", QLocale().toString( vectorY ) );
|
||||
derivedAttributes.insert( "Vector y-component", QLocale().toString( vectorX ) );
|
||||
}
|
||||
}
|
||||
|
||||
const QgsMeshDatasetMetadata &meta = layer->datasetMetadata( index );
|
||||
|
||||
if ( groupMeta.isTemporal() )
|
||||
derivedAttributes.insert( "Time Step", layer->formatTime( meta.time() ) );
|
||||
derivedAttributes.insert( "Source", groupMeta.uri() );
|
||||
|
||||
QString resultName = groupMeta.name();
|
||||
|
||||
QDomElement attributeElement = infoDocument.createElement( QStringLiteral( "Attribute" ) );
|
||||
attributeElement.setAttribute( QStringLiteral( "name" ), resultName );
|
||||
|
||||
QString value;
|
||||
if ( !QgsVariantUtils::isNull( scalarDoubleValue ) )
|
||||
{
|
||||
value = QString::number( scalarDoubleValue );
|
||||
}
|
||||
|
||||
attributeElement.setAttribute( QStringLiteral( "value" ), value );
|
||||
layerElement.appendChild( attributeElement );
|
||||
|
||||
if ( isTemporal )
|
||||
{
|
||||
QDomElement attributeElementTime = infoDocument.createElement( QStringLiteral( "Attribute" ) );
|
||||
attributeElementTime.setAttribute( QStringLiteral( "name" ), "Time" );
|
||||
if ( range.isInstant() )
|
||||
{
|
||||
value = range.begin().toString( dateFormat );
|
||||
}
|
||||
else
|
||||
{
|
||||
value = range.begin().toString( dateFormat ) + '/' + range.end().toString( dateFormat );
|
||||
}
|
||||
attributeElementTime.setAttribute( QStringLiteral( "value" ), value );
|
||||
layerElement.appendChild( attributeElementTime );
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QgsRenderer::featureInfoFromRasterLayer( QgsRasterLayer *layer, const QgsMapSettings &mapSettings, const QgsPointXY *infoPoint, const QgsRenderContext &renderContext, QDomDocument &infoDocument, QDomElement &layerElement, const QString &version ) const
|
||||
{
|
||||
Q_UNUSED( version )
|
||||
@ -2821,7 +2965,8 @@ namespace QgsWms
|
||||
|
||||
QByteArray QgsRenderer::convertFeatureInfoToJson( const QList<QgsMapLayer *> &layers, const QDomDocument &doc, const QgsCoordinateReferenceSystem &destCRS ) const
|
||||
{
|
||||
json json {
|
||||
json json
|
||||
{
|
||||
{ "type", "FeatureCollection" },
|
||||
{ "features", json::array() },
|
||||
};
|
||||
@ -2971,7 +3116,8 @@ namespace QgsWms
|
||||
}
|
||||
|
||||
json["features"].push_back(
|
||||
{ { "type", "Feature" },
|
||||
{
|
||||
{ "type", "Feature" },
|
||||
{ "id", layerName.toStdString() },
|
||||
{ "properties", properties }
|
||||
}
|
||||
@ -3064,7 +3210,8 @@ namespace QgsWms
|
||||
|
||||
// find if an attribute is in any form tab
|
||||
std::function<bool( const QString &, const QgsAttributeEditorElement * )> findAttributeInTree;
|
||||
findAttributeInTree = [&findAttributeInTree, &layer]( const QString &attributeName, const QgsAttributeEditorElement *group ) -> bool {
|
||||
findAttributeInTree = [&findAttributeInTree, &layer]( const QString & attributeName, const QgsAttributeEditorElement * group ) -> bool
|
||||
{
|
||||
const QgsAttributeEditorContainer *container = dynamic_cast<const QgsAttributeEditorContainer *>( group );
|
||||
if ( container )
|
||||
{
|
||||
|
@ -40,6 +40,7 @@ class QgsMapRendererTask;
|
||||
class QgsMapSettings;
|
||||
class QgsPointXY;
|
||||
class QgsRasterLayer;
|
||||
class QgsMeshLayer;
|
||||
class QgsRectangle;
|
||||
class QgsRenderContext;
|
||||
class QgsVectorLayer;
|
||||
@ -278,6 +279,7 @@ namespace QgsWms
|
||||
void writeVectorLayerAttribute( int attributeIndex, QgsVectorLayer *layer, const QgsFields &fields, QgsAttributes &featureAttributes, QDomDocument &doc, QDomElement &featureElem, QgsRenderContext &renderContext, QStringList *attributes = nullptr ) const;
|
||||
|
||||
//! Appends feature info xml for the layer to the layer element of the dom document
|
||||
bool featureInfoFromMeshLayer( QgsMeshLayer *layer, const QgsMapSettings &mapSettings, const QgsPointXY *infoPoint, const QgsRenderContext &renderContext, QDomDocument &infoDocument, QDomElement &layerElement, const QString &version ) const;
|
||||
bool featureInfoFromRasterLayer( QgsRasterLayer *layer, const QgsMapSettings &mapSettings, const QgsPointXY *infoPoint, const QgsRenderContext &renderContext, QDomDocument &infoDocument, QDomElement &layerElement, const QString &version ) const;
|
||||
|
||||
//! Record which symbols would be used if the map was in the current configuration of renderer. This is useful for content-based legend
|
||||
|
Loading…
x
Reference in New Issue
Block a user