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