[#19] Extract thumbnail from ISO documents

This commit is contained in:
amercader 2013-05-15 16:41:36 +01:00
parent 2d557022f4
commit 692f04568f
2 changed files with 48 additions and 1 deletions

View File

@ -259,6 +259,17 @@ class SpatialHarvester(HarvesterBase):
extras['access_constraints'] = iso_values.get('limitations-on-public-access', '')
# Grpahic preview
browse_graphic = iso_values.get('browse-graphic')
if browse_graphic:
browse_graphic = browse_graphic[0]
extras['graphic-preview-file'] = browse_graphic.get('file')
if browse_graphic.get('description'):
extras['graphic-preview-description'] = browse_graphic.get('description')
if browse_graphic.get('type'):
extras['graphic-preview-type'] = browse_graphic.get('type')
for key in ['temporal-extent-begin', 'temporal-extent-end']:
if len(iso_values[key]) > 0:
extras[key] = iso_values[key][0]

View File

@ -344,6 +344,33 @@ class ISOBoundingBox(ISOElement):
),
]
class ISOBrowseGraphic(ISOElement):
elements = [
ISOElement(
name="file",
search_paths=[
"gmd:fileName/gco:CharacterString/text()",
],
multiplicity="1",
),
ISOElement(
name="description",
search_paths=[
"gmd:fileDescription/gco:CharacterString/text()",
],
multiplicity="0..1",
),
ISOElement(
name="type",
search_paths=[
"gmd:fileType/gco:CharacterString/text()",
],
multiplicity="0..1",
),
]
class ISODocument(MappedXmlDocument):
# Attribute specifications from "XPaths for GEMINI" by Peter Parslow.
@ -651,7 +678,16 @@ class ISODocument(MappedXmlDocument):
"gmd:dataQualityInfo/gmd:DQ_DataQuality/gmd:lineage/gmd:LI_Lineage/gmd:statement/gco:CharacterString/text()",
],
multiplicity="0..1",
)
),
ISOBrowseGraphic(
name="browse-graphic",
search_paths=[
"gmd:identificationInfo/gmd:MD_DataIdentification/gmd:graphicOverview/gmd:MD_BrowseGraphic",
"gmd:identificationInfo/srv:SV_ServiceIdentification/gmd:graphicOverview/gmd:MD_BrowseGraphic",
],
multiplicity="*",
),
]
def infer_values(self, values):