QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
qgsmetadatautils.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsmetadatautils.cpp
3 -------------------
4 begin : April 2021
5 copyright : (C) 2021 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#include "qgsmetadatautils.h"
19#include "qgslayermetadata.h"
20
21#include <QDomDocument>
22#include <QTextDocumentFragment>
23
25{
26 QgsLayerMetadata metadata;
27 const QDomElement metadataElem = document.firstChildElement( QStringLiteral( "metadata" ) );
28
29 const QDomElement esri = metadataElem.firstChildElement( QStringLiteral( "Esri" ) );
30 const QDomElement dataProperties = esri.firstChildElement( QStringLiteral( "DataProperties" ) );
31 const QDomElement itemProps = dataProperties.firstChildElement( QStringLiteral( "itemProps" ) );
32 metadata.setIdentifier( itemProps.firstChildElement( QStringLiteral( "itemName" ) ).text() );
33
34 const QDomElement dataIdInfo = metadataElem.firstChildElement( QStringLiteral( "dataIdInfo" ) );
35 const QDomElement idInfo = metadataElem.firstChildElement( QStringLiteral( "idinfo" ) );
36
37 // title
38 const QDomElement idCitation = dataIdInfo.firstChildElement( QStringLiteral( "idCitation" ) );
39 const QString title = idCitation.firstChildElement( QStringLiteral( "resTitle" ) ).text();
40 metadata.setTitle( title );
41
42 // if no explicit identifier we use the title
43 if ( metadata.identifier().isEmpty() && !title.isEmpty() )
44 metadata.setIdentifier( title );
45
46 const QDomElement citationDatesElement = idCitation.firstChildElement( QStringLiteral( "date" ) ).toElement();
47 if ( !citationDatesElement.isNull() )
48 {
49 {
50 const QDomElement createDateElement = citationDatesElement.firstChildElement( QStringLiteral( "createDate" ) ).toElement();
51 if ( !createDateElement.isNull() )
52 {
53 metadata.setDateTime( Qgis::MetadataDateType::Created, QDateTime::fromString( createDateElement.text(), Qt::ISODate ) );
54 }
55 }
56 {
57 const QDomElement pubDateElement = citationDatesElement.firstChildElement( QStringLiteral( "pubDate" ) ).toElement();
58 if ( !pubDateElement.isNull() )
59 {
60 metadata.setDateTime( Qgis::MetadataDateType::Published, QDateTime::fromString( pubDateElement.text(), Qt::ISODate ) );
61 }
62 }
63 {
64 const QDomElement reviseDateElement = citationDatesElement.firstChildElement( QStringLiteral( "reviseDate" ) ).toElement();
65 if ( !reviseDateElement.isNull() )
66 {
67 metadata.setDateTime( Qgis::MetadataDateType::Revised, QDateTime::fromString( reviseDateElement.text(), Qt::ISODate ) );
68 }
69 }
70 {
71 const QDomElement supersededDateElement = citationDatesElement.firstChildElement( QStringLiteral( "supersDate" ) ).toElement();
72 if ( !supersededDateElement.isNull() )
73 {
74 metadata.setDateTime( Qgis::MetadataDateType::Superseded, QDateTime::fromString( supersededDateElement.text(), Qt::ISODate ) );
75 }
76 }
77 }
78
79 // abstract
80 const QDomElement idAbs = dataIdInfo.firstChildElement( QStringLiteral( "idAbs" ) );
81 const QString abstractPlainText = QTextDocumentFragment::fromHtml( idAbs.text() ).toPlainText();
82 metadata.setAbstract( abstractPlainText );
83
84 // purpose
85 const QDomElement idPurp = dataIdInfo.firstChildElement( QStringLiteral( "idPurp" ) );
86 const QString purposePlainText = QTextDocumentFragment::fromHtml( idPurp.text() ).toPlainText();
87 if ( !metadata.abstract().isEmpty() )
88 metadata.setAbstract( metadata.abstract() + QStringLiteral( "\n\n" ) + purposePlainText );
89 else
90 metadata.setAbstract( purposePlainText );
91
92 // older metadata format used "descript" element instead
93 const QDomElement descript = idInfo.firstChildElement( QStringLiteral( "descript" ) );
94 if ( !descript.isNull() )
95 {
96 const QDomElement abstract = descript.firstChildElement( QStringLiteral( "abstract" ) );
97 const QString abstractPlainText = QTextDocumentFragment::fromHtml( abstract.text() ).toPlainText();
98 if ( !abstractPlainText.isEmpty() )
99 {
100 if ( !metadata.abstract().isEmpty() )
101 metadata.setAbstract( metadata.abstract() + QStringLiteral( "\n\n" ) + abstractPlainText );
102 else
103 metadata.setAbstract( abstractPlainText );
104 }
105
106 const QDomElement purpose = descript.firstChildElement( QStringLiteral( "purpose" ) );
107 const QString purposePlainText = QTextDocumentFragment::fromHtml( purpose.text() ).toPlainText();
108 if ( !purposePlainText.isEmpty() )
109 {
110 if ( !metadata.abstract().isEmpty() )
111 metadata.setAbstract( metadata.abstract() + QStringLiteral( "\n\n" ) + purposePlainText );
112 else
113 metadata.setAbstract( purposePlainText );
114 }
115
116 const QDomElement supplinf = descript.firstChildElement( QStringLiteral( "supplinf" ) );
117 const QString supplinfPlainText = QTextDocumentFragment::fromHtml( supplinf.text() ).toPlainText();
118 if ( !supplinfPlainText.isEmpty() )
119 {
120 if ( !metadata.abstract().isEmpty() )
121 metadata.setAbstract( metadata.abstract() + QStringLiteral( "\n\n" ) + supplinfPlainText );
122 else
123 metadata.setAbstract( supplinfPlainText );
124 }
125 }
126
127 // supplementary info
128 const QDomElement suppInfo = dataIdInfo.firstChildElement( QStringLiteral( "suppInfo" ) );
129 const QString suppInfoPlainText = QTextDocumentFragment::fromHtml( suppInfo.text() ).toPlainText();
130 if ( !suppInfoPlainText.isEmpty() )
131 {
132 if ( !metadata.abstract().isEmpty() )
133 metadata.setAbstract( metadata.abstract() + QStringLiteral( "\n\n" ) + suppInfoPlainText );
134 else
135 metadata.setAbstract( suppInfoPlainText );
136 }
137
138 // language
139 const QDomElement dataLang = dataIdInfo.firstChildElement( QStringLiteral( "dataLang" ) );
140 const QDomElement languageCode = dataLang.firstChildElement( QStringLiteral( "languageCode" ) );
141 const QString language = languageCode.attribute( QStringLiteral( "value" ) ).toUpper();
142 metadata.setLanguage( language );
143
144 // keywords
145 QDomElement searchKeys = dataIdInfo.firstChildElement( QStringLiteral( "searchKeys" ) );
146 QStringList keywords;
147 while ( !searchKeys.isNull() )
148 {
149 QDomElement keyword = searchKeys.firstChildElement( QStringLiteral( "keyword" ) );
150 while ( !keyword.isNull() )
151 {
152 keywords << keyword.text();
153 keyword = keyword.nextSiblingElement( QStringLiteral( "keyword" ) );
154 }
155
156 searchKeys = searchKeys.nextSiblingElement( QStringLiteral( "searchKeys" ) );
157 }
158
159 // categories
160 QDomElement themeKeys = dataIdInfo.firstChildElement( QStringLiteral( "themeKeys" ) );
161 QStringList categories;
162 while ( !themeKeys.isNull() )
163 {
164 const QDomElement thesaName = themeKeys.firstChildElement( QStringLiteral( "thesaName" ) );
165 const QString thesaTitle = thesaName.firstChildElement( QStringLiteral( "resTitle" ) ).text();
166
167 const bool isSearchKeyWord = thesaTitle.compare( QLatin1String( "Common Search Terms" ), Qt::CaseInsensitive ) == 0;
168
169 QDomElement themeKeyword = themeKeys.firstChildElement( QStringLiteral( "keyword" ) );
170 while ( !themeKeyword.isNull() )
171 {
172 if ( isSearchKeyWord )
173 {
174 keywords.append( themeKeyword.text().split( ',' ) );
175 }
176 else
177 {
178 categories << themeKeyword.text();
179 }
180 themeKeyword = themeKeyword.nextSiblingElement( QStringLiteral( "keyword" ) );
181 }
182 themeKeys = themeKeys.nextSiblingElement( QStringLiteral( "themeKeys" ) );
183 }
184
185 // older xml format
186 QDomElement keywordsElem = idInfo.firstChildElement( QStringLiteral( "keywords" ) );
187 while ( !keywordsElem.isNull() )
188 {
189 QDomElement theme = keywordsElem.firstChildElement( QStringLiteral( "theme" ) );
190 while ( !theme.isNull() )
191 {
192 categories << theme.firstChildElement( QStringLiteral( "themekey" ) ).text();
193 theme = theme.nextSiblingElement( QStringLiteral( "theme" ) );
194 }
195
196 keywordsElem = keywordsElem.nextSiblingElement( QStringLiteral( "keywords" ) );
197 }
198
199 if ( !categories.isEmpty() )
200 metadata.setCategories( categories );
201
202 if ( !keywords.empty() )
203 metadata.addKeywords( QObject::tr( "Search keys" ), keywords );
204
206
207 // pubDate
208 const QDomElement date = idCitation.firstChildElement( QStringLiteral( "date" ) );
209 const QString pubDate = date.firstChildElement( QStringLiteral( "pubDate" ) ).text();
210 const QDateTime publicationDate = QDateTime::fromString( pubDate, Qt::ISODate );
211 if ( publicationDate.isValid() )
212 {
213 extent.setTemporalExtents( { publicationDate, QDateTime() } );
214 }
215 else
216 {
217 // older XML format
218 QDomElement timeperd = idInfo.firstChildElement( QStringLiteral( "timeperd" ) );
219 while ( !timeperd.isNull() )
220 {
221 if ( timeperd.firstChildElement( QStringLiteral( "current" ) ).text().compare( QLatin1String( "publication date" ) ) == 0 )
222 {
223 const QDomElement timeinfo = timeperd.firstChildElement( QStringLiteral( "timeinfo" ) );
224 const QDomElement sngdate = timeinfo.firstChildElement( QStringLiteral( "sngdate" ) );
225 if ( !sngdate.isNull() )
226 {
227 const QDomElement caldate = sngdate.firstChildElement( QStringLiteral( "caldate" ) );
228 const QString caldateString = caldate.text();
229 const QDateTime publicationDate = QDateTime::fromString( caldateString, QStringLiteral( "MMMM yyyy" ) );
230 if ( publicationDate.isValid() )
231 {
232 extent.setTemporalExtents( { publicationDate, QDateTime() } );
233 break;
234 }
235 }
236 const QDomElement rngdates = timeinfo.firstChildElement( QStringLiteral( "rngdates" ) );
237 if ( !rngdates.isNull() )
238 {
239 const QDomElement begdate = rngdates.firstChildElement( QStringLiteral( "begdate" ) );
240 const QDomElement enddate = rngdates.firstChildElement( QStringLiteral( "enddate" ) );
241 const QString begdateString = begdate.text();
242 const QString enddateString = enddate.text();
243 QDateTime begin;
244 QDateTime end;
245 for ( const QString format : { "yyyy-MM-dd", "dd/MM/yyyy" } )
246 {
247 if ( !begin.isValid() )
248 begin = QDateTime::fromString( begdateString, format );
249 if ( !end.isValid() )
250 end = QDateTime::fromString( enddateString, format );
251 }
252
253 if ( begin.isValid() || end.isValid() )
254 {
255 extent.setTemporalExtents( {QgsDateTimeRange{ begin, end } } );
256 break;
257 }
258 }
259 }
260
261 timeperd = timeperd.nextSiblingElement( QStringLiteral( "timeperd" ) );
262 }
263 }
264
265 //crs
267 QDomElement refSysInfo = metadataElem.firstChildElement( QStringLiteral( "refSysInfo" ) );
268 while ( !refSysInfo.isNull() )
269 {
270 const QDomElement refSystem = refSysInfo.firstChildElement( QStringLiteral( "RefSystem" ) );
271 const QDomElement refSysID = refSystem.firstChildElement( QStringLiteral( "refSysID" ) );
272 const QDomElement identAuth = refSysID.firstChildElement( QStringLiteral( "identAuth" ) );
273 if ( !identAuth.isNull() )
274 {
275 if ( identAuth.firstChildElement( QStringLiteral( "resTitle" ) ).text().compare( QLatin1String( "EPSG Geodetic Parameter Dataset" ) ) == 0 )
276 {
277 const QString code = refSysID.firstChildElement( QStringLiteral( "identCode" ) ).attribute( QStringLiteral( "code" ) );
279 }
280 }
281 else
282 {
283 const QString code = refSysID.firstChildElement( QStringLiteral( "identCode" ) ).attribute( QStringLiteral( "code" ) );
284 const QString auth = refSysID.firstChildElement( QStringLiteral( "idCodeSpace" ) ).text();
285 crs = QgsCoordinateReferenceSystem( QStringLiteral( "%1:%2" ).arg( auth, code ) );
286 }
287
288 if ( crs.isValid() )
289 {
290 metadata.setCrs( crs );
291 break;
292 }
293 refSysInfo = refSysInfo.nextSiblingElement( QStringLiteral( "refSysInfo" ) );
294 }
295
296 // extent
297 QDomElement dataExt = dataIdInfo.firstChildElement( QStringLiteral( "dataExt" ) );
298 while ( !dataExt.isNull() )
299 {
300 const QDomElement geoEle = dataExt.firstChildElement( QStringLiteral( "geoEle" ) );
301 if ( !geoEle.isNull() )
302 {
303 const QDomElement geoBndBox = geoEle.firstChildElement( QStringLiteral( "GeoBndBox" ) );
304 const double west = geoBndBox.firstChildElement( QStringLiteral( "westBL" ) ).text().toDouble();
305 const double east = geoBndBox.firstChildElement( QStringLiteral( "eastBL" ) ).text().toDouble();
306 const double south = geoBndBox.firstChildElement( QStringLiteral( "northBL" ) ).text().toDouble();
307 const double north = geoBndBox.firstChildElement( QStringLiteral( "southBL" ) ).text().toDouble();
308
310 spatialExtent.extentCrs = crs.isValid() ? crs : QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) );
311 spatialExtent.bounds = QgsBox3D( west, south, 0, east, north, 0 );
312
313 extent.setSpatialExtents( { spatialExtent } );
314 break;
315 }
316 dataExt = dataExt.nextSiblingElement( QStringLiteral( "dataExt" ) );
317 }
318
319 metadata.setExtent( extent );
320
321 // licenses, constraints
322 QStringList licenses;
323 QStringList rights;
325 QDomElement resConst = dataIdInfo.firstChildElement( QStringLiteral( "resConst" ) );
326 while ( !resConst.isNull() )
327 {
328 QDomElement legConsts = resConst.firstChildElement( QStringLiteral( "LegConsts" ) );
329 while ( !legConsts.isNull() )
330 {
331 const QString restrictCd = legConsts.firstChildElement( QStringLiteral( "useConsts" ) ).firstChildElement( QStringLiteral( "RestrictCd" ) ).attribute( QStringLiteral( "value" ) );
332
333 if ( restrictCd.compare( QLatin1String( "005" ) ) == 0 )
334 {
335 licenses << QTextDocumentFragment::fromHtml( legConsts.firstChildElement( QStringLiteral( "useLimit" ) ).text() ).toPlainText();
336 }
337 else if ( restrictCd.compare( QLatin1String( "006" ) ) == 0 )
338 {
339 rights << QTextDocumentFragment::fromHtml( legConsts.firstChildElement( QStringLiteral( "useLimit" ) ).text() ).toPlainText();
340 }
341 legConsts = legConsts.nextSiblingElement( QStringLiteral( "LegConsts" ) );
342 }
343
344 QDomElement secConsts = resConst.firstChildElement( QStringLiteral( "SecConsts" ) );
345 while ( !secConsts.isNull() )
346 {
348 constraint.type = QObject::tr( "Security constraints" );
349 constraint.constraint = QTextDocumentFragment::fromHtml( secConsts.firstChildElement( QStringLiteral( "userNote" ) ).text() ).toPlainText();
350 constraints << constraint;
351 secConsts = secConsts.nextSiblingElement( QStringLiteral( "SecConsts" ) );
352 }
353
354 QDomElement consts = resConst.firstChildElement( QStringLiteral( "Consts" ) );
355 while ( !consts.isNull() )
356 {
358 constraint.type = QObject::tr( "Limitations of use" );
359 constraint.constraint = QTextDocumentFragment::fromHtml( consts.firstChildElement( QStringLiteral( "useLimit" ) ).text() ).toPlainText();
360 constraints << constraint;
361 consts = consts.nextSiblingElement( QStringLiteral( "Consts" ) );
362 }
363
364 resConst = resConst.nextSiblingElement( QStringLiteral( "resConst" ) );
365 }
366
367 const QDomElement idCredit = dataIdInfo.firstChildElement( QStringLiteral( "idCredit" ) );
368 const QString credit = idCredit.text();
369 if ( !credit.isEmpty() )
370 rights << credit;
371
372 // older xml format
373 QDomElement accconst = idInfo.firstChildElement( QStringLiteral( "accconst" ) );
374 while ( !accconst.isNull() )
375 {
377 constraint.type = QObject::tr( "Access" );
378 constraint.constraint = QTextDocumentFragment::fromHtml( accconst.text() ).toPlainText();
379 constraints << constraint;
380
381 accconst = accconst.nextSiblingElement( QStringLiteral( "accconst" ) );
382 }
383 QDomElement useconst = idInfo.firstChildElement( QStringLiteral( "useconst" ) );
384 while ( !useconst.isNull() )
385 {
386 rights << QTextDocumentFragment::fromHtml( useconst.text() ).toPlainText();
387 useconst = useconst.nextSiblingElement( QStringLiteral( "useconst" ) );
388 }
389
390 metadata.setLicenses( licenses );
391 metadata.setRights( rights );
392 metadata.setConstraints( constraints );
393
394 // links
395 const QDomElement distInfo = metadataElem.firstChildElement( QStringLiteral( "distInfo" ) );
396 const QDomElement distributor = distInfo.firstChildElement( QStringLiteral( "distributor" ) );
397
398 QDomElement distorTran = distributor.firstChildElement( QStringLiteral( "distorTran" ) );
399 while ( !distorTran.isNull() )
400 {
401 const QDomElement onLineSrc = distorTran.firstChildElement( QStringLiteral( "onLineSrc" ) );
402 if ( !onLineSrc.isNull() )
403 {
405 link.url = onLineSrc.firstChildElement( QStringLiteral( "linkage" ) ).text();
406
407 const QDomElement distorFormat = distributor.firstChildElement( QStringLiteral( "distorFormat" ) );
408 link.name = distorFormat.firstChildElement( QStringLiteral( "formatName" ) ).text();
409 link.type = distorFormat.firstChildElement( QStringLiteral( "formatSpec" ) ).text();
410
411 if ( link.type.isEmpty() )
412 {
413 // older xml format
414 link.type = onLineSrc.firstChildElement( QStringLiteral( "protocol" ) ).text();
415 }
416 metadata.addLink( link );
417 }
418
419 distorTran = distorTran.nextSiblingElement( QStringLiteral( "distorTran" ) );
420 }
421
422 // lineage
423 const QDomElement dqInfo = metadataElem.firstChildElement( QStringLiteral( "dqInfo" ) );
424 const QDomElement dataLineage = dqInfo.firstChildElement( QStringLiteral( "dataLineage" ) );
425 const QString statement = QTextDocumentFragment::fromHtml( dataLineage.firstChildElement( QStringLiteral( "statement" ) ).text() ).toPlainText();
426 if ( !statement.isEmpty() )
427 metadata.addHistoryItem( statement );
428
429 QDomElement dataSource = dataLineage.firstChildElement( QStringLiteral( "dataSource" ) );
430 while ( !dataSource.isNull() )
431 {
432 metadata.addHistoryItem( QObject::tr( "Data source: %1" ).arg( QTextDocumentFragment::fromHtml( dataSource.firstChildElement( QStringLiteral( "srcDesc" ) ).text() ).toPlainText() ) );
433 dataSource = dataSource.nextSiblingElement( QStringLiteral( "dataSource" ) );
434 }
435
436 // contacts
437 const QDomElement mdContact = metadataElem.firstChildElement( QStringLiteral( "mdContact" ) );
438 if ( !mdContact.isNull() )
439 {
441 contact.name = mdContact.firstChildElement( QStringLiteral( "rpIndName" ) ).text();
442 contact.organization = mdContact.firstChildElement( QStringLiteral( "rpOrgName" ) ).text();
443 contact.position = mdContact.firstChildElement( QStringLiteral( "rpPosName" ) ).text();
444
445 const QString role = mdContact.firstChildElement( QStringLiteral( "role" ) ).firstChildElement( QStringLiteral( "RoleCd" ) ).attribute( QStringLiteral( "value" ) );
446 if ( role == QLatin1String( "007" ) )
447 contact.role = QObject::tr( "Point of contact" );
448
449 const QDomElement rpCntInfo = mdContact.firstChildElement( QStringLiteral( "rpCntInfo" ) );
450 contact.email = rpCntInfo.firstChildElement( QStringLiteral( "cntAddress" ) ).firstChildElement( QStringLiteral( "eMailAdd" ) ).text();
451 contact.voice = rpCntInfo.firstChildElement( QStringLiteral( "cntPhone" ) ).firstChildElement( QStringLiteral( "voiceNum" ) ).text();
452
453 QDomElement cntAddress = rpCntInfo.firstChildElement( QStringLiteral( "cntAddress" ) );
454 while ( !cntAddress.isNull() )
455 {
457
458 address.type = cntAddress.attribute( QStringLiteral( "addressType" ) );
459 address.address = cntAddress.firstChildElement( QStringLiteral( "delPoint" ) ).text();
460 address.city = cntAddress.firstChildElement( QStringLiteral( "city" ) ).text();
461 address.administrativeArea = cntAddress.firstChildElement( QStringLiteral( "adminArea" ) ).text();
462 address.postalCode = cntAddress.firstChildElement( QStringLiteral( "postCode" ) ).text();
463 address.country = cntAddress.firstChildElement( QStringLiteral( "country" ) ).text();
464
465 contact.addresses.append( address );
466
467 cntAddress = cntAddress.nextSiblingElement( QStringLiteral( "cntAddress" ) );
468 }
469
470
471 metadata.addContact( contact );
472 }
473
474 // older xml format
475 const QDomElement ptcontac = idInfo.firstChildElement( QStringLiteral( "ptcontac" ) );
476 const QDomElement cntinfo = ptcontac.firstChildElement( QStringLiteral( "cntinfo" ) );
477 if ( !cntinfo.isNull() )
478 {
480 const QDomElement cntorgp = cntinfo.firstChildElement( QStringLiteral( "cntorgp" ) );
481 const QString org = cntorgp.firstChildElement( QStringLiteral( "cntorg" ) ).text();
482
483 contact.name = org;
484 contact.organization = org;
485 contact.role = QObject::tr( "Point of contact" );
486
487 const QDomElement rpCntInfo = mdContact.firstChildElement( QStringLiteral( "rpCntInfo" ) );
488 contact.email = cntinfo.firstChildElement( QStringLiteral( "cntemail" ) ).text();
489 contact.fax = cntinfo.firstChildElement( QStringLiteral( "cntfax" ) ).text();
490 contact.voice = cntinfo.firstChildElement( QStringLiteral( "cntvoice" ) ).text();
491
492 QDomElement cntaddr = cntinfo.firstChildElement( QStringLiteral( "cntaddr" ) );
493 while ( !cntaddr.isNull() )
494 {
496
497 QDomElement addressElem = cntaddr.firstChildElement( QStringLiteral( "address" ) );
498 while ( !addressElem.isNull() )
499 {
500 const QString addressPart = addressElem.text();
501 address.address = address.address.isEmpty() ? addressPart : address.address + '\n' + addressPart;
502 addressElem = addressElem.nextSiblingElement( QStringLiteral( "address" ) );
503 }
504 address.type = cntaddr.firstChildElement( QStringLiteral( "addrtype" ) ).text();
505 address.city = cntaddr.firstChildElement( QStringLiteral( "city" ) ).text();
506 address.administrativeArea = cntaddr.firstChildElement( QStringLiteral( "state" ) ).text();
507 address.postalCode = cntaddr.firstChildElement( QStringLiteral( "postal" ) ).text();
508 address.country = cntaddr.firstChildElement( QStringLiteral( "country" ) ).text();
509
510 contact.addresses.append( address );
511
512 cntaddr = cntaddr.nextSiblingElement( QStringLiteral( "cntaddr" ) );
513 }
514
515 metadata.addContact( contact );
516 }
517
518 return metadata;
519}
@ Created
Date created.
@ Published
Date published.
@ Superseded
Date superseded.
@ Revised
Date revised.
void setAbstract(const QString &abstract)
Sets a free-form abstract (description) of the resource.
void addContact(const QgsAbstractMetadataBase::Contact &contact)
Adds an individual contact to the existing contacts.
void setTitle(const QString &title)
Sets the human readable title (name) of the resource, typically displayed in search results.
void setIdentifier(const QString &identifier)
Sets the reference, URI, URL or some other mechanism to identify the resource.
QString abstract() const
Returns a free-form description of the resource.
void setDateTime(Qgis::MetadataDateType type, QDateTime date)
Sets a date value for the specified date type.
void setLanguage(const QString &language)
Sets the human language associated with the resource.
void addKeywords(const QString &vocabulary, const QStringList &keywords)
Adds a list of descriptive keywords for a specified vocabulary.
void addLink(const QgsAbstractMetadataBase::Link &link)
Adds an individual link to the existing links.
QString identifier() const
A reference, URI, URL or some other mechanism to identify the resource.
void setCategories(const QStringList &categories)
Sets categories of the resource.
void addHistoryItem(const QString &text)
Adds a single history text to the end of the existing history list.
A 3-dimensional box composed of x, y, z coordinates.
Definition qgsbox3d.h:43
This class represents a coordinate reference system (CRS).
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
A structured metadata store for a map layer.
void setConstraints(const QgsLayerMetadata::ConstraintList &constraints)
Sets the list of constraints associated with using the resource.
void setLicenses(const QStringList &licenses)
Sets a list of licenses associated with the resource.
void setRights(const QStringList &rights)
Sets a list of rights (attribution or copyright strings) associated with the resource.
void setExtent(const QgsLayerMetadata::Extent &extent)
Sets the spatial and temporal extents associated with the resource.
QList< QgsLayerMetadata::Constraint > ConstraintList
A list of constraints.
void setCrs(const QgsCoordinateReferenceSystem &crs)
Sets the coordinate reference system for the layer's metadata.
static QgsLayerMetadata convertFromEsri(const QDomDocument &document)
Converts ESRI layer metadata to QgsLayerMetadata.
const QgsCoordinateReferenceSystem & crs
QString administrativeArea
Administrative area (state, province/territory, etc.).
QString address
Free-form physical address component, e.g.
QString city
City or locality name.
QString country
Free-form country string.
QString postalCode
Postal (or ZIP) code.
QString position
Position/title of contact.
QList< QgsAbstractMetadataBase::Address > addresses
List of addresses associated with this contact.
QString email
Electronic mail address.
QString organization
Organization contact belongs to/represents.
Metadata constraint structure.
QString constraint
Free-form constraint string.
QString type
Constraint type.
Metadata extent structure.
void setSpatialExtents(const QList< QgsLayerMetadata::SpatialExtent > &extents)
Sets the spatial extents of the resource.
void setTemporalExtents(const QList< QgsDateTimeRange > &extents)
Sets the temporal extents of the resource.
Metadata spatial extent structure.
QgsCoordinateReferenceSystem extentCrs
Coordinate reference system for spatial extent.
QgsBox3D bounds
Geospatial extent of the resource.