-
Notifications
You must be signed in to change notification settings - Fork 1
/
dwc_multimedia.sql
76 lines (69 loc) · 1.92 KB
/
dwc_multimedia.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
Created by Peter Desmet (INBO)
Mapping from Camtrap DP: https://tdwg.github.io/camtrap-dp
Mapping to Audubon Media Description: https://rs.gbif.org/extension/ac/audubon_2020_10_06.xml
Y = included in DwC, N = not included in DwC
CAMTRAP DP MEDIA
mediaID Y: as link to observation
parentMediaID Y: as link to child media files
deploymentID Y
captureMethod ?
start Y
end N
filePath Y
fileName Y: to sort data
fileMediatype Y
exifData N
favourite N
comments N
_id N
*/
SELECT
-- occurrenceID
obs.observationID AS occurrenceID,
-- creator
-- providerLiteral
-- provider
-- rights
{metadata$mediaLicense} AS rights,
-- owner
-- identifier
med.mediaID AS identifier,
-- type
CASE
WHEN med.fileMediatype LIKE '%video%' THEN 'MovingImage'
ELSE 'StillImage'
END AS type,
-- providerManagedID
med._id AS providerManagedID,
-- captureDevice
-- dep.cameraModel AS captureDevice,
-- resourceCreationTechnique
med.captureMethod AS resourceCreationTechnique,
-- accessURI
med.filePath AS accessURI,
-- format
med.fileMediatype AS format,
-- CreateDate
STRFTIME('%Y-%m-%dT%H:%M:%SZ', datetime(med.start, 'unixepoch')) AS createDate
FROM
observations AS obs
LEFT JOIN media AS parent_med
ON obs.mediaID = parent_med.mediaID
LEFT JOIN
(
SELECT
*,
CASE
WHEN parentMediaID IS NULL THEN mediaID -- Make parents their own child
ELSE parentMediaID
END AS populatedParentMediaID
FROM media
) AS med
ON med.populatedParentMediaID = parent_med.mediaID
WHERE
obs.observationType = 'animal' AND
med.filePath IS NOT NULL -- Remove sequences
ORDER BY
med.start,
med.fileName