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();
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 );
361 return mSpatialExtents;
366 mSpatialExtents = spatialExtents;
371 return mTemporalExtents;
376 mTemporalExtents = temporalExtents;
381 return mSpatialExtents == other.mSpatialExtents && mTemporalExtents == other.mTemporalExtents;
387 mFees == other.mFees &&
388 mConstraints == other.mConstraints &&
389 mRights == other.mRights &&
390 mLicenses == other.mLicenses &&
391 mEncoding == other.mEncoding &&
392 mCrs == other.mCrs &&
393 mExtent == other.mExtent;
Base class for all map layer types.
QList< QgsAbstractMetadataBase::Link > LinkList
A list of links.
void setXMinimum(double x)
Sets the minimum x value.
bool writeXml(QDomNode &node, QDomDocument &doc) const
Stores state to the given Dom node in the given document.
void setCustomProperty(const QString &key, const QVariant &value)
Set a custom property for layer.
QList< QgsAbstractMetadataBase::Contact > ContactList
A list of contacts.
void setXMaximum(double x)
Sets the maximum x value.
A 3-dimensional box composed of x, y, z coordinates.
void setYMaximum(double y)
Sets the maximum y value.
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
void setZMinimum(double z)
Sets the minimum z value.
void setYMinimum(double y)
Sets the minimum y value.
static QgsCoordinateReferenceSystem fromOgcWmsCrs(const QString &ogcCrs)
Creates a CRS from a given OGC WMS-format Coordinate Reference System string.
This class represents a coordinate reference system (CRS).
QString authid() const
Returns the authority identifier for the CRS.
bool readXml(const QDomNode &node)
Restores state from the given DOM node.
void setZMaximum(double z)
Sets the maximum z value.