38 mConstraints << constraint;
98 layer->
setCustomProperty( QStringLiteral(
"metadata/extent" ), QVariant::fromValue( mExtent ) );
106 layer->
setCustomProperty( QStringLiteral(
"metadata/constraints" ), QVariant::fromValue( mConstraints ) );
120 mFees = layer->
customProperty( QStringLiteral(
"metadata/fees" ) ).toString();
121 mRights = layer->
customProperty( QStringLiteral(
"metadata/rights" ) ).toStringList();
122 mLicenses = layer->
customProperty( QStringLiteral(
"metadata/licenses" ) ).toStringList();
124 mEncoding = layer->
customProperty( QStringLiteral(
"metadata/encoding" ) ).toString();
125 const QString crsAuthId = layer->
customProperty( QStringLiteral(
"metadata/crs" ) ).toString();
128 mConstraints = layer->
customProperty( QStringLiteral(
"metadata/constraints" ) ).value<ConstraintList>();
129 mKeywords = layer->
customProperty( QStringLiteral(
"metadata/keywords" ) ).value<QgsAbstractMetadataBase::KeywordMap>();
130 mContacts = layer->
customProperty( QStringLiteral(
"metadata/contacts" ) ).value<QgsAbstractMetadataBase::ContactList>();
131 mLinks = layer->
customProperty( QStringLiteral(
"metadata/links" ) ).value<QgsAbstractMetadataBase::LinkList>();
142 mnl = metadataElement.namedItem( QStringLiteral(
"fees" ) );
143 mFees = mnl.toElement().text();
146 const QDomNodeList constraintsList = metadataElement.elementsByTagName( QStringLiteral(
"constraints" ) );
147 mConstraints.clear();
148 for (
int i = 0; i < constraintsList.size(); i++ )
150 mnl = constraintsList.at( i );
151 mne = mnl.toElement();
156 const QDomNodeList rightsNodeList = metadataElement.elementsByTagName( QStringLiteral(
"rights" ) );
157 QStringList rightsList;
158 for (
int i = 0; i < rightsNodeList.size(); i++ )
160 mnl = rightsNodeList.at( i );
161 mne = mnl.toElement();
162 rightsList.append( mne.text() );
167 const QDomNodeList licensesNodeList = metadataElement.elementsByTagName( QStringLiteral(
"license" ) );
168 QStringList licensesList;
169 for (
int i = 0; i < licensesNodeList.size(); i++ )
171 mnl = licensesNodeList.at( i );
172 mne = mnl.toElement();
173 licensesList.append( mne.text() );
178 mnl = metadataElement.namedItem( QStringLiteral(
"encoding" ) );
179 mEncoding = mnl.toElement().text();
182 mnl = metadataElement.namedItem( QStringLiteral(
"crs" ) );
187 mnl = metadataElement.namedItem( QStringLiteral(
"extent" ) );
191 const QDomNodeList spatialList = mnl.toElement().elementsByTagName( QStringLiteral(
"spatial" ) );
192 QList< QgsLayerMetadata::SpatialExtent > metadataSpatialExtents;
193 for (
int i = 0; i < spatialList.size(); i++ )
195 mnl = spatialList.at( i );
196 mne = mnl.toElement();
206 metadataSpatialExtents.append( se );
211 mnl = metadataElement.namedItem( QStringLiteral(
"extent" ) );
212 const QDomNodeList temporalList = mnl.toElement().elementsByTagName( QStringLiteral(
"temporal" ) );
213 QList<QgsDateTimeRange> metadataDates;
214 for (
int j = 0; j < temporalList.size(); j++ )
216 mnl = temporalList.at( j );
217 const QDomNodeList instantList = mnl.toElement().elementsByTagName( QStringLiteral(
"instant" ) );
218 for (
int i = 0; i < instantList.size(); i++ )
220 mnl = instantList.at( i );
221 const QDateTime d = QDateTime::fromString( mnl.toElement().text(), Qt::ISODate );
222 const QgsDateTimeRange date = QgsDateTimeRange( d, d );
223 metadataDates << date;
225 const QDomNodeList periodList = mnl.toElement().elementsByTagName( QStringLiteral(
"period" ) );
226 for (
int i = 0; i < periodList.size(); i++ )
228 const QDomNode begin = periodList.at( i ).namedItem( QStringLiteral(
"start" ) );
229 const QDomNode end = periodList.at( i ).namedItem( QStringLiteral(
"end" ) );
230 const QDateTime beginDate = QDateTime::fromString( begin.toElement().text(), Qt::ISODate );
231 const QDateTime endDate = QDateTime::fromString( end.toElement().text(), Qt::ISODate );
232 const QgsDateTimeRange date = QgsDateTimeRange( beginDate, endDate );
233 metadataDates << date;
247 QDomElement
fees = document.createElement( QStringLiteral(
"fees" ) );
248 const QDomText feesText = document.createTextNode( mFees );
249 fees.appendChild( feesText );
250 metadataElement.appendChild(
fees );
255 QDomElement constraintElement = document.createElement( QStringLiteral(
"constraints" ) );
256 constraintElement.setAttribute( QStringLiteral(
"type" ), constraint.type );
257 const QDomText constraintText = document.createTextNode( constraint.constraint );
258 constraintElement.appendChild( constraintText );
259 metadataElement.appendChild( constraintElement );
263 for (
const QString &right : mRights )
265 QDomElement rightElement = document.createElement( QStringLiteral(
"rights" ) );
266 const QDomText rightText = document.createTextNode( right );
267 rightElement.appendChild( rightText );
268 metadataElement.appendChild( rightElement );
272 for (
const QString &license : mLicenses )
274 QDomElement licenseElement = document.createElement( QStringLiteral(
"license" ) );
275 const QDomText licenseText = document.createTextNode( license );
276 licenseElement.appendChild( licenseText );
277 metadataElement.appendChild( licenseElement );
281 QDomElement
encoding = document.createElement( QStringLiteral(
"encoding" ) );
282 const QDomText encodingText = document.createTextNode( mEncoding );
283 encoding.appendChild( encodingText );
284 metadataElement.appendChild(
encoding );
287 QDomElement crsElement = document.createElement( QStringLiteral(
"crs" ) );
288 mCrs.
writeXml( crsElement, document );
289 metadataElement.appendChild( crsElement );
292 QDomElement extentElement = document.createElement( QStringLiteral(
"extent" ) );
298 QDomElement spatialElement = document.createElement( QStringLiteral(
"spatial" ) );
300 spatialElement.setAttribute( QStringLiteral(
"dimensions" ), QStringLiteral(
"2" ) );
301 spatialElement.setAttribute( QStringLiteral(
"crs" ), spatialExtent.extentCrs.authid() );
302 spatialElement.setAttribute( QStringLiteral(
"minx" ),
qgsDoubleToString( spatialExtent.bounds.xMinimum() ) );
303 spatialElement.setAttribute( QStringLiteral(
"miny" ),
qgsDoubleToString( spatialExtent.bounds.yMinimum() ) );
304 spatialElement.setAttribute( QStringLiteral(
"minz" ),
qgsDoubleToString( spatialExtent.bounds.zMinimum() ) );
305 spatialElement.setAttribute( QStringLiteral(
"maxx" ),
qgsDoubleToString( spatialExtent.bounds.xMaximum() ) );
306 spatialElement.setAttribute( QStringLiteral(
"maxy" ),
qgsDoubleToString( spatialExtent.bounds.yMaximum() ) );
307 spatialElement.setAttribute( QStringLiteral(
"maxz" ),
qgsDoubleToString( spatialExtent.bounds.zMaximum() ) );
308 extentElement.appendChild( spatialElement );
313 for (
const QgsDateTimeRange &temporalExtent : tExtents )
315 QDomElement temporalElement = document.createElement( QStringLiteral(
"temporal" ) );
316 if ( temporalExtent.isInstant() )
318 QDomElement instantElement = document.createElement( QStringLiteral(
"instant" ) );
319 const QDomText instantText = document.createTextNode( temporalExtent.begin().toTimeSpec( Qt::OffsetFromUTC ).toString( Qt::ISODate ) );
320 instantElement.appendChild( instantText );
321 temporalElement.appendChild( instantElement );
325 QDomElement periodElement = document.createElement( QStringLiteral(
"period" ) );
326 QDomElement startElement = document.createElement( QStringLiteral(
"start" ) );
327 QDomElement endElement = document.createElement( QStringLiteral(
"end" ) );
328 const QDomText startText = document.createTextNode( temporalExtent.begin().toTimeSpec( Qt::OffsetFromUTC ).toString( Qt::ISODate ) );
329 const QDomText endText = document.createTextNode( temporalExtent.end().toTimeSpec( Qt::OffsetFromUTC ).toString( Qt::ISODate ) );
330 startElement.appendChild( startText );
331 endElement.appendChild( endText );
332 periodElement.appendChild( startElement );
333 periodElement.appendChild( endElement );
334 temporalElement.appendChild( periodElement );
336 extentElement.appendChild( temporalElement );
339 metadataElement.appendChild( extentElement );
350 if ( !otherLayerMetadata->fees().isEmpty() )
351 mFees = otherLayerMetadata->fees();
353 if ( !otherLayerMetadata->constraints().isEmpty() )
354 mConstraints = otherLayerMetadata->constraints();
356 if ( !otherLayerMetadata->rights().isEmpty() )
357 mRights = otherLayerMetadata->rights();
359 if ( !otherLayerMetadata->licenses().isEmpty() )
360 mLicenses = otherLayerMetadata->licenses();
362 if ( !otherLayerMetadata->encoding().isEmpty() )
363 mEncoding = otherLayerMetadata->encoding();
365 if ( otherLayerMetadata->crs().isValid() )
366 mCrs = otherLayerMetadata->crs();
368 if ( !otherLayerMetadata->extent().spatialExtents().isEmpty() )
371 if ( !otherLayerMetadata->extent().temporalExtents().isEmpty() )
393 return mSpatialExtents;
398 mSpatialExtents = spatialExtents;
403 return mTemporalExtents;
408 mTemporalExtents = temporalExtents;
413 return mSpatialExtents == other.mSpatialExtents && mTemporalExtents == other.mTemporalExtents;
419 mFees == other.mFees &&
420 mConstraints == other.mConstraints &&
421 mRights == other.mRights &&
422 mLicenses == other.mLicenses &&
423 mEncoding == other.mEncoding &&
424 mCrs == other.mCrs &&
425 mExtent == other.mExtent;