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 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 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 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 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 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 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 QDomNodeList instantList = mnl.toElement().elementsByTagName( QStringLiteral(
"instant" ) );
218 for (
int i = 0; i < instantList.size(); i++ )
220 mnl = instantList.at( i );
221 QDateTime d = QDateTime().fromString( mnl.toElement().text(), Qt::ISODate );
222 QgsDateTimeRange date = QgsDateTimeRange( d, d );
223 metadataDates << date;
225 QDomNodeList periodList = mnl.toElement().elementsByTagName( QStringLiteral(
"period" ) );
226 for (
int i = 0; i < periodList.size(); i++ )
228 QDomNode begin = periodList.at( i ).namedItem( QStringLiteral(
"start" ) );
229 QDomNode end = periodList.at( i ).namedItem( QStringLiteral(
"end" ) );
230 QDateTime beginDate = QDateTime().fromString( begin.toElement().text(), Qt::ISODate );
231 QDateTime endDate = QDateTime().fromString( end.toElement().text(), Qt::ISODate );
232 QgsDateTimeRange date = QgsDateTimeRange( beginDate, endDate );
233 metadataDates << date;
247 QDomElement
fees = document.createElement( QStringLiteral(
"fees" ) );
248 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 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 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 QDomText licenseText = document.createTextNode( license );
276 licenseElement.appendChild( licenseText );
277 metadataElement.appendChild( licenseElement );
281 QDomElement
encoding = document.createElement( QStringLiteral(
"encoding" ) );
282 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 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 QDomText startText = document.createTextNode( temporalExtent.begin().toTimeSpec( Qt::OffsetFromUTC ).toString( Qt::ISODate ) );
329 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;
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.
QString authid() const
Returns the authority identifier for the CRS.
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