20#include <QRegularExpression>
39 mConstraints << constraint;
99 layer->
setCustomProperty( QStringLiteral(
"metadata/extent" ), QVariant::fromValue( mExtent ) );
107 layer->
setCustomProperty( QStringLiteral(
"metadata/constraints" ), QVariant::fromValue( mConstraints ) );
121 mFees = layer->
customProperty( QStringLiteral(
"metadata/fees" ) ).toString();
122 mRights = layer->
customProperty( QStringLiteral(
"metadata/rights" ) ).toStringList();
123 mLicenses = layer->
customProperty( QStringLiteral(
"metadata/licenses" ) ).toStringList();
125 mEncoding = layer->
customProperty( QStringLiteral(
"metadata/encoding" ) ).toString();
126 const QString crsAuthId = layer->
customProperty( QStringLiteral(
"metadata/crs" ) ).toString();
129 mConstraints = layer->
customProperty( QStringLiteral(
"metadata/constraints" ) ).value<ConstraintList>();
130 mKeywords = layer->
customProperty( QStringLiteral(
"metadata/keywords" ) ).value<QgsAbstractMetadataBase::KeywordMap>();
131 mContacts = layer->
customProperty( QStringLiteral(
"metadata/contacts" ) ).value<QgsAbstractMetadataBase::ContactList>();
132 mLinks = layer->
customProperty( QStringLiteral(
"metadata/links" ) ).value<QgsAbstractMetadataBase::LinkList>();
143 mnl = metadataElement.namedItem( QStringLiteral(
"fees" ) );
144 mFees = mnl.toElement().text();
147 const QDomNodeList constraintsList = metadataElement.elementsByTagName( QStringLiteral(
"constraints" ) );
148 mConstraints.clear();
149 for (
int i = 0; i < constraintsList.size(); i++ )
151 mnl = constraintsList.at( i );
152 mne = mnl.toElement();
157 const QDomNodeList rightsNodeList = metadataElement.elementsByTagName( QStringLiteral(
"rights" ) );
158 QStringList rightsList;
159 for (
int i = 0; i < rightsNodeList.size(); i++ )
161 mnl = rightsNodeList.at( i );
162 mne = mnl.toElement();
163 rightsList.append( mne.text() );
168 const QDomNodeList licensesNodeList = metadataElement.elementsByTagName( QStringLiteral(
"license" ) );
169 QStringList licensesList;
170 for (
int i = 0; i < licensesNodeList.size(); i++ )
172 mnl = licensesNodeList.at( i );
173 mne = mnl.toElement();
174 licensesList.append( mne.text() );
179 mnl = metadataElement.namedItem( QStringLiteral(
"encoding" ) );
180 mEncoding = mnl.toElement().text();
183 mnl = metadataElement.namedItem( QStringLiteral(
"crs" ) );
188 mnl = metadataElement.namedItem( QStringLiteral(
"extent" ) );
192 const QDomNodeList spatialList = mnl.toElement().elementsByTagName( QStringLiteral(
"spatial" ) );
193 QList< QgsLayerMetadata::SpatialExtent > metadataSpatialExtents;
194 for (
int i = 0; i < spatialList.size(); i++ )
196 mnl = spatialList.at( i );
197 mne = mnl.toElement();
207 metadataSpatialExtents.append( se );
212 mnl = metadataElement.namedItem( QStringLiteral(
"extent" ) );
213 const QDomNodeList temporalList = mnl.toElement().elementsByTagName( QStringLiteral(
"temporal" ) );
214 QList<QgsDateTimeRange> metadataDates;
215 for (
int j = 0; j < temporalList.size(); j++ )
217 mnl = temporalList.at( j );
218 const QDomNodeList instantList = mnl.toElement().elementsByTagName( QStringLiteral(
"instant" ) );
219 for (
int i = 0; i < instantList.size(); i++ )
221 mnl = instantList.at( i );
222 const QDateTime d = QDateTime::fromString( mnl.toElement().text(), Qt::ISODate );
223 const QgsDateTimeRange date = QgsDateTimeRange( d, d );
224 metadataDates << date;
226 const QDomNodeList periodList = mnl.toElement().elementsByTagName( QStringLiteral(
"period" ) );
227 for (
int i = 0; i < periodList.size(); i++ )
229 const QDomNode begin = periodList.at( i ).namedItem( QStringLiteral(
"start" ) );
230 const QDomNode end = periodList.at( i ).namedItem( QStringLiteral(
"end" ) );
231 const QDateTime beginDate = QDateTime::fromString( begin.toElement().text(), Qt::ISODate );
232 const QDateTime endDate = QDateTime::fromString( end.toElement().text(), Qt::ISODate );
233 const QgsDateTimeRange date = QgsDateTimeRange( beginDate, endDate );
234 metadataDates << date;
248 QDomElement
fees = document.createElement( QStringLiteral(
"fees" ) );
249 const QDomText feesText = document.createTextNode( mFees );
250 fees.appendChild( feesText );
251 metadataElement.appendChild(
fees );
256 QDomElement constraintElement = document.createElement( QStringLiteral(
"constraints" ) );
257 constraintElement.setAttribute( QStringLiteral(
"type" ), constraint.type );
258 const QDomText constraintText = document.createTextNode( constraint.constraint );
259 constraintElement.appendChild( constraintText );
260 metadataElement.appendChild( constraintElement );
264 for (
const QString &right : mRights )
266 QDomElement rightElement = document.createElement( QStringLiteral(
"rights" ) );
267 const QDomText rightText = document.createTextNode( right );
268 rightElement.appendChild( rightText );
269 metadataElement.appendChild( rightElement );
273 for (
const QString &license : mLicenses )
275 QDomElement licenseElement = document.createElement( QStringLiteral(
"license" ) );
276 const QDomText licenseText = document.createTextNode( license );
277 licenseElement.appendChild( licenseText );
278 metadataElement.appendChild( licenseElement );
282 QDomElement
encoding = document.createElement( QStringLiteral(
"encoding" ) );
283 const QDomText encodingText = document.createTextNode( mEncoding );
284 encoding.appendChild( encodingText );
285 metadataElement.appendChild(
encoding );
288 QDomElement crsElement = document.createElement( QStringLiteral(
"crs" ) );
289 mCrs.
writeXml( crsElement, document );
290 metadataElement.appendChild( crsElement );
293 QDomElement extentElement = document.createElement( QStringLiteral(
"extent" ) );
299 QDomElement spatialElement = document.createElement( QStringLiteral(
"spatial" ) );
301 spatialElement.setAttribute( QStringLiteral(
"dimensions" ), QStringLiteral(
"2" ) );
302 spatialElement.setAttribute( QStringLiteral(
"crs" ), spatialExtent.extentCrs.authid() );
303 spatialElement.setAttribute( QStringLiteral(
"minx" ),
qgsDoubleToString( spatialExtent.bounds.xMinimum() ) );
304 spatialElement.setAttribute( QStringLiteral(
"miny" ),
qgsDoubleToString( spatialExtent.bounds.yMinimum() ) );
305 spatialElement.setAttribute( QStringLiteral(
"minz" ),
qgsDoubleToString( spatialExtent.bounds.zMinimum() ) );
306 spatialElement.setAttribute( QStringLiteral(
"maxx" ),
qgsDoubleToString( spatialExtent.bounds.xMaximum() ) );
307 spatialElement.setAttribute( QStringLiteral(
"maxy" ),
qgsDoubleToString( spatialExtent.bounds.yMaximum() ) );
308 spatialElement.setAttribute( QStringLiteral(
"maxz" ),
qgsDoubleToString( spatialExtent.bounds.zMaximum() ) );
309 extentElement.appendChild( spatialElement );
314 for (
const QgsDateTimeRange &temporalExtent : tExtents )
316 QDomElement temporalElement = document.createElement( QStringLiteral(
"temporal" ) );
317 if ( temporalExtent.isInstant() )
319 QDomElement instantElement = document.createElement( QStringLiteral(
"instant" ) );
320 const QDomText instantText = document.createTextNode( temporalExtent.begin().toTimeSpec( Qt::OffsetFromUTC ).toString( Qt::ISODate ) );
321 instantElement.appendChild( instantText );
322 temporalElement.appendChild( instantElement );
326 QDomElement periodElement = document.createElement( QStringLiteral(
"period" ) );
327 QDomElement startElement = document.createElement( QStringLiteral(
"start" ) );
328 QDomElement endElement = document.createElement( QStringLiteral(
"end" ) );
329 const QDomText startText = document.createTextNode( temporalExtent.begin().toTimeSpec( Qt::OffsetFromUTC ).toString( Qt::ISODate ) );
330 const QDomText endText = document.createTextNode( temporalExtent.end().toTimeSpec( Qt::OffsetFromUTC ).toString( Qt::ISODate ) );
331 startElement.appendChild( startText );
332 endElement.appendChild( endText );
333 periodElement.appendChild( startElement );
334 periodElement.appendChild( endElement );
335 temporalElement.appendChild( periodElement );
337 extentElement.appendChild( temporalElement );
340 metadataElement.appendChild( extentElement );
351 if ( !otherLayerMetadata->fees().isEmpty() )
352 mFees = otherLayerMetadata->fees();
354 if ( !otherLayerMetadata->constraints().isEmpty() )
355 mConstraints = otherLayerMetadata->constraints();
357 if ( !otherLayerMetadata->rights().isEmpty() )
358 mRights = otherLayerMetadata->rights();
360 if ( !otherLayerMetadata->licenses().isEmpty() )
361 mLicenses = otherLayerMetadata->licenses();
363 if ( !otherLayerMetadata->encoding().isEmpty() )
364 mEncoding = otherLayerMetadata->encoding();
366 if ( otherLayerMetadata->crs().isValid() )
367 mCrs = otherLayerMetadata->crs();
369 if ( !otherLayerMetadata->extent().spatialExtents().isEmpty() )
372 if ( !otherLayerMetadata->extent().temporalExtents().isEmpty() )
394 return mSpatialExtents;
399 mSpatialExtents = spatialExtents;
404 return mTemporalExtents;
409 mTemporalExtents = temporalExtents;
414 return mSpatialExtents == other.mSpatialExtents && mTemporalExtents == other.mTemporalExtents;
420 mFees == other.mFees &&
421 mConstraints == other.mConstraints &&
422 mRights == other.mRights &&
423 mLicenses == other.mLicenses &&
424 mEncoding == other.mEncoding &&
425 mCrs == other.mCrs &&
426 mExtent == other.mExtent;
432 if ( searchString.trimmed().isEmpty() )
437 if (
title().
contains( searchString, Qt::CaseInsensitive ) ||
444 const QList<QStringList> keyVals {
keywords().values() };
445 for (
const QStringList &kws : std::as_const( keyVals ) )
447 for (
const QString &kw : std::as_const( kws ) )
449 if ( kw.contains( searchString, Qt::CaseSensitivity::CaseInsensitive ) )
457 for (
const QString &cat : std::as_const( constCat ) )
459 if ( cat.contains( searchString, Qt::CaseSensitivity::CaseInsensitive ) )
470 for (
const QRegularExpression &re : std::as_const( searchReList ) )
472 if ( re.match(
title() ).hasMatch() ||
479 const QList<QStringList> keyVals {
keywords().values() };
480 for (
const QStringList &kws : std::as_const( keyVals ) )
482 for (
const QString &kw : std::as_const( kws ) )
484 if ( re.match( kw ).hasMatch() )
492 for (
const QString &cat : std::as_const( constCat ) )
494 if ( re.match( cat ).hasMatch() )
A 3-dimensional box composed of x, y, z coordinates.
void setXMaximum(double x) SIP_HOLDGIL
Sets the maximum x value.
void setYMaximum(double y) SIP_HOLDGIL
Sets the maximum y value.
void setZMinimum(double z) SIP_HOLDGIL
Sets the minimum z value.
void setZMaximum(double z) SIP_HOLDGIL
Sets the maximum z value.
void setYMinimum(double y) SIP_HOLDGIL
Sets the minimum y value.
void setXMinimum(double x) SIP_HOLDGIL
Sets the minimum x value.
This class represents a coordinate reference system (CRS).
static QgsCoordinateReferenceSystem fromOgcWmsCrs(const QString &ogcCrs)
Creates a CRS from a given OGC WMS-format Coordinate Reference System string.
bool readXml(const QDomNode &node)
Restores state from the given DOM node.
bool writeXml(QDomNode &node, QDomDocument &doc) const
Stores state to the given Dom node in the given document.
Base class for all map layer types.
Q_INVOKABLE QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
Q_INVOKABLE void setCustomProperty(const QString &key, const QVariant &value)
Set a custom property for layer.
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
const QgsCoordinateReferenceSystem & crs