31 const QDomElement metadataElem = document.firstChildElement( u
"metadata"_s );
33 const QDomElement esri = metadataElem.firstChildElement( u
"Esri"_s );
34 const QDomElement dataProperties = esri.firstChildElement( u
"DataProperties"_s );
35 const QDomElement itemProps = dataProperties.firstChildElement( u
"itemProps"_s );
36 metadata.
setIdentifier( itemProps.firstChildElement( u
"itemName"_s ).text() );
38 const QDomElement dataIdInfo = metadataElem.firstChildElement( u
"dataIdInfo"_s );
39 const QDomElement idInfo = metadataElem.firstChildElement( u
"idinfo"_s );
42 const QDomElement idCitation = dataIdInfo.firstChildElement( u
"idCitation"_s );
43 const QString title = idCitation.firstChildElement( u
"resTitle"_s ).text();
47 if ( metadata.
identifier().isEmpty() && !title.isEmpty() )
50 const QDomElement citationDatesElement = idCitation.firstChildElement( u
"date"_s ).toElement();
51 if ( !citationDatesElement.isNull() )
54 const QDomElement createDateElement = citationDatesElement.firstChildElement( u
"createDate"_s ).toElement();
55 if ( !createDateElement.isNull() )
61 const QDomElement pubDateElement = citationDatesElement.firstChildElement( u
"pubDate"_s ).toElement();
62 if ( !pubDateElement.isNull() )
68 const QDomElement reviseDateElement = citationDatesElement.firstChildElement( u
"reviseDate"_s ).toElement();
69 if ( !reviseDateElement.isNull() )
75 const QDomElement supersededDateElement = citationDatesElement.firstChildElement( u
"supersDate"_s ).toElement();
76 if ( !supersededDateElement.isNull() )
84 const QDomElement idAbs = dataIdInfo.firstChildElement( u
"idAbs"_s );
85 const QString abstractPlainText = QTextDocumentFragment::fromHtml( idAbs.text() ).toPlainText();
89 const QDomElement idPurp = dataIdInfo.firstChildElement( u
"idPurp"_s );
90 const QString purposePlainText = QTextDocumentFragment::fromHtml( idPurp.text() ).toPlainText();
91 if ( !metadata.
abstract().isEmpty() )
97 const QDomElement descript = idInfo.firstChildElement( u
"descript"_s );
98 if ( !descript.isNull() )
100 const QDomElement abstract = descript.firstChildElement( u
"abstract"_s );
101 const QString abstractPlainText = QTextDocumentFragment::fromHtml( abstract.text() ).toPlainText();
102 if ( !abstractPlainText.isEmpty() )
104 if ( !metadata.
abstract().isEmpty() )
110 const QDomElement purpose = descript.firstChildElement( u
"purpose"_s );
111 const QString purposePlainText = QTextDocumentFragment::fromHtml( purpose.text() ).toPlainText();
112 if ( !purposePlainText.isEmpty() )
114 if ( !metadata.
abstract().isEmpty() )
120 const QDomElement supplinf = descript.firstChildElement( u
"supplinf"_s );
121 const QString supplinfPlainText = QTextDocumentFragment::fromHtml( supplinf.text() ).toPlainText();
122 if ( !supplinfPlainText.isEmpty() )
124 if ( !metadata.
abstract().isEmpty() )
132 const QDomElement suppInfo = dataIdInfo.firstChildElement( u
"suppInfo"_s );
133 const QString suppInfoPlainText = QTextDocumentFragment::fromHtml( suppInfo.text() ).toPlainText();
134 if ( !suppInfoPlainText.isEmpty() )
136 if ( !metadata.
abstract().isEmpty() )
143 const QDomElement dataLang = dataIdInfo.firstChildElement( u
"dataLang"_s );
144 const QDomElement languageCode = dataLang.firstChildElement( u
"languageCode"_s );
145 const QString language = languageCode.attribute( u
"value"_s ).toUpper();
149 QDomElement searchKeys = dataIdInfo.firstChildElement( u
"searchKeys"_s );
150 QStringList keywords;
151 while ( !searchKeys.isNull() )
153 QDomElement keyword = searchKeys.firstChildElement( u
"keyword"_s );
154 while ( !keyword.isNull() )
156 keywords << keyword.text();
157 keyword = keyword.nextSiblingElement( u
"keyword"_s );
160 searchKeys = searchKeys.nextSiblingElement( u
"searchKeys"_s );
164 QDomElement themeKeys = dataIdInfo.firstChildElement( u
"themeKeys"_s );
165 QStringList categories;
166 while ( !themeKeys.isNull() )
168 const QDomElement thesaName = themeKeys.firstChildElement( u
"thesaName"_s );
169 const QString thesaTitle = thesaName.firstChildElement( u
"resTitle"_s ).text();
171 const bool isSearchKeyWord = thesaTitle.compare(
"Common Search Terms"_L1, Qt::CaseInsensitive ) == 0;
173 QDomElement themeKeyword = themeKeys.firstChildElement( u
"keyword"_s );
174 while ( !themeKeyword.isNull() )
176 if ( isSearchKeyWord )
178 keywords.append( themeKeyword.text().split(
',' ) );
182 categories << themeKeyword.text();
184 themeKeyword = themeKeyword.nextSiblingElement( u
"keyword"_s );
186 themeKeys = themeKeys.nextSiblingElement( u
"themeKeys"_s );
190 QDomElement keywordsElem = idInfo.firstChildElement( u
"keywords"_s );
191 while ( !keywordsElem.isNull() )
193 QDomElement theme = keywordsElem.firstChildElement( u
"theme"_s );
194 while ( !theme.isNull() )
196 categories << theme.firstChildElement( u
"themekey"_s ).text();
197 theme = theme.nextSiblingElement( u
"theme"_s );
200 keywordsElem = keywordsElem.nextSiblingElement( u
"keywords"_s );
203 if ( !categories.isEmpty() )
206 if ( !keywords.empty() )
207 metadata.
addKeywords( QObject::tr(
"Search keys" ), keywords );
212 const QDomElement date = idCitation.firstChildElement( u
"date"_s );
213 const QString pubDate = date.firstChildElement( u
"pubDate"_s ).text();
214 const QDateTime publicationDate = QDateTime::fromString( pubDate, Qt::ISODate );
215 if ( publicationDate.isValid() )
222 QDomElement timeperd = idInfo.firstChildElement( u
"timeperd"_s );
223 while ( !timeperd.isNull() )
225 if ( timeperd.firstChildElement( u
"current"_s ).text().compare(
"publication date"_L1 ) == 0 )
227 const QDomElement timeinfo = timeperd.firstChildElement( u
"timeinfo"_s );
228 const QDomElement sngdate = timeinfo.firstChildElement( u
"sngdate"_s );
229 if ( !sngdate.isNull() )
231 const QDomElement caldate = sngdate.firstChildElement( u
"caldate"_s );
232 const QString caldateString = caldate.text();
233 const QDateTime publicationDate = QDateTime::fromString( caldateString, u
"MMMM yyyy"_s );
234 if ( publicationDate.isValid() )
240 const QDomElement rngdates = timeinfo.firstChildElement( u
"rngdates"_s );
241 if ( !rngdates.isNull() )
243 const QDomElement begdate = rngdates.firstChildElement( u
"begdate"_s );
244 const QDomElement enddate = rngdates.firstChildElement( u
"enddate"_s );
245 const QString begdateString = begdate.text();
246 const QString enddateString = enddate.text();
249 for (
const QString format : {
"yyyy-MM-dd",
"dd/MM/yyyy" } )
251 if ( !begin.isValid() )
252 begin = QDateTime::fromString( begdateString, format );
253 if ( !end.isValid() )
254 end = QDateTime::fromString( enddateString, format );
257 if ( begin.isValid() || end.isValid() )
265 timeperd = timeperd.nextSiblingElement( u
"timeperd"_s );
271 QDomElement refSysInfo = metadataElem.firstChildElement( u
"refSysInfo"_s );
272 while ( !refSysInfo.isNull() )
274 const QDomElement refSystem = refSysInfo.firstChildElement( u
"RefSystem"_s );
275 const QDomElement refSysID = refSystem.firstChildElement( u
"refSysID"_s );
276 const QDomElement identAuth = refSysID.firstChildElement( u
"identAuth"_s );
277 if ( !identAuth.isNull() )
279 if ( identAuth.firstChildElement( u
"resTitle"_s ).text().compare(
"EPSG Geodetic Parameter Dataset"_L1 ) == 0 )
281 const QString code = refSysID.firstChildElement( u
"identCode"_s ).attribute( u
"code"_s );
287 const QString code = refSysID.firstChildElement( u
"identCode"_s ).attribute( u
"code"_s );
288 const QString auth = refSysID.firstChildElement( u
"idCodeSpace"_s ).text();
297 refSysInfo = refSysInfo.nextSiblingElement( u
"refSysInfo"_s );
301 QDomElement dataExt = dataIdInfo.firstChildElement( u
"dataExt"_s );
302 while ( !dataExt.isNull() )
304 const QDomElement geoEle = dataExt.firstChildElement( u
"geoEle"_s );
305 if ( !geoEle.isNull() )
307 const QDomElement geoBndBox = geoEle.firstChildElement( u
"GeoBndBox"_s );
308 const double west = geoBndBox.firstChildElement( u
"westBL"_s ).text().toDouble();
309 const double east = geoBndBox.firstChildElement( u
"eastBL"_s ).text().toDouble();
310 const double south = geoBndBox.firstChildElement( u
"northBL"_s ).text().toDouble();
311 const double north = geoBndBox.firstChildElement( u
"southBL"_s ).text().toDouble();
315 spatialExtent.
bounds =
QgsBox3D( west, south, 0, east, north, 0 );
320 dataExt = dataExt.nextSiblingElement( u
"dataExt"_s );
326 QStringList licenses;
329 QDomElement resConst = dataIdInfo.firstChildElement( u
"resConst"_s );
330 while ( !resConst.isNull() )
332 QDomElement legConsts = resConst.firstChildElement( u
"LegConsts"_s );
333 while ( !legConsts.isNull() )
335 const QString restrictCd = legConsts.firstChildElement( u
"useConsts"_s ).firstChildElement( u
"RestrictCd"_s ).attribute( u
"value"_s );
337 if ( restrictCd.compare(
"005"_L1 ) == 0 )
339 licenses << QTextDocumentFragment::fromHtml( legConsts.firstChildElement( u
"useLimit"_s ).text() ).toPlainText();
341 else if ( restrictCd.compare(
"006"_L1 ) == 0 )
343 rights << QTextDocumentFragment::fromHtml( legConsts.firstChildElement( u
"useLimit"_s ).text() ).toPlainText();
345 legConsts = legConsts.nextSiblingElement( u
"LegConsts"_s );
348 QDomElement secConsts = resConst.firstChildElement( u
"SecConsts"_s );
349 while ( !secConsts.isNull() )
352 constraint.
type = QObject::tr(
"Security constraints" );
353 constraint.
constraint = QTextDocumentFragment::fromHtml( secConsts.firstChildElement( u
"userNote"_s ).text() ).toPlainText();
354 constraints << constraint;
355 secConsts = secConsts.nextSiblingElement( u
"SecConsts"_s );
358 QDomElement consts = resConst.firstChildElement( u
"Consts"_s );
359 while ( !consts.isNull() )
362 constraint.
type = QObject::tr(
"Limitations of use" );
363 constraint.
constraint = QTextDocumentFragment::fromHtml( consts.firstChildElement( u
"useLimit"_s ).text() ).toPlainText();
364 constraints << constraint;
365 consts = consts.nextSiblingElement( u
"Consts"_s );
368 resConst = resConst.nextSiblingElement( u
"resConst"_s );
371 const QDomElement idCredit = dataIdInfo.firstChildElement( u
"idCredit"_s );
372 const QString credit = idCredit.text();
373 if ( !credit.isEmpty() )
377 QDomElement accconst = idInfo.firstChildElement( u
"accconst"_s );
378 while ( !accconst.isNull() )
381 constraint.
type = QObject::tr(
"Access" );
382 constraint.
constraint = QTextDocumentFragment::fromHtml( accconst.text() ).toPlainText();
383 constraints << constraint;
385 accconst = accconst.nextSiblingElement( u
"accconst"_s );
387 QDomElement useconst = idInfo.firstChildElement( u
"useconst"_s );
388 while ( !useconst.isNull() )
390 rights << QTextDocumentFragment::fromHtml( useconst.text() ).toPlainText();
391 useconst = useconst.nextSiblingElement( u
"useconst"_s );
399 const QDomElement distInfo = metadataElem.firstChildElement( u
"distInfo"_s );
400 const QDomElement distributor = distInfo.firstChildElement( u
"distributor"_s );
402 QDomElement distorTran = distributor.firstChildElement( u
"distorTran"_s );
403 while ( !distorTran.isNull() )
405 const QDomElement onLineSrc = distorTran.firstChildElement( u
"onLineSrc"_s );
406 if ( !onLineSrc.isNull() )
409 link.
url = onLineSrc.firstChildElement( u
"linkage"_s ).text();
411 const QDomElement distorFormat = distributor.firstChildElement( u
"distorFormat"_s );
412 link.
name = distorFormat.firstChildElement( u
"formatName"_s ).text();
413 link.
type = distorFormat.firstChildElement( u
"formatSpec"_s ).text();
415 if ( link.
type.isEmpty() )
418 link.
type = onLineSrc.firstChildElement( u
"protocol"_s ).text();
423 distorTran = distorTran.nextSiblingElement( u
"distorTran"_s );
427 const QDomElement dqInfo = metadataElem.firstChildElement( u
"dqInfo"_s );
428 const QDomElement dataLineage = dqInfo.firstChildElement( u
"dataLineage"_s );
429 const QString statement = QTextDocumentFragment::fromHtml( dataLineage.firstChildElement( u
"statement"_s ).text() ).toPlainText();
430 if ( !statement.isEmpty() )
433 QDomElement dataSource = dataLineage.firstChildElement( u
"dataSource"_s );
434 while ( !dataSource.isNull() )
436 metadata.
addHistoryItem( QObject::tr(
"Data source: %1" ).arg( QTextDocumentFragment::fromHtml( dataSource.firstChildElement( u
"srcDesc"_s ).text() ).toPlainText() ) );
437 dataSource = dataSource.nextSiblingElement( u
"dataSource"_s );
441 const QDomElement mdContact = metadataElem.firstChildElement( u
"mdContact"_s );
442 if ( !mdContact.isNull() )
445 contact.
name = mdContact.firstChildElement( u
"rpIndName"_s ).text();
446 contact.
organization = mdContact.firstChildElement( u
"rpOrgName"_s ).text();
447 contact.
position = mdContact.firstChildElement( u
"rpPosName"_s ).text();
449 const QString role = mdContact.firstChildElement( u
"role"_s ).firstChildElement( u
"RoleCd"_s ).attribute( u
"value"_s );
450 if ( role ==
"007"_L1 )
451 contact.
role = QObject::tr(
"Point of contact" );
453 const QDomElement rpCntInfo = mdContact.firstChildElement( u
"rpCntInfo"_s );
454 contact.
email = rpCntInfo.firstChildElement( u
"cntAddress"_s ).firstChildElement( u
"eMailAdd"_s ).text();
455 contact.
voice = rpCntInfo.firstChildElement( u
"cntPhone"_s ).firstChildElement( u
"voiceNum"_s ).text();
457 QDomElement cntAddress = rpCntInfo.firstChildElement( u
"cntAddress"_s );
458 while ( !cntAddress.isNull() )
462 address.
type = cntAddress.attribute( u
"addressType"_s );
463 address.
address = cntAddress.firstChildElement( u
"delPoint"_s ).text();
464 address.
city = cntAddress.firstChildElement( u
"city"_s ).text();
466 address.
postalCode = cntAddress.firstChildElement( u
"postCode"_s ).text();
467 address.
country = cntAddress.firstChildElement( u
"country"_s ).text();
471 cntAddress = cntAddress.nextSiblingElement( u
"cntAddress"_s );
479 const QDomElement ptcontac = idInfo.firstChildElement( u
"ptcontac"_s );
480 const QDomElement cntinfo = ptcontac.firstChildElement( u
"cntinfo"_s );
481 if ( !cntinfo.isNull() )
484 const QDomElement cntorgp = cntinfo.firstChildElement( u
"cntorgp"_s );
485 const QString org = cntorgp.firstChildElement( u
"cntorg"_s ).text();
489 contact.
role = QObject::tr(
"Point of contact" );
491 const QDomElement rpCntInfo = mdContact.firstChildElement( u
"rpCntInfo"_s );
492 contact.
email = cntinfo.firstChildElement( u
"cntemail"_s ).text();
493 contact.
fax = cntinfo.firstChildElement( u
"cntfax"_s ).text();
494 contact.
voice = cntinfo.firstChildElement( u
"cntvoice"_s ).text();
496 QDomElement cntaddr = cntinfo.firstChildElement( u
"cntaddr"_s );
497 while ( !cntaddr.isNull() )
501 QDomElement addressElem = cntaddr.firstChildElement( u
"address"_s );
502 while ( !addressElem.isNull() )
504 const QString addressPart = addressElem.text();
506 addressElem = addressElem.nextSiblingElement( u
"address"_s );
508 address.
type = cntaddr.firstChildElement( u
"addrtype"_s ).text();
509 address.
city = cntaddr.firstChildElement( u
"city"_s ).text();
511 address.
postalCode = cntaddr.firstChildElement( u
"postal"_s ).text();
512 address.
country = cntaddr.firstChildElement( u
"country"_s ).text();
516 cntaddr = cntaddr.nextSiblingElement( u
"cntaddr"_s );