File Coverage

blib/lib/Image/ExifTool/DarwinCore.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             #------------------------------------------------------------------------------
2             # File: DarwinCore.pm
3             #
4             # Description: Darwin Core XMP tags
5             #
6             # Revisions: 2013-01-28 - P. Harvey Created
7             #
8             # References: 1) http://rs.tdwg.org/dwc/index.htm
9             # 2) https://exiftool.org/forum/index.php/topic,4442.0/all.html
10             #------------------------------------------------------------------------------
11              
12             package Image::ExifTool::DarwinCore;
13              
14 2     2   33 use strict;
  2         6  
  2         123  
15 2     2   13 use vars qw($VERSION);
  2         10  
  2         124  
16 2     2   14 use Image::ExifTool::XMP;
  2         7  
  2         1632  
17              
18             $VERSION = '1.07';
19              
20             my %dateTimeInfo = (
21             # NOTE: Do NOT put "Groups" here because Groups hash must not be common!
22             Writable => 'date',
23             Shift => 'Time',
24             PrintConv => '$self->ConvertDateTime($val)',
25             PrintConvInv => '$self->InverseDateTime($val,undef,1)',
26             );
27              
28             my %materialSample = (
29             STRUCT_NAME => 'DarwinCore MaterialSample',
30             NAMESPACE => 'dwc',
31             materialSampleID => { },
32             );
33              
34             my %event = (
35             STRUCT_NAME => 'DarwinCore Event',
36             NAMESPACE => 'dwc',
37             day => { Writable => 'integer', Groups => { 2 => 'Time' } },
38             earliestDate => { %dateTimeInfo, Groups => { 2 => 'Time' } },
39             endDayOfYear => { Writable => 'integer', Groups => { 2 => 'Time' } },
40             eventDate => { %dateTimeInfo, Groups => { 2 => 'Time' } },
41             eventID => { Avoid => 1, Notes => 'avoided in favor of XMP-iptcExt:EventID' },
42             eventRemarks => { Writable => 'lang-alt' },
43             eventTime => {
44             Groups => { 2 => 'Time' },
45             Writable => 'string', # (so we can format this ourself)
46             Shift => 'Time',
47             # (allow date/time or just time value)
48             ValueConv => 'Image::ExifTool::XMP::ConvertXMPDate($val)',
49             PrintConv => '$self->ConvertDateTime($val)',
50             ValueConvInv => 'Image::ExifTool::XMP::FormatXMPDate($val) or $val',
51             PrintConvInv => q{
52             my $v = $self->InverseDateTime($val,undef,1);
53             undef $Image::ExifTool::evalWarning;
54             return $v if $v;
55             # allow time-only values by adding dummy date (thanks Herb)
56             my $v = $self->InverseDateTime("2000:01:01 $val",undef,1);
57             undef $Image::ExifTool::evalWarning;
58             return $v if $v and $v =~ s/.* //; # strip off dummy date
59             $Image::ExifTool::evalWarning = 'Invalid date/time or time-only value (use HH:MM:SS[.ss][+/-HH:MM|Z])';
60             return undef;
61             },
62             },
63             fieldNotes => { },
64             fieldNumber => { },
65             habitat => { },
66             latestDate => { %dateTimeInfo, Groups => { 2 => 'Time' } },
67             month => { Writable => 'integer', Groups => { 2 => 'Time' } },
68             parentEventID => { },
69             samplingEffort => { },
70             samplingProtocol => { },
71             sampleSizeValue => { },
72             sampleSizeUnit => { },
73             startDayOfYear => { Writable => 'integer', Groups => { 2 => 'Time' } },
74             verbatimEventDate => { Groups => { 2 => 'Time' } },
75             year => { Writable => 'integer', Groups => { 2 => 'Time' } },
76             );
77              
78             # Darwin Core tags
79             %Image::ExifTool::DarwinCore::Main = (
80             GROUPS => { 0 => 'XMP', 1 => 'XMP-dwc', 2 => 'Other' },
81             NAMESPACE => 'dwc',
82             WRITABLE => 'string',
83             NOTES => q{
84             Tags defined in the Darwin Core (dwc) XMP namespace. See
85             L for the official specification.
86             },
87             Event => {
88             Name => 'DCEvent', # (avoid conflict with XMP-iptcExt:Event)
89             FlatName => 'Event',
90             Struct => \%event,
91             },
92             # tweak a few of the flattened tag names
93             EventEventDate => { Name => 'EventDate', Flat => 1 },
94             EventEventID => { Name => 'EventID', Flat => 1 },
95             EventEventRemarks => { Name => 'EventRemarks', Flat => 1 },
96             EventEventTime => { Name => 'EventTime', Flat => 1 },
97             FossilSpecimen => { Struct => \%materialSample },
98             GeologicalContext => {
99             FlatName => '', # ('GeologicalContext' is too long)
100             Struct => {
101             STRUCT_NAME => 'DarwinCore GeologicalContext',
102             NAMESPACE => 'dwc',
103             bed => { },
104             earliestAgeOrLowestStage => { },
105             earliestEonOrLowestEonothem => { },
106             earliestEpochOrLowestSeries => { },
107             earliestEraOrLowestErathem => { },
108             earliestPeriodOrLowestSystem=> { },
109             formation => { },
110             geologicalContextID => { },
111             group => { },
112             highestBiostratigraphicZone => { },
113             latestAgeOrHighestStage => { },
114             latestEonOrHighestEonothem => { },
115             latestEpochOrHighestSeries => { },
116             latestEraOrHighestErathem => { },
117             latestPeriodOrHighestSystem => { },
118             lithostratigraphicTerms => { },
119             lowestBiostratigraphicZone => { },
120             member => { },
121             },
122             },
123             GeologicalContextBed => { Name => 'GeologicalContextBed', Flat => 1 },
124             GeologicalContextFormation => { Name => 'GeologicalContextFormation', Flat => 1 },
125             GeologicalContextGroup => { Name => 'GeologicalContextGroup', Flat => 1 },
126             GeologicalContextMember => { Name => 'GeologicalContextMember', Flat => 1 },
127             HumanObservation => { Struct => \%event },
128             Identification => {
129             FlatName => '', # ('Identification' is redundant)
130             Struct => {
131             STRUCT_NAME => 'DarwinCore Identification',
132             NAMESPACE => 'dwc',
133             dateIdentified => { %dateTimeInfo, Groups => { 2 => 'Time' } },
134             identificationID => { },
135             identificationQualifier => { },
136             identificationReferences => { },
137             identificationRemarks => { },
138             identificationVerificationStatus => { },
139             identifiedBy => { },
140             typeStatus => { },
141             # new, ref forum13707
142             identifiedByID => { },
143             verbatimIdentification => { },
144             },
145             },
146             LivingSpecimen => { Struct => \%materialSample },
147             MachineObservation => { Struct => \%event },
148             MaterialSample => { Struct => \%materialSample },
149             MaterialSampleMaterialSampleID => { Name => 'MaterialSampleID', Flat => 1 },
150             MeasurementOrFact => {
151             FlatName => '', # ('MeasurementOrFact' is redundant and too long)
152             Struct => {
153             STRUCT_NAME => 'DarwinCore MeasurementOrFact',
154             NAMESPACE => 'dwc',
155             measurementAccuracy => { Format => 'real' },
156             measurementDeterminedBy => { },
157             measurementDeterminedDate => { %dateTimeInfo, Groups => { 2 => 'Time' } },
158             measurementID => { },
159             measurementMethod => { },
160             measurementRemarks => { },
161             measurementType => { },
162             measurementUnit => { },
163             measurementValue => { },
164             },
165             },
166             Occurrence => {
167             Struct => {
168             STRUCT_NAME => 'DarwinCore Occurrence',
169             NAMESPACE => 'dwc',
170             associatedMedia => { },
171             associatedOccurrences => { },
172             associatedReferences => { },
173             associatedSequences => { },
174             associatedTaxa => { },
175             behavior => { },
176             catalogNumber => { },
177             disposition => { },
178             establishmentMeans => { },
179             individualCount => { },
180             individualID => { },
181             lifeStage => { },
182             occurrenceDetails => { },
183             occurrenceID => { },
184             occurrenceRemarks => { },
185             occurrenceStatus => { },
186             organismQuantity => { },
187             organismQuantityType => { },
188             otherCatalogNumbers => { },
189             preparations => { },
190             previousIdentifications => { },
191             recordedBy => { },
192             recordNumber => { },
193             reproductiveCondition => { },
194             sex => { },
195             # new, ref forum13707
196             degreeOfEstablishment => { },
197             georeferenceVerificationStatus => { },
198             pathway => { },
199             recordedByID => { },
200             },
201             },
202             OccurrenceOccurrenceDetails => { Name => 'OccurrenceDetails', Flat => 1 },
203             OccurrenceOccurrenceID => { Name => 'OccurrenceID', Flat => 1 },
204             OccurrenceOccurrenceRemarks => { Name => 'OccurrenceRemarks', Flat => 1 },
205             OccurrenceOccurrenceStatus => { Name => 'OccurrenceStatus', Flat => 1 },
206             Organism => {
207             Struct => {
208             STRUCT_NAME => 'DarwinCore Organism',
209             NAMESPACE => 'dwc',
210             associatedOccurrences => { },
211             associatedOrganisms => { },
212             organismID => { },
213             organismName => { },
214             organismRemarks => { },
215             organismScope => { },
216             previousIdentifications => { },
217             },
218             },
219             OrganismOrganismID => { Name => 'OrganismID', Flat => 1 },
220             OrganismOrganismName => { Name => 'OrganismName', Flat => 1 },
221             OrganismOrganismRemarks => { Name => 'OrganismRemarks', Flat => 1 },
222             OrganismOrganismScope => { Name => 'OrganismScope', Flat => 1 },
223             PreservedSpecimen => { Struct => \%materialSample },
224             Record => {
225             Struct => {
226             STRUCT_NAME => 'DarwinCore Record',
227             NAMESPACE => 'dwc',
228             basisOfRecord => { },
229             collectionCode => { },
230             collectionID => { },
231             dataGeneralizations => { },
232             datasetID => { },
233             datasetName => { },
234             dynamicProperties => { },
235             informationWithheld => { },
236             institutionCode => { },
237             institutionID => { },
238             ownerInstitutionCode => { },
239             },
240             },
241             ResourceRelationship => {
242             FlatName => '', # ('ResourceRelationship' is redundant and too long)
243             Struct => {
244             STRUCT_NAME => 'DarwinCore ResourceRelationship',
245             NAMESPACE => 'dwc',
246             relatedResourceID => { },
247             relationshipAccordingTo => { },
248             relationshipEstablishedDate => { %dateTimeInfo, Groups => { 2 => 'Time' } },
249             relationshipOfResource => { },
250             relationshipRemarks => { },
251             resourceID => { },
252             resourceRelationshipID => { },
253             relationshipOfResourceID => { }, # new, ref forum13707
254             },
255             },
256             Taxon => {
257             Struct => {
258             STRUCT_NAME => 'DarwinCore Taxon',
259             NAMESPACE => 'dwc',
260             acceptedNameUsage => { },
261             acceptedNameUsageID => { },
262             class => { },
263             family => { },
264             genus => { },
265             higherClassification => { },
266             infraspecificEpithet => { },
267             cultivarEpithet => { }, # new, ref forum13707
268             kingdom => { },
269             nameAccordingTo => { },
270             nameAccordingToID => { },
271             namePublishedIn => { },
272             namePublishedInID => { },
273             namePublishedInYear => { },
274             nomenclaturalCode => { },
275             nomenclaturalStatus => { },
276             order => { },
277             originalNameUsage => { },
278             originalNameUsageID => { },
279             parentNameUsage => { },
280             parentNameUsageID => { },
281             phylum => { },
282             scientificName => { },
283             scientificNameAuthorship => { },
284             scientificNameID => { },
285             specificEpithet => { },
286             subgenus => { },
287             taxonConceptID => { },
288             taxonID => { },
289             taxonRank => { },
290             taxonRemarks => { },
291             taxonomicStatus => { },
292             verbatimTaxonRank => { },
293             vernacularName => { Writable => 'lang-alt' },
294             },
295             },
296             TaxonTaxonConceptID => { Name => 'TaxonConceptID', Flat => 1 },
297             TaxonTaxonID => { Name => 'TaxonID', Flat => 1 },
298             TaxonTaxonRank => { Name => 'TaxonRank', Flat => 1 },
299             TaxonTaxonRemarks => { Name => 'TaxonRemarks', Flat => 1 },
300             dctermsLocation => {
301             Name => 'DCTermsLocation',
302             Groups => { 2 => 'Location' },
303             FlatName => 'DC', # ('dctermsLocation' is too long)
304             Struct => {
305             STRUCT_NAME => 'DarwinCore DCTermsLocation',
306             NAMESPACE => 'dwc',
307             continent => { },
308             coordinatePrecision => { },
309             coordinateUncertaintyInMeters => { },
310             country => { },
311             countryCode => { },
312             county => { },
313             decimalLatitude => { },
314             decimalLongitude => { },
315             footprintSpatialFit => { },
316             footprintSRS => { },
317             footprintWKT => { },
318             geodeticDatum => { },
319             georeferencedBy => { },
320             georeferencedDate => { },
321             georeferenceProtocol => { },
322             georeferenceRemarks => { },
323             georeferenceSources => { },
324             georeferenceVerificationStatus => { },
325             higherGeography => { },
326             higherGeographyID => { },
327             island => { },
328             islandGroup => { },
329             locality => { },
330             locationAccordingTo => { },
331             locationID => { },
332             locationRemarks => { },
333             maximumDepthInMeters => { },
334             maximumDistanceAboveSurfaceInMeters => { },
335             maximumElevationInMeters => { },
336             minimumDepthInMeters => { },
337             minimumDistanceAboveSurfaceInMeters => { },
338             minimumElevationInMeters => { },
339             municipality => { },
340             pointRadiusSpatialFit => { },
341             stateProvince => { },
342             verbatimCoordinates => { },
343             verbatimCoordinateSystem => { },
344             verbatimDepth => { },
345             verbatimElevation => { },
346             verbatimLatitude => { },
347             verbatimLocality => { },
348             verbatimLongitude => { },
349             verbatimSRS => { },
350             waterBody => { },
351             # new, ref forum13707
352             verticalDatum => { },
353             },
354             },
355             );
356              
357             1; #end
358              
359             __END__