33 return mParentIdentifier;
83 mConstraints << constraint;
163 mKeywords.insert( vocabulary, keywords );
168 return mKeywords.remove( vocabulary );
173 return mKeywords.keys();
178 return mKeywords.value( vocabulary );
183 if ( mKeywords.contains( QStringLiteral(
"gmd:topicCategory" ) ) )
185 return mKeywords.value( QStringLiteral(
"gmd:topicCategory" ) );
189 return QStringList();
195 mKeywords.insert( QStringLiteral(
"gmd:topicCategory" ), category );
210 mContacts << contact;
240 layer->
setCustomProperty( QStringLiteral(
"metadata/identifier" ), mIdentifier );
241 layer->
setCustomProperty( QStringLiteral(
"metadata/parentIdentifier" ), mParentIdentifier );
245 layer->
setCustomProperty( QStringLiteral(
"metadata/extent" ), QVariant::fromValue( mExtent ) );
253 layer->
setCustomProperty( QStringLiteral(
"metadata/constraints" ), QVariant::fromValue( mConstraints ) );
254 layer->
setCustomProperty( QStringLiteral(
"metadata/keywords" ), QVariant::fromValue( mKeywords ) );
255 layer->
setCustomProperty( QStringLiteral(
"metadata/contacts" ), QVariant::fromValue( mContacts ) );
256 layer->
setCustomProperty( QStringLiteral(
"metadata/links" ), QVariant::fromValue( mLinks ) );
261 mIdentifier = layer->
customProperty( QStringLiteral(
"metadata/identifier" ) ).toString();
262 mParentIdentifier = layer->
customProperty( QStringLiteral(
"metadata/parentIdentifier" ) ).toString();
263 mLanguage = layer->
customProperty( QStringLiteral(
"metadata/language" ) ).toString();
264 mType = layer->
customProperty( QStringLiteral(
"metadata/type" ) ).toString();
265 mTitle = layer->
customProperty( QStringLiteral(
"metadata/title" ) ).toString();
266 mAbstract = layer->
customProperty( QStringLiteral(
"metadata/abstract" ) ).toString();
267 mFees = layer->
customProperty( QStringLiteral(
"metadata/fees" ) ).toString();
268 mRights = layer->
customProperty( QStringLiteral(
"metadata/rights" ) ).toStringList();
269 mLicenses = layer->
customProperty( QStringLiteral(
"metadata/licenses" ) ).toStringList();
270 mHistory = layer->
customProperty( QStringLiteral(
"metadata/history" ) ).toStringList();
271 mEncoding = layer->
customProperty( QStringLiteral(
"metadata/encoding" ) ).toString();
272 QString crsAuthId = layer->
customProperty( QStringLiteral(
"metadata/crs" ) ).toString();
287 mnl = metadataElement.namedItem( QStringLiteral(
"identifier" ) );
288 mIdentifier = mnl.toElement().text();
291 mnl = metadataElement.namedItem( QStringLiteral(
"parentidentifier" ) );
292 mParentIdentifier = mnl.toElement().text();
295 mnl = metadataElement.namedItem( QStringLiteral(
"language" ) );
296 mLanguage = mnl.toElement().text();
299 mnl = metadataElement.namedItem( QStringLiteral(
"type" ) );
300 mType = mnl.toElement().text();
303 mnl = metadataElement.namedItem( QStringLiteral(
"title" ) );
304 mTitle = mnl.toElement().text();
307 mnl = metadataElement.namedItem( QStringLiteral(
"abstract" ) );
308 mAbstract = mnl.toElement().text();
311 QDomNodeList
keywords = metadataElement.elementsByTagName( QStringLiteral(
"keywords" ) );
313 for (
int i = 0; i < keywords.size(); i++ )
315 QStringList keywordsList;
316 mnl = keywords.at( i );
317 mne = mnl.toElement();
319 QDomNodeList el = mne.elementsByTagName( QStringLiteral(
"keyword" ) );
320 for (
int j = 0; j < el.size(); j++ )
322 keywordsList.append( el.at( j ).toElement().text() );
324 addKeywords( mne.attribute( QStringLiteral(
"vocabulary" ) ), keywordsList );
328 mnl = metadataElement.namedItem( QStringLiteral(
"fees" ) );
329 mFees = mnl.toElement().text();
332 QDomNodeList constraintsList = metadataElement.elementsByTagName( QStringLiteral(
"constraints" ) );
333 mConstraints.clear();
334 for (
int i = 0; i < constraintsList.size(); i++ )
336 mnl = constraintsList.at( i );
337 mne = mnl.toElement();
342 QDomNodeList rightsNodeList = metadataElement.elementsByTagName( QStringLiteral(
"rights" ) );
343 QStringList rightsList;
344 for (
int i = 0; i < rightsNodeList.size(); i++ )
346 mnl = rightsNodeList.at( i );
347 mne = mnl.toElement();
348 rightsList.append( mne.text() );
353 QDomNodeList licensesNodeList = metadataElement.elementsByTagName( QStringLiteral(
"license" ) );
354 QStringList licensesList;
355 for (
int i = 0; i < licensesNodeList.size(); i++ )
357 mnl = licensesNodeList.at( i );
358 mne = mnl.toElement();
359 licensesList.append( mne.text() );
364 mnl = metadataElement.namedItem( QStringLiteral(
"encoding" ) );
365 mEncoding = mnl.toElement().text();
368 mnl = metadataElement.namedItem( QStringLiteral(
"crs" ) );
373 mnl = metadataElement.namedItem( QStringLiteral(
"extent" ) );
377 QDomNodeList spatialList = mnl.toElement().elementsByTagName( QStringLiteral(
"spatial" ) );
378 QList< QgsLayerMetadata::SpatialExtent > metadataSpatialExtents;
379 for (
int i = 0; i < spatialList.size(); i++ )
381 mnl = spatialList.at( i );
382 mne = mnl.toElement();
392 metadataSpatialExtents.append( se );
397 mnl = metadataElement.namedItem( QStringLiteral(
"extent" ) );
398 QDomNodeList temporalList = mnl.toElement().elementsByTagName( QStringLiteral(
"temporal" ) );
399 QList<QgsDateTimeRange> metadataDates;
400 for (
int j = 0; j < temporalList.size(); j++ )
402 mnl = temporalList.at( j );
403 QDomNodeList instantList = mnl.toElement().elementsByTagName( QStringLiteral(
"instant" ) );
404 for (
int i = 0; i < instantList.size(); i++ )
406 mnl = instantList.at( i );
407 QDateTime d = QDateTime().fromString( mnl.toElement().text(), Qt::ISODate );
408 QgsDateTimeRange date = QgsDateTimeRange( d, d );
409 metadataDates << date;
411 QDomNodeList periodList = mnl.toElement().elementsByTagName( QStringLiteral(
"period" ) );
412 for (
int i = 0; i < periodList.size(); i++ )
414 QDomNode begin = periodList.at( i ).namedItem( QStringLiteral(
"start" ) );
415 QDomNode
end = periodList.at( i ).namedItem( QStringLiteral(
"end" ) );
416 QDateTime beginDate = QDateTime().fromString( begin.toElement().text(), Qt::ISODate );
417 QDateTime endDate = QDateTime().fromString( end.toElement().text(), Qt::ISODate );
418 QgsDateTimeRange date = QgsDateTimeRange( beginDate, endDate );
419 metadataDates << date;
426 QDomNodeList contactsList = metadataElement.elementsByTagName( QStringLiteral(
"contact" ) );
428 for (
int i = 0; i < contactsList.size(); i++ )
430 mnl = contactsList.at( i );
431 mne = mnl.toElement();
434 oneContact.
name = mne.namedItem( QStringLiteral(
"name" ) ).toElement().text();
435 oneContact.
organization = mne.namedItem( QStringLiteral(
"organization" ) ).toElement().text();
436 oneContact.
position = mne.namedItem( QStringLiteral(
"position" ) ).toElement().text();
437 oneContact.
voice = mne.namedItem( QStringLiteral(
"voice" ) ).toElement().text();
438 oneContact.
fax = mne.namedItem( QStringLiteral(
"fax" ) ).toElement().text();
439 oneContact.
email = mne.namedItem( QStringLiteral(
"email" ) ).toElement().text();
440 oneContact.
role = mne.namedItem( QStringLiteral(
"role" ) ).toElement().text();
442 QList< QgsLayerMetadata::Address > addresses;
443 QDomNodeList addressList = mne.elementsByTagName( QStringLiteral(
"contactAddress" ) );
444 for (
int j = 0; j < addressList.size(); j++ )
446 QDomElement addressElement = addressList.at( j ).toElement();
448 oneAddress.
address = addressElement.namedItem( QStringLiteral(
"address" ) ).toElement().text();
449 oneAddress.
administrativeArea = addressElement.namedItem( QStringLiteral(
"administrativearea" ) ).toElement().text();
450 oneAddress.
city = addressElement.namedItem( QStringLiteral(
"city" ) ).toElement().text();
451 oneAddress.
country = addressElement.namedItem( QStringLiteral(
"country" ) ).toElement().text();
452 oneAddress.
postalCode = addressElement.namedItem( QStringLiteral(
"postalcode" ) ).toElement().text();
453 oneAddress.
type = addressElement.namedItem( QStringLiteral(
"type" ) ).toElement().text();
454 addresses << oneAddress;
461 mnl = metadataElement.namedItem( QStringLiteral(
"links" ) );
462 mne = mnl.toElement();
464 QDomNodeList el = mne.elementsByTagName( QStringLiteral(
"link" ) );
465 for (
int i = 0; i < el.size(); i++ )
467 mne = el.at( i ).toElement();
469 oneLink.
name = mne.attribute( QStringLiteral(
"name" ) );
470 oneLink.
type = mne.attribute( QStringLiteral(
"type" ) );
471 oneLink.
url = mne.attribute( QStringLiteral(
"url" ) );
472 oneLink.
description = mne.attribute( QStringLiteral(
"description" ) );
473 oneLink.
format = mne.attribute( QStringLiteral(
"format" ) );
474 oneLink.
mimeType = mne.attribute( QStringLiteral(
"mimeType" ) );
475 oneLink.
size = mne.attribute( QStringLiteral(
"size" ) );
480 QDomNodeList historyNodeList = metadataElement.elementsByTagName( QStringLiteral(
"history" ) );
481 QStringList historyList;
482 for (
int i = 0; i < historyNodeList.size(); i++ )
484 mnl = historyNodeList.at( i );
485 mne = mnl.toElement();
486 historyList.append( mne.text() );
496 QDomElement
identifier = document.createElement( QStringLiteral(
"identifier" ) );
497 QDomText identifierText = document.createTextNode( mIdentifier );
498 identifier.appendChild( identifierText );
499 metadataElement.appendChild( identifier );
502 QDomElement
parentIdentifier = document.createElement( QStringLiteral(
"parentidentifier" ) );
503 QDomText parentIdentifierText = document.createTextNode( mParentIdentifier );
504 parentIdentifier.appendChild( parentIdentifierText );
505 metadataElement.appendChild( parentIdentifier );
508 QDomElement
language = document.createElement( QStringLiteral(
"language" ) );
509 QDomText languageText = document.createTextNode( mLanguage );
510 language.appendChild( languageText );
511 metadataElement.appendChild( language );
514 QDomElement
type = document.createElement( QStringLiteral(
"type" ) );
515 QDomText typeText = document.createTextNode( mType );
516 type.appendChild( typeText );
517 metadataElement.appendChild( type );
520 QDomElement
title = document.createElement( QStringLiteral(
"title" ) );
521 QDomText titleText = document.createTextNode( mTitle );
522 title.appendChild( titleText );
523 metadataElement.appendChild( title );
526 QDomElement
abstract = document.createElement( QStringLiteral(
"abstract" ) );
527 QDomText abstractText = document.createTextNode( mAbstract );
528 abstract.appendChild( abstractText );
529 metadataElement.appendChild(
abstract );
532 QMapIterator<QString, QStringList> i( mKeywords );
533 while ( i.hasNext() )
536 QDomElement keywordsElement = document.createElement( QStringLiteral(
"keywords" ) );
537 keywordsElement.setAttribute( QStringLiteral(
"vocabulary" ), i.key() );
538 const QStringList values = i.value();
539 for (
const QString &kw : values )
541 QDomElement keyword = document.createElement( QStringLiteral(
"keyword" ) );
542 QDomText keywordText = document.createTextNode( kw );
543 keyword.appendChild( keywordText );
544 keywordsElement.appendChild( keyword );
546 metadataElement.appendChild( keywordsElement );
550 QDomElement
fees = document.createElement( QStringLiteral(
"fees" ) );
551 QDomText feesText = document.createTextNode( mFees );
552 fees.appendChild( feesText );
553 metadataElement.appendChild( fees );
558 QDomElement constraintElement = document.createElement( QStringLiteral(
"constraints" ) );
559 constraintElement.setAttribute( QStringLiteral(
"type" ), constraint.type );
560 QDomText constraintText = document.createTextNode( constraint.constraint );
561 constraintElement.appendChild( constraintText );
562 metadataElement.appendChild( constraintElement );
566 for (
const QString &right : mRights )
568 QDomElement rightElement = document.createElement( QStringLiteral(
"rights" ) );
569 QDomText rightText = document.createTextNode( right );
570 rightElement.appendChild( rightText );
571 metadataElement.appendChild( rightElement );
575 for (
const QString &license : mLicenses )
577 QDomElement licenseElement = document.createElement( QStringLiteral(
"license" ) );
578 QDomText licenseText = document.createTextNode( license );
579 licenseElement.appendChild( licenseText );
580 metadataElement.appendChild( licenseElement );
584 QDomElement
encoding = document.createElement( QStringLiteral(
"encoding" ) );
585 QDomText encodingText = document.createTextNode( mEncoding );
586 encoding.appendChild( encodingText );
587 metadataElement.appendChild( encoding );
590 QDomElement crsElement = document.createElement( QStringLiteral(
"crs" ) );
591 mCrs.
writeXml( crsElement, document );
592 metadataElement.appendChild( crsElement );
595 QDomElement extentElement = document.createElement( QStringLiteral(
"extent" ) );
601 QDomElement spatialElement = document.createElement( QStringLiteral(
"spatial" ) );
603 spatialElement.setAttribute( QStringLiteral(
"dimensions" ), QStringLiteral(
"2" ) );
604 spatialElement.setAttribute( QStringLiteral(
"crs" ), spatialExtent.extentCrs.authid() );
605 spatialElement.setAttribute( QStringLiteral(
"minx" ),
qgsDoubleToString( spatialExtent.bounds.xMinimum() ) );
606 spatialElement.setAttribute( QStringLiteral(
"miny" ),
qgsDoubleToString( spatialExtent.bounds.yMinimum() ) );
607 spatialElement.setAttribute( QStringLiteral(
"minz" ),
qgsDoubleToString( spatialExtent.bounds.zMinimum() ) );
608 spatialElement.setAttribute( QStringLiteral(
"maxx" ),
qgsDoubleToString( spatialExtent.bounds.xMaximum() ) );
609 spatialElement.setAttribute( QStringLiteral(
"maxy" ),
qgsDoubleToString( spatialExtent.bounds.yMaximum() ) );
610 spatialElement.setAttribute( QStringLiteral(
"maxz" ),
qgsDoubleToString( spatialExtent.bounds.zMaximum() ) );
611 extentElement.appendChild( spatialElement );
616 for (
const QgsDateTimeRange &temporalExtent : tExtents )
618 QDomElement temporalElement = document.createElement( QStringLiteral(
"temporal" ) );
619 if ( temporalExtent.isInstant() )
621 QDomElement instantElement = document.createElement( QStringLiteral(
"instant" ) );
622 QDomText instantText = document.createTextNode( temporalExtent.begin().toTimeSpec( Qt::OffsetFromUTC ).toString( Qt::ISODate ) );
623 instantElement.appendChild( instantText );
624 temporalElement.appendChild( instantElement );
628 QDomElement periodElement = document.createElement( QStringLiteral(
"period" ) );
629 QDomElement startElement = document.createElement( QStringLiteral(
"start" ) );
630 QDomElement endElement = document.createElement( QStringLiteral(
"end" ) );
631 QDomText startText = document.createTextNode( temporalExtent.begin().toTimeSpec( Qt::OffsetFromUTC ).toString( Qt::ISODate ) );
632 QDomText endText = document.createTextNode( temporalExtent.end().toTimeSpec( Qt::OffsetFromUTC ).toString( Qt::ISODate ) );
633 startElement.appendChild( startText );
634 endElement.appendChild( endText );
635 periodElement.appendChild( startElement );
636 periodElement.appendChild( endElement );
637 temporalElement.appendChild( periodElement );
639 extentElement.appendChild( temporalElement );
642 metadataElement.appendChild( extentElement );
647 QDomElement contactElement = document.createElement( QStringLiteral(
"contact" ) );
648 QDomElement nameElement = document.createElement( QStringLiteral(
"name" ) );
649 QDomElement organizationElement = document.createElement( QStringLiteral(
"organization" ) );
650 QDomElement positionElement = document.createElement( QStringLiteral(
"position" ) );
651 QDomElement voiceElement = document.createElement( QStringLiteral(
"voice" ) );
652 QDomElement faxElement = document.createElement( QStringLiteral(
"fax" ) );
653 QDomElement emailElement = document.createElement( QStringLiteral(
"email" ) );
654 QDomElement roleElement = document.createElement( QStringLiteral(
"role" ) );
656 QDomText nameText = document.createTextNode( contact.name );
657 QDomText orgaText = document.createTextNode( contact.organization );
658 QDomText positionText = document.createTextNode( contact.position );
659 QDomText voiceText = document.createTextNode( contact.voice );
660 QDomText faxText = document.createTextNode( contact.fax );
661 QDomText emailText = document.createTextNode( contact.email );
662 QDomText roleText = document.createTextNode( contact.role );
666 QDomElement addressElement = document.createElement( QStringLiteral(
"contactAddress" ) );
667 QDomElement typeElement = document.createElement( QStringLiteral(
"type" ) );
668 QDomElement addressDetailedElement = document.createElement( QStringLiteral(
"address" ) );
669 QDomElement cityElement = document.createElement( QStringLiteral(
"city" ) );
670 QDomElement administrativeAreaElement = document.createElement( QStringLiteral(
"administrativearea" ) );
671 QDomElement postalCodeElement = document.createElement( QStringLiteral(
"postalcode" ) );
672 QDomElement countryElement = document.createElement( QStringLiteral(
"country" ) );
674 typeElement.appendChild( document.createTextNode( oneAddress.
type ) );
675 addressDetailedElement.appendChild( document.createTextNode( oneAddress.
address ) );
676 cityElement.appendChild( document.createTextNode( oneAddress.
city ) );
677 administrativeAreaElement.appendChild( document.createTextNode( oneAddress.
administrativeArea ) );
678 postalCodeElement.appendChild( document.createTextNode( oneAddress.
postalCode ) );
679 countryElement.appendChild( document.createTextNode( oneAddress.
country ) );
681 addressElement.appendChild( typeElement );
682 addressElement.appendChild( addressDetailedElement );
683 addressElement.appendChild( cityElement );
684 addressElement.appendChild( administrativeAreaElement );
685 addressElement.appendChild( postalCodeElement );
686 addressElement.appendChild( countryElement );
687 contactElement.appendChild( addressElement );
690 nameElement.appendChild( nameText );
691 organizationElement.appendChild( orgaText );
692 positionElement.appendChild( positionText );
693 voiceElement.appendChild( voiceText );
694 faxElement.appendChild( faxText );
695 emailElement.appendChild( emailText );
696 roleElement.appendChild( roleText );
698 contactElement.appendChild( nameElement );
699 contactElement.appendChild( organizationElement );
700 contactElement.appendChild( positionElement );
701 contactElement.appendChild( voiceElement );
702 contactElement.appendChild( faxElement );
703 contactElement.appendChild( emailElement );
704 contactElement.appendChild( roleElement );
705 metadataElement.appendChild( contactElement );
709 QDomElement
links = document.createElement( QStringLiteral(
"links" ) );
712 QDomElement linkElement = document.createElement( QStringLiteral(
"link" ) );
713 linkElement.setAttribute( QStringLiteral(
"name" ), link.name );
714 linkElement.setAttribute( QStringLiteral(
"type" ), link.type );
715 linkElement.setAttribute( QStringLiteral(
"url" ), link.url );
716 linkElement.setAttribute( QStringLiteral(
"description" ), link.description );
717 linkElement.setAttribute( QStringLiteral(
"format" ), link.format );
718 linkElement.setAttribute( QStringLiteral(
"mimeType" ), link.mimeType );
719 linkElement.setAttribute( QStringLiteral(
"size" ), link.size );
720 links.appendChild( linkElement );
722 metadataElement.appendChild( links );
725 for (
const QString &
history : mHistory )
727 QDomElement historyElement = document.createElement( QStringLiteral(
"history" ) );
728 QDomText historyText = document.createTextNode(
history );
729 historyElement.appendChild( historyText );
730 metadataElement.appendChild( historyElement );
753 return mSpatialExtents;
758 mSpatialExtents = spatialExtents;
763 return mTemporalExtents;
768 mTemporalExtents = temporalExtents;
773 return mSpatialExtents == other.mSpatialExtents && mTemporalExtents == other.mTemporalExtents;
778 return ( ( mIdentifier == metadataOther.mIdentifier ) &&
779 ( mParentIdentifier == metadataOther.mParentIdentifier ) &&
780 ( mLanguage == metadataOther.mLanguage ) &&
781 ( mType == metadataOther.mType ) &&
782 ( mTitle == metadataOther.mTitle ) &&
783 ( mAbstract == metadataOther.mAbstract ) &&
784 ( mFees == metadataOther.mFees ) &&
785 ( mConstraints == metadataOther.mConstraints ) &&
786 ( mRights == metadataOther.mRights ) &&
787 ( mLicenses == metadataOther.mLicenses ) &&
788 ( mHistory == metadataOther.mHistory ) &&
789 ( mEncoding == metadataOther.mEncoding ) &&
790 ( mCrs == metadataOther.mCrs ) &&
791 ( mExtent == metadataOther.mExtent ) &&
792 ( mKeywords == metadataOther.mKeywords ) &&
793 ( mContacts == metadataOther.mContacts ) &&
794 ( mLinks == metadataOther.mLinks ) );
810 return name == other.
name &&
814 voice == other.
voice &&
816 email == other.
email &&
822 return name == other.
name &&
835 city == other.
city &&
Base class for all map layer types.
void setXMinimum(double x)
Sets the minimum x value.
void setCustomProperty(const QString &key, const QVariant &value)
Set a custom property for layer.
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.
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).
bool readXml(const QDomNode &node)
Restores state from the given DOM node.
QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
bool writeXml(QDomNode &node, QDomDocument &doc) const
Stores state to the given Dom node in the given document.
QString authid() const
Returns the authority identifier for the CRS.
void setZMaximum(double z)
Sets the maximum z value.