23#include <QRegularExpression>
26using namespace Qt::StringLiterals;
45 mConstraints << constraint;
105 layer->
setCustomProperty( u
"metadata/extent"_s, QVariant::fromValue( mExtent ) );
113 layer->
setCustomProperty( u
"metadata/constraints"_s, QVariant::fromValue( mConstraints ) );
128 mRights = layer->
customProperty( u
"metadata/rights"_s ).toStringList();
129 mLicenses = layer->
customProperty( u
"metadata/licenses"_s ).toStringList();
131 mEncoding = layer->
customProperty( u
"metadata/encoding"_s ).toString();
132 const QString crsAuthId = layer->
customProperty( u
"metadata/crs"_s ).toString();
149 mnl = metadataElement.namedItem( u
"fees"_s );
150 mFees = mnl.toElement().text();
153 const QDomNodeList constraintsList = metadataElement.elementsByTagName( u
"constraints"_s );
154 mConstraints.clear();
155 for (
int i = 0; i < constraintsList.size(); i++ )
157 mnl = constraintsList.at( i );
158 mne = mnl.toElement();
163 const QDomNodeList rightsNodeList = metadataElement.elementsByTagName( u
"rights"_s );
164 QStringList rightsList;
165 for (
int i = 0; i < rightsNodeList.size(); i++ )
167 mnl = rightsNodeList.at( i );
168 mne = mnl.toElement();
170 rightsList.append( right );
175 const QDomNodeList licensesNodeList = metadataElement.elementsByTagName( u
"license"_s );
176 QStringList licensesList;
177 for (
int i = 0; i < licensesNodeList.size(); i++ )
179 mnl = licensesNodeList.at( i );
180 mne = mnl.toElement();
181 licensesList.append( mne.text() );
186 mnl = metadataElement.namedItem( u
"encoding"_s );
187 mEncoding = mnl.toElement().text();
190 mnl = metadataElement.namedItem( u
"crs"_s );
191 if ( !mCrs.readXml( mnl ) )
195 mnl = metadataElement.namedItem( u
"extent"_s );
199 const QDomNodeList spatialList = mnl.toElement().elementsByTagName( u
"spatial"_s );
200 QList< QgsLayerMetadata::SpatialExtent > metadataSpatialExtents;
201 for (
int i = 0; i < spatialList.size(); i++ )
203 mnl = spatialList.at( i );
204 mne = mnl.toElement();
214 metadataSpatialExtents.append( se );
219 mnl = metadataElement.namedItem( u
"extent"_s );
220 const QDomNodeList temporalList = mnl.toElement().elementsByTagName( u
"temporal"_s );
221 QList<QgsDateTimeRange> metadataDates;
222 for (
int j = 0; j < temporalList.size(); j++ )
224 mnl = temporalList.at( j );
225 const QDomNodeList instantList = mnl.toElement().elementsByTagName( u
"instant"_s );
226 for (
int i = 0; i < instantList.size(); i++ )
228 mnl = instantList.at( i );
229 const QDateTime d = QDateTime::fromString( mnl.toElement().text(), Qt::ISODate );
231 metadataDates << date;
233 const QDomNodeList periodList = mnl.toElement().elementsByTagName( u
"period"_s );
234 for (
int i = 0; i < periodList.size(); i++ )
236 const QDomNode begin = periodList.at( i ).namedItem( u
"start"_s );
237 const QDomNode end = periodList.at( i ).namedItem( u
"end"_s );
238 const QDateTime beginDate = QDateTime::fromString( begin.toElement().text(), Qt::ISODate );
239 const QDateTime endDate = QDateTime::fromString( end.toElement().text(), Qt::ISODate );
241 metadataDates << date;
255 QDomElement
fees = document.createElement( u
"fees"_s );
256 const QDomText feesText = document.createTextNode( mFees );
257 fees.appendChild( feesText );
258 metadataElement.appendChild(
fees );
263 QDomElement constraintElement = document.createElement( u
"constraints"_s );
264 constraintElement.setAttribute( u
"type"_s, constraint.type );
265 const QDomText constraintText = document.createTextNode( constraint.constraint );
266 constraintElement.appendChild( constraintText );
267 metadataElement.appendChild( constraintElement );
271 for (
const QString &right : mRights )
273 QDomElement rightElement = document.createElement( u
"rights"_s );
274 const QDomText rightText = document.createTextNode( right );
275 rightElement.appendChild( rightText );
276 metadataElement.appendChild( rightElement );
280 for (
const QString &license : mLicenses )
282 QDomElement licenseElement = document.createElement( u
"license"_s );
283 const QDomText licenseText = document.createTextNode( license );
284 licenseElement.appendChild( licenseText );
285 metadataElement.appendChild( licenseElement );
289 QDomElement
encoding = document.createElement( u
"encoding"_s );
290 const QDomText encodingText = document.createTextNode( mEncoding );
291 encoding.appendChild( encodingText );
292 metadataElement.appendChild(
encoding );
295 QDomElement crsElement = document.createElement( u
"crs"_s );
296 mCrs.writeXml( crsElement, document );
297 metadataElement.appendChild( crsElement );
300 QDomElement extentElement = document.createElement( u
"extent"_s );
306 QDomElement spatialElement = document.createElement( u
"spatial"_s );
308 spatialElement.setAttribute( u
"dimensions"_s, u
"2"_s );
309 spatialElement.setAttribute( u
"crs"_s, spatialExtent.extentCrs.authid() );
310 spatialElement.setAttribute( u
"minx"_s,
qgsDoubleToString( spatialExtent.bounds.xMinimum() ) );
311 spatialElement.setAttribute( u
"miny"_s,
qgsDoubleToString( spatialExtent.bounds.yMinimum() ) );
312 spatialElement.setAttribute( u
"minz"_s,
qgsDoubleToString( spatialExtent.bounds.zMinimum() ) );
313 spatialElement.setAttribute( u
"maxx"_s,
qgsDoubleToString( spatialExtent.bounds.xMaximum() ) );
314 spatialElement.setAttribute( u
"maxy"_s,
qgsDoubleToString( spatialExtent.bounds.yMaximum() ) );
315 spatialElement.setAttribute( u
"maxz"_s,
qgsDoubleToString( spatialExtent.bounds.zMaximum() ) );
316 extentElement.appendChild( spatialElement );
323 QDomElement temporalElement = document.createElement( u
"temporal"_s );
324 if ( temporalExtent.isInstant() )
326 QDomElement instantElement = document.createElement( u
"instant"_s );
327 const QDomText instantText = document.createTextNode( temporalExtent.begin().toTimeSpec( Qt::OffsetFromUTC ).toString( Qt::ISODate ) );
328 instantElement.appendChild( instantText );
329 temporalElement.appendChild( instantElement );
333 QDomElement periodElement = document.createElement( u
"period"_s );
334 QDomElement startElement = document.createElement( u
"start"_s );
335 QDomElement endElement = document.createElement( u
"end"_s );
336 const QDomText startText = document.createTextNode( temporalExtent.begin().toTimeSpec( Qt::OffsetFromUTC ).toString( Qt::ISODate ) );
337 const QDomText endText = document.createTextNode( temporalExtent.end().toTimeSpec( Qt::OffsetFromUTC ).toString( Qt::ISODate ) );
338 startElement.appendChild( startText );
339 endElement.appendChild( endText );
340 periodElement.appendChild( startElement );
341 periodElement.appendChild( endElement );
342 temporalElement.appendChild( periodElement );
344 extentElement.appendChild( temporalElement );
347 metadataElement.appendChild( extentElement );
356 for (
const QString &right : std::as_const( mRights ) )
368 if ( !otherLayerMetadata->fees().isEmpty() )
369 mFees = otherLayerMetadata->fees();
371 if ( !otherLayerMetadata->constraints().isEmpty() )
372 mConstraints = otherLayerMetadata->constraints();
374 if ( !otherLayerMetadata->rights().isEmpty() )
375 mRights = otherLayerMetadata->rights();
377 if ( !otherLayerMetadata->licenses().isEmpty() )
378 mLicenses = otherLayerMetadata->licenses();
380 if ( !otherLayerMetadata->encoding().isEmpty() )
381 mEncoding = otherLayerMetadata->encoding();
383 if ( otherLayerMetadata->crs().isValid() )
384 mCrs = otherLayerMetadata->crs();
386 if ( !otherLayerMetadata->extent().spatialExtents().isEmpty() )
387 mExtent.setSpatialExtents( otherLayerMetadata->extent().spatialExtents() );
389 if ( !otherLayerMetadata->extent().temporalExtents().isEmpty() )
390 mExtent.setTemporalExtents( otherLayerMetadata->extent().temporalExtents() );
411 return mSpatialExtents;
421 return mTemporalExtents;
431 return mSpatialExtents == other.mSpatialExtents && mTemporalExtents == other.mTemporalExtents;
437 mFees == other.mFees &&
438 mConstraints == other.mConstraints &&
439 mRights == other.mRights &&
440 mLicenses == other.mLicenses &&
441 mEncoding == other.mEncoding &&
442 mCrs == other.mCrs &&
443 mExtent == other.mExtent;
449 if ( searchString.trimmed().isEmpty() )
454 if (
title().
contains( searchString, Qt::CaseInsensitive ) ||
461 const QList<QStringList> keyVals {
keywords().values() };
462 for (
const QStringList &kws : std::as_const( keyVals ) )
464 for (
const QString &kw : std::as_const( kws ) )
466 if ( kw.contains( searchString, Qt::CaseSensitivity::CaseInsensitive ) )
474 for (
const QString &cat : std::as_const( constCat ) )
476 if ( cat.contains( searchString, Qt::CaseSensitivity::CaseInsensitive ) )
487 for (
const QRegularExpression &re : std::as_const( searchReList ) )
489 if ( re.match(
title() ).hasMatch() ||
496 const QList<QStringList> keyVals {
keywords().values() };
497 for (
const QStringList &kws : std::as_const( keyVals ) )
499 for (
const QString &kw : std::as_const( kws ) )
501 if ( re.match( kw ).hasMatch() )
509 for (
const QString &cat : std::as_const( constCat ) )
511 if ( re.match( cat ).hasMatch() )
A 3-dimensional box composed of x, y, z coordinates.
void setZMinimum(double z)
Sets the minimum z value.
void setYMaximum(double y)
Sets the maximum y value.
void setZMaximum(double z)
Sets the maximum z value.
void setXMaximum(double x)
Sets the maximum x value.
void setYMinimum(double y)
Sets the minimum y value.
void setXMinimum(double x)
Sets the minimum x value.
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.
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.
virtual QString translate(const QString &context, const QString &sourceText, const char *disambiguation=nullptr, int n=-1) const =0
Translates a string using the Qt QTranslator mechanism.
A container for the context for various read/write operations on objects.
const QgsProjectTranslator * projectTranslator() const
Returns the project translator.
Used for the collecting of strings from projects for translation and creation of ts files.
void registerTranslation(const QString &context, const QString &source)
Registers the source to be translated.
QList< QgsAbstractMetadataBase::Link > LinkList
A list of links.
QList< QgsAbstractMetadataBase::Contact > ContactList
A list of contacts.
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
QgsTemporalRange< QDateTime > QgsDateTimeRange
QgsRange which stores a range of date times.