QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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
20#include "qgslayermetadata.h"
21
22#include <QDomDocument>
23#include <QTextDocumentFragment>
24
26{
27 QgsLayerMetadata metadata;
28 const QDomElement metadataElem = document.firstChildElement( QStringLiteral( "metadata" ) );
29
30 const QDomElement esri = metadataElem.firstChildElement( QStringLiteral( "Esri" ) );
31 const QDomElement dataProperties = esri.firstChildElement( QStringLiteral( "DataProperties" ) );
32 const QDomElement itemProps = dataProperties.firstChildElement( QStringLiteral( "itemProps" ) );
33 metadata.setIdentifier( itemProps.firstChildElement( QStringLiteral( "itemName" ) ).text() );
34
35 const QDomElement dataIdInfo = metadataElem.firstChildElement( QStringLiteral( "dataIdInfo" ) );
36 const QDomElement idInfo = metadataElem.firstChildElement( QStringLiteral( "idinfo" ) );
37
38 // title
39 const QDomElement idCitation = dataIdInfo.firstChildElement( QStringLiteral( "idCitation" ) );
40 const QString title = idCitation.firstChildElement( QStringLiteral( "resTitle" ) ).text();
41 metadata.setTitle( title );
42
43 // if no explicit identifier we use the title
44 if ( metadata.identifier().isEmpty() && !title.isEmpty() )
45 metadata.setIdentifier( title );
46
47 const QDomElement citationDatesElement = idCitation.firstChildElement( QStringLiteral( "date" ) ).toElement();
48 if ( !citationDatesElement.isNull() )
49 {
50 {
51 const QDomElement createDateElement = citationDatesElement.firstChildElement( QStringLiteral( "createDate" ) ).toElement();
52 if ( !createDateElement.isNull() )
53 {
54 metadata.setDateTime( Qgis::MetadataDateType::Created, QDateTime::fromString( createDateElement.text(), Qt::ISODate ) );
55 }
56 }
57 {
58 const QDomElement pubDateElement = citationDatesElement.firstChildElement( QStringLiteral( "pubDate" ) ).toElement();
59 if ( !pubDateElement.isNull() )
60 {
61 metadata.setDateTime( Qgis::MetadataDateType::Published, QDateTime::fromString( pubDateElement.text(), Qt::ISODate ) );
62 }
63 }
64 {
65 const QDomElement reviseDateElement = citationDatesElement.firstChildElement( QStringLiteral( "reviseDate" ) ).toElement();
66 if ( !reviseDateElement.isNull() )
67 {
68 metadata.setDateTime( Qgis::MetadataDateType::Revised, QDateTime::fromString( reviseDateElement.text(), Qt::ISODate ) );
69 }
70 }
71 {
72 const QDomElement supersededDateElement = citationDatesElement.firstChildElement( QStringLiteral( "supersDate" ) ).toElement();
73 if ( !supersededDateElement.isNull() )
74 {
75 metadata.setDateTime( Qgis::MetadataDateType::Superseded, QDateTime::fromString( supersededDateElement.text(), Qt::ISODate ) );
76 }
77 }
78 }
79
80 // abstract
81 const QDomElement idAbs = dataIdInfo.firstChildElement( QStringLiteral( "idAbs" ) );
82 const QString abstractPlainText = QTextDocumentFragment::fromHtml( idAbs.text() ).toPlainText();
83 metadata.setAbstract( abstractPlainText );
84
85 // purpose
86 const QDomElement idPurp = dataIdInfo.firstChildElement( QStringLiteral( "idPurp" ) );
87 const QString purposePlainText = QTextDocumentFragment::fromHtml( idPurp.text() ).toPlainText();
88 if ( !metadata.abstract().isEmpty() )
89 metadata.setAbstract( metadata.abstract() + QStringLiteral( "\n\n" ) + purposePlainText );
90 else
91 metadata.setAbstract( purposePlainText );
92
93 // older metadata format used "descript" element instead
94 const QDomElement descript = idInfo.firstChildElement( QStringLiteral( "descript" ) );
95 if ( !descript.isNull() )
96 {
97 const QDomElement abstract = descript.firstChildElement( QStringLiteral( "abstract" ) );
98 const QString abstractPlainText = QTextDocumentFragment::fromHtml( abstract.text() ).toPlainText();
99 if ( !abstractPlainText.isEmpty() )
100 {
101 if ( !metadata.abstract().isEmpty() )
102 metadata.setAbstract( metadata.abstract() + QStringLiteral( "\n\n" ) + abstractPlainText );
103 else
104 metadata.setAbstract( abstractPlainText );
105 }
106
107 const QDomElement purpose = descript.firstChildElement( QStringLiteral( "purpose" ) );
108 const QString purposePlainText = QTextDocumentFragment::fromHtml( purpose.text() ).toPlainText();
109 if ( !purposePlainText.isEmpty() )
110 {
111 if ( !metadata.abstract().isEmpty() )
112 metadata.setAbstract( metadata.abstract() + QStringLiteral( "\n\n" ) + purposePlainText );
113 else
114 metadata.setAbstract( purposePlainText );
115 }
116
117 const QDomElement supplinf = descript.firstChildElement( QStringLiteral( "supplinf" ) );
118 const QString supplinfPlainText = QTextDocumentFragment::fromHtml( supplinf.text() ).toPlainText();
119 if ( !supplinfPlainText.isEmpty() )
120 {
121 if ( !metadata.abstract().isEmpty() )
122 metadata.setAbstract( metadata.abstract() + QStringLiteral( "\n\n" ) + supplinfPlainText );
123 else
124 metadata.setAbstract( supplinfPlainText );
125 }
126 }
127
128 // supplementary info
129 const QDomElement suppInfo = dataIdInfo.firstChildElement( QStringLiteral( "suppInfo" ) );
130 const QString suppInfoPlainText = QTextDocumentFragment::fromHtml( suppInfo.text() ).toPlainText();
131 if ( !suppInfoPlainText.isEmpty() )
132 {
133 if ( !metadata.abstract().isEmpty() )
134 metadata.setAbstract( metadata.abstract() + QStringLiteral( "\n\n" ) + suppInfoPlainText );
135 else
136 metadata.setAbstract( suppInfoPlainText );
137 }
138
139 // language
140 const QDomElement dataLang = dataIdInfo.firstChildElement( QStringLiteral( "dataLang" ) );
141 const QDomElement languageCode = dataLang.firstChildElement( QStringLiteral( "languageCode" ) );
142 const QString language = languageCode.attribute( QStringLiteral( "value" ) ).toUpper();
143 metadata.setLanguage( language );
144
145 // keywords
146 QDomElement searchKeys = dataIdInfo.firstChildElement( QStringLiteral( "searchKeys" ) );
147 QStringList keywords;
148 while ( !searchKeys.isNull() )
149 {
150 QDomElement keyword = searchKeys.firstChildElement( QStringLiteral( "keyword" ) );
151 while ( !keyword.isNull() )
152 {
153 keywords << keyword.text();
154 keyword = keyword.nextSiblingElement( QStringLiteral( "keyword" ) );
155 }
156
157 searchKeys = searchKeys.nextSiblingElement( QStringLiteral( "searchKeys" ) );
158 }
159
160 // categories
161 QDomElement themeKeys = dataIdInfo.firstChildElement( QStringLiteral( "themeKeys" ) );
162 QStringList categories;
163 while ( !themeKeys.isNull() )
164 {
165 const QDomElement thesaName = themeKeys.firstChildElement( QStringLiteral( "thesaName" ) );
166 const QString thesaTitle = thesaName.firstChildElement( QStringLiteral( "resTitle" ) ).text();
167
168 const bool isSearchKeyWord = thesaTitle.compare( QLatin1String( "Common Search Terms" ), Qt::CaseInsensitive ) == 0;
169
170 QDomElement themeKeyword = themeKeys.firstChildElement( QStringLiteral( "keyword" ) );
171 while ( !themeKeyword.isNull() )
172 {
173 if ( isSearchKeyWord )
174 {
175 keywords.append( themeKeyword.text().split( ',' ) );
176 }
177 else
178 {
179 categories << themeKeyword.text();
180 }
181 themeKeyword = themeKeyword.nextSiblingElement( QStringLiteral( "keyword" ) );
182 }
183 themeKeys = themeKeys.nextSiblingElement( QStringLiteral( "themeKeys" ) );
184 }
185
186 // older xml format
187 QDomElement keywordsElem = idInfo.firstChildElement( QStringLiteral( "keywords" ) );
188 while ( !keywordsElem.isNull() )
189 {
190 QDomElement theme = keywordsElem.firstChildElement( QStringLiteral( "theme" ) );
191 while ( !theme.isNull() )
192 {
193 categories << theme.firstChildElement( QStringLiteral( "themekey" ) ).text();
194 theme = theme.nextSiblingElement( QStringLiteral( "theme" ) );
195 }
196
197 keywordsElem = keywordsElem.nextSiblingElement( QStringLiteral( "keywords" ) );
198 }
199
200 if ( !categories.isEmpty() )
201 metadata.setCategories( categories );
202
203 if ( !keywords.empty() )
204 metadata.addKeywords( QObject::tr( "Search keys" ), keywords );
205
207
208 // pubDate
209 const QDomElement date = idCitation.firstChildElement( QStringLiteral( "date" ) );
210 const QString pubDate = date.firstChildElement( QStringLiteral( "pubDate" ) ).text();
211 const QDateTime publicationDate = QDateTime::fromString( pubDate, Qt::ISODate );
212 if ( publicationDate.isValid() )
213 {
214 extent.setTemporalExtents( { publicationDate, QDateTime() } );
215 }
216 else
217 {
218 // older XML format
219 QDomElement timeperd = idInfo.firstChildElement( QStringLiteral( "timeperd" ) );
220 while ( !timeperd.isNull() )
221 {
222 if ( timeperd.firstChildElement( QStringLiteral( "current" ) ).text().compare( QLatin1String( "publication date" ) ) == 0 )
223 {
224 const QDomElement timeinfo = timeperd.firstChildElement( QStringLiteral( "timeinfo" ) );
225 const QDomElement sngdate = timeinfo.firstChildElement( QStringLiteral( "sngdate" ) );
226 if ( !sngdate.isNull() )
227 {
228 const QDomElement caldate = sngdate.firstChildElement( QStringLiteral( "caldate" ) );
229 const QString caldateString = caldate.text();
230 const QDateTime publicationDate = QDateTime::fromString( caldateString, QStringLiteral( "MMMM yyyy" ) );
231 if ( publicationDate.isValid() )
232 {
233 extent.setTemporalExtents( { publicationDate, QDateTime() } );
234 break;
235 }
236 }
237 const QDomElement rngdates = timeinfo.firstChildElement( QStringLiteral( "rngdates" ) );
238 if ( !rngdates.isNull() )
239 {
240 const QDomElement begdate = rngdates.firstChildElement( QStringLiteral( "begdate" ) );
241 const QDomElement enddate = rngdates.firstChildElement( QStringLiteral( "enddate" ) );
242 const QString begdateString = begdate.text();
243 const QString enddateString = enddate.text();
244 QDateTime begin;
245 QDateTime end;
246 for ( const QString format : { "yyyy-MM-dd", "dd/MM/yyyy" } )
247 {
248 if ( !begin.isValid() )
249 begin = QDateTime::fromString( begdateString, format );
250 if ( !end.isValid() )
251 end = QDateTime::fromString( enddateString, format );
252 }
253
254 if ( begin.isValid() || end.isValid() )
255 {
256 extent.setTemporalExtents( {QgsDateTimeRange{ begin, end } } );
257 break;
258 }
259 }
260 }
261
262 timeperd = timeperd.nextSiblingElement( QStringLiteral( "timeperd" ) );
263 }
264 }
265
266 //crs
268 QDomElement refSysInfo = metadataElem.firstChildElement( QStringLiteral( "refSysInfo" ) );
269 while ( !refSysInfo.isNull() )
270 {
271 const QDomElement refSystem = refSysInfo.firstChildElement( QStringLiteral( "RefSystem" ) );
272 const QDomElement refSysID = refSystem.firstChildElement( QStringLiteral( "refSysID" ) );
273 const QDomElement identAuth = refSysID.firstChildElement( QStringLiteral( "identAuth" ) );
274 if ( !identAuth.isNull() )
275 {
276 if ( identAuth.firstChildElement( QStringLiteral( "resTitle" ) ).text().compare( QLatin1String( "EPSG Geodetic Parameter Dataset" ) ) == 0 )
277 {
278 const QString code = refSysID.firstChildElement( QStringLiteral( "identCode" ) ).attribute( QStringLiteral( "code" ) );
279 crs = QgsCoordinateReferenceSystem( code );
280 }
281 }
282 else
283 {
284 const QString code = refSysID.firstChildElement( QStringLiteral( "identCode" ) ).attribute( QStringLiteral( "code" ) );
285 const QString auth = refSysID.firstChildElement( QStringLiteral( "idCodeSpace" ) ).text();
286 crs = QgsCoordinateReferenceSystem( QStringLiteral( "%1:%2" ).arg( auth, code ) );
287 }
288
289 if ( crs.isValid() )
290 {
291 metadata.setCrs( crs );
292 break;
293 }
294 refSysInfo = refSysInfo.nextSiblingElement( QStringLiteral( "refSysInfo" ) );
295 }
296
297 // extent
298 QDomElement dataExt = dataIdInfo.firstChildElement( QStringLiteral( "dataExt" ) );
299 while ( !dataExt.isNull() )
300 {
301 const QDomElement geoEle = dataExt.firstChildElement( QStringLiteral( "geoEle" ) );
302 if ( !geoEle.isNull() )
303 {
304 const QDomElement geoBndBox = geoEle.firstChildElement( QStringLiteral( "GeoBndBox" ) );
305 const double west = geoBndBox.firstChildElement( QStringLiteral( "westBL" ) ).text().toDouble();
306 const double east = geoBndBox.firstChildElement( QStringLiteral( "eastBL" ) ).text().toDouble();
307 const double south = geoBndBox.firstChildElement( QStringLiteral( "northBL" ) ).text().toDouble();
308 const double north = geoBndBox.firstChildElement( QStringLiteral( "southBL" ) ).text().toDouble();
309
311 spatialExtent.extentCrs = crs.isValid() ? crs : QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) );
312 spatialExtent.bounds = QgsBox3D( west, south, 0, east, north, 0 );
313
314 extent.setSpatialExtents( { spatialExtent } );
315 break;
316 }
317 dataExt = dataExt.nextSiblingElement( QStringLiteral( "dataExt" ) );
318 }
319
320 metadata.setExtent( extent );
321
322 // licenses, constraints
323 QStringList licenses;
324 QStringList rights;
326 QDomElement resConst = dataIdInfo.firstChildElement( QStringLiteral( "resConst" ) );
327 while ( !resConst.isNull() )
328 {
329 QDomElement legConsts = resConst.firstChildElement( QStringLiteral( "LegConsts" ) );
330 while ( !legConsts.isNull() )
331 {
332 const QString restrictCd = legConsts.firstChildElement( QStringLiteral( "useConsts" ) ).firstChildElement( QStringLiteral( "RestrictCd" ) ).attribute( QStringLiteral( "value" ) );
333
334 if ( restrictCd.compare( QLatin1String( "005" ) ) == 0 )
335 {
336 licenses << QTextDocumentFragment::fromHtml( legConsts.firstChildElement( QStringLiteral( "useLimit" ) ).text() ).toPlainText();
337 }
338 else if ( restrictCd.compare( QLatin1String( "006" ) ) == 0 )
339 {
340 rights << QTextDocumentFragment::fromHtml( legConsts.firstChildElement( QStringLiteral( "useLimit" ) ).text() ).toPlainText();
341 }
342 legConsts = legConsts.nextSiblingElement( QStringLiteral( "LegConsts" ) );
343 }
344
345 QDomElement secConsts = resConst.firstChildElement( QStringLiteral( "SecConsts" ) );
346 while ( !secConsts.isNull() )
347 {
349 constraint.type = QObject::tr( "Security constraints" );
350 constraint.constraint = QTextDocumentFragment::fromHtml( secConsts.firstChildElement( QStringLiteral( "userNote" ) ).text() ).toPlainText();
351 constraints << constraint;
352 secConsts = secConsts.nextSiblingElement( QStringLiteral( "SecConsts" ) );
353 }
354
355 QDomElement consts = resConst.firstChildElement( QStringLiteral( "Consts" ) );
356 while ( !consts.isNull() )
357 {
359 constraint.type = QObject::tr( "Limitations of use" );
360 constraint.constraint = QTextDocumentFragment::fromHtml( consts.firstChildElement( QStringLiteral( "useLimit" ) ).text() ).toPlainText();
361 constraints << constraint;
362 consts = consts.nextSiblingElement( QStringLiteral( "Consts" ) );
363 }
364
365 resConst = resConst.nextSiblingElement( QStringLiteral( "resConst" ) );
366 }
367
368 const QDomElement idCredit = dataIdInfo.firstChildElement( QStringLiteral( "idCredit" ) );
369 const QString credit = idCredit.text();
370 if ( !credit.isEmpty() )
371 rights << credit;
372
373 // older xml format
374 QDomElement accconst = idInfo.firstChildElement( QStringLiteral( "accconst" ) );
375 while ( !accconst.isNull() )
376 {
378 constraint.type = QObject::tr( "Access" );
379 constraint.constraint = QTextDocumentFragment::fromHtml( accconst.text() ).toPlainText();
380 constraints << constraint;
381
382 accconst = accconst.nextSiblingElement( QStringLiteral( "accconst" ) );
383 }
384 QDomElement useconst = idInfo.firstChildElement( QStringLiteral( "useconst" ) );
385 while ( !useconst.isNull() )
386 {
387 rights << QTextDocumentFragment::fromHtml( useconst.text() ).toPlainText();
388 useconst = useconst.nextSiblingElement( QStringLiteral( "useconst" ) );
389 }
390
391 metadata.setLicenses( licenses );
392 metadata.setRights( rights );
393 metadata.setConstraints( constraints );
394
395 // links
396 const QDomElement distInfo = metadataElem.firstChildElement( QStringLiteral( "distInfo" ) );
397 const QDomElement distributor = distInfo.firstChildElement( QStringLiteral( "distributor" ) );
398
399 QDomElement distorTran = distributor.firstChildElement( QStringLiteral( "distorTran" ) );
400 while ( !distorTran.isNull() )
401 {
402 const QDomElement onLineSrc = distorTran.firstChildElement( QStringLiteral( "onLineSrc" ) );
403 if ( !onLineSrc.isNull() )
404 {
406 link.url = onLineSrc.firstChildElement( QStringLiteral( "linkage" ) ).text();
407
408 const QDomElement distorFormat = distributor.firstChildElement( QStringLiteral( "distorFormat" ) );
409 link.name = distorFormat.firstChildElement( QStringLiteral( "formatName" ) ).text();
410 link.type = distorFormat.firstChildElement( QStringLiteral( "formatSpec" ) ).text();
411
412 if ( link.type.isEmpty() )
413 {
414 // older xml format
415 link.type = onLineSrc.firstChildElement( QStringLiteral( "protocol" ) ).text();
416 }
417 metadata.addLink( link );
418 }
419
420 distorTran = distorTran.nextSiblingElement( QStringLiteral( "distorTran" ) );
421 }
422
423 // lineage
424 const QDomElement dqInfo = metadataElem.firstChildElement( QStringLiteral( "dqInfo" ) );
425 const QDomElement dataLineage = dqInfo.firstChildElement( QStringLiteral( "dataLineage" ) );
426 const QString statement = QTextDocumentFragment::fromHtml( dataLineage.firstChildElement( QStringLiteral( "statement" ) ).text() ).toPlainText();
427 if ( !statement.isEmpty() )
428 metadata.addHistoryItem( statement );
429
430 QDomElement dataSource = dataLineage.firstChildElement( QStringLiteral( "dataSource" ) );
431 while ( !dataSource.isNull() )
432 {
433 metadata.addHistoryItem( QObject::tr( "Data source: %1" ).arg( QTextDocumentFragment::fromHtml( dataSource.firstChildElement( QStringLiteral( "srcDesc" ) ).text() ).toPlainText() ) );
434 dataSource = dataSource.nextSiblingElement( QStringLiteral( "dataSource" ) );
435 }
436
437 // contacts
438 const QDomElement mdContact = metadataElem.firstChildElement( QStringLiteral( "mdContact" ) );
439 if ( !mdContact.isNull() )
440 {
442 contact.name = mdContact.firstChildElement( QStringLiteral( "rpIndName" ) ).text();
443 contact.organization = mdContact.firstChildElement( QStringLiteral( "rpOrgName" ) ).text();
444 contact.position = mdContact.firstChildElement( QStringLiteral( "rpPosName" ) ).text();
445
446 const QString role = mdContact.firstChildElement( QStringLiteral( "role" ) ).firstChildElement( QStringLiteral( "RoleCd" ) ).attribute( QStringLiteral( "value" ) );
447 if ( role == QLatin1String( "007" ) )
448 contact.role = QObject::tr( "Point of contact" );
449
450 const QDomElement rpCntInfo = mdContact.firstChildElement( QStringLiteral( "rpCntInfo" ) );
451 contact.email = rpCntInfo.firstChildElement( QStringLiteral( "cntAddress" ) ).firstChildElement( QStringLiteral( "eMailAdd" ) ).text();
452 contact.voice = rpCntInfo.firstChildElement( QStringLiteral( "cntPhone" ) ).firstChildElement( QStringLiteral( "voiceNum" ) ).text();
453
454 QDomElement cntAddress = rpCntInfo.firstChildElement( QStringLiteral( "cntAddress" ) );
455 while ( !cntAddress.isNull() )
456 {
458
459 address.type = cntAddress.attribute( QStringLiteral( "addressType" ) );
460 address.address = cntAddress.firstChildElement( QStringLiteral( "delPoint" ) ).text();
461 address.city = cntAddress.firstChildElement( QStringLiteral( "city" ) ).text();
462 address.administrativeArea = cntAddress.firstChildElement( QStringLiteral( "adminArea" ) ).text();
463 address.postalCode = cntAddress.firstChildElement( QStringLiteral( "postCode" ) ).text();
464 address.country = cntAddress.firstChildElement( QStringLiteral( "country" ) ).text();
465
466 contact.addresses.append( address );
467
468 cntAddress = cntAddress.nextSiblingElement( QStringLiteral( "cntAddress" ) );
469 }
470
471
472 metadata.addContact( contact );
473 }
474
475 // older xml format
476 const QDomElement ptcontac = idInfo.firstChildElement( QStringLiteral( "ptcontac" ) );
477 const QDomElement cntinfo = ptcontac.firstChildElement( QStringLiteral( "cntinfo" ) );
478 if ( !cntinfo.isNull() )
479 {
481 const QDomElement cntorgp = cntinfo.firstChildElement( QStringLiteral( "cntorgp" ) );
482 const QString org = cntorgp.firstChildElement( QStringLiteral( "cntorg" ) ).text();
483
484 contact.name = org;
485 contact.organization = org;
486 contact.role = QObject::tr( "Point of contact" );
487
488 const QDomElement rpCntInfo = mdContact.firstChildElement( QStringLiteral( "rpCntInfo" ) );
489 contact.email = cntinfo.firstChildElement( QStringLiteral( "cntemail" ) ).text();
490 contact.fax = cntinfo.firstChildElement( QStringLiteral( "cntfax" ) ).text();
491 contact.voice = cntinfo.firstChildElement( QStringLiteral( "cntvoice" ) ).text();
492
493 QDomElement cntaddr = cntinfo.firstChildElement( QStringLiteral( "cntaddr" ) );
494 while ( !cntaddr.isNull() )
495 {
497
498 QDomElement addressElem = cntaddr.firstChildElement( QStringLiteral( "address" ) );
499 while ( !addressElem.isNull() )
500 {
501 const QString addressPart = addressElem.text();
502 address.address = address.address.isEmpty() ? addressPart : address.address + '\n' + addressPart;
503 addressElem = addressElem.nextSiblingElement( QStringLiteral( "address" ) );
504 }
505 address.type = cntaddr.firstChildElement( QStringLiteral( "addrtype" ) ).text();
506 address.city = cntaddr.firstChildElement( QStringLiteral( "city" ) ).text();
507 address.administrativeArea = cntaddr.firstChildElement( QStringLiteral( "state" ) ).text();
508 address.postalCode = cntaddr.firstChildElement( QStringLiteral( "postal" ) ).text();
509 address.country = cntaddr.firstChildElement( QStringLiteral( "country" ) ).text();
510
511 contact.addresses.append( address );
512
513 cntaddr = cntaddr.nextSiblingElement( QStringLiteral( "cntaddr" ) );
514 }
515
516 metadata.addContact( contact );
517 }
518
519 return metadata;
520}
@ Created
Date created.
Definition qgis.h:4694
@ Published
Date published.
Definition qgis.h:4695
@ Superseded
Date superseded.
Definition qgis.h:4697
@ Revised
Date revised.
Definition qgis.h:4696
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:42
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.
QgsTemporalRange< QDateTime > QgsDateTimeRange
QgsRange which stores a range of date times.
Definition qgsrange.h:761
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.