Skip to content

Commit

Permalink
Merge pull request #5 from biigle/patch-1
Browse files Browse the repository at this point in the history
Fix case of imported iFDO without annotations
  • Loading branch information
mzur authored Dec 3, 2024
2 parents da0ab36 + 3195b91 commit 1feda4b
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public function __construct($acquisitionFormat)
public function convert($ifdo)
{
$header = $ifdo->getImageSetHeader();
$this->annotators = $this->extractIfdoAnnotators($header['image-annotation-creators']);
$this->labels = $this->extractIfdoLabels($header['image-annotation-labels']);
$this->annotators = $this->extractIfdoAnnotators($header['image-annotation-creators'] ?? []);
$this->labels = $this->extractIfdoLabels($header['image-annotation-labels'] ?? []);

$data = new VolumeMetadata(
type: $this->mediaType(),
Expand Down
9 changes: 9 additions & 0 deletions tests/IfdoParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,13 @@ public function testGetVideoMetadata()
$this->assertSame(681.7, $annotation->points[0][0]);
$this->assertSame(0.402947, $annotation->frames[0]);
}

public function testGetMetadataNoLabels()
{
$file = new File(__DIR__ . "/files/image-ifdo-no-annotations.json");
$parser = new IfdoParser($file);
$data = $parser->getMetadata();
$this->assertSame(MediaType::imageId(), $data->type->id);
$this->assertSame('SO268 SO268-2_100-1_OFOS SO_CAM-1_Photo_OFOS', $data->name);
}
}
78 changes: 78 additions & 0 deletions tests/files/image-ifdo-no-annotations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"image-set-header": {
"image-set-ifdo-version": "v2.1.0",
"image-altitude-meters": -4094.5,
"image-coordinate-reference-system": "EPSG:4326",
"image-coordinate-uncertainty-meters": 4.74,
"image-set-ifdo-version": "v2.1.0",
"image-datetime": "2019-04-06 04:29:27.000000",
"image-acquisition": "photo",
"image-area-square-meter": 5,
"image-capture-mode": "mixed",
"image-coordinate-reference-system": "EPSG:4326",
"image-deployment": "survey",
"image-event": "SO268-2_100-1_OFOS",
"image-illumination": "artificial light",
"image-latitude": 11.8581802,
"image-license": "CC-BY",
"image-longitude": -117.0214864,
"image-marine-zone": "seafloor",
"image-meters-above-ground": 2,
"image-navigation": "beacon",
"image-project": "SO268",
"image-quality": "raw",
"image-resolution": "mm",
"image-scale-reference": "laser marker",
"image-set-metadata-handle": "20.500.12085/d7546c4b-307f-4d42-8554-33236c577450@metadata",
"image-set-name": "SO268 SO268-2_100-1_OFOS SO_CAM-1_Photo_OFOS",
"image-set-uuid": "d7546c4b-307f-4d42-8554-33236c577450",
"image-spectral-resolution": "rgb",
"image-copyright": "(c) GEOMAR Helmholtz Centre for Ocean Research Kiel. Contact: [email protected]",
"image-abstract": "Image Abstract",
"image-set-handle": "https://hdl.handle.net/20.500.12085/d7546c4b-307f-4d42-8554-33236c577450",
"image-license": {
"name": "CC-BY",
"uri": "https://creativecommons.org/licenses/by/4.0/legalcode"
},
"image-project": {
"name": "Test Project",
"uri": "https://doi.org/example"
},
"image-event": {
"name": "SO268-1_21-1_OFOS",
"uri": "https://portal.geomar.de/metadata/event/show/1603320?leg=348623"
},
"image-platform": {
"name": "SO_PFM-01_OFOS",
"uri": "https://dm.pages.geomar.de/equipment/equipment/SO/PFM/SO_PFM-1_OFOS_Isitec/"
},
"image-sensor": {
"name": "SO_CAM-1_Photo_OFOS",
"uri": "https://dm.pages.geomar.de/equipment/equipment/SO/CAM/SO_CAM-1_Photo_OFOS/"
},
"image-pi": {
"name": "Timm Schoening",
"uri":"https://orcid.org/0000-0002-0035-3282"
},
"image-context": {
"name": "Text Context",
"uri": "https://example.com"
},
"image-creators": [
{
"name": "Timm Schoening",
"uri": "https://orcid.org/0000-0002-0035-3282"
}
]
},
"image-set-items": {
"SO268-2_100-1_OFOS_SO_CAM-1_20190406_042927.JPG": {
"image-datetime": "2019-04-06 04:29:27.000000",
"image-uuid": "61056dd9-8230-42df-bf7a-395b03d09f98",
"image-hash-sha256": "0193d337cc4ed6f64ee7e6bb4ccb811b9714c0007632a64abc944ec420e81e45",
"image-handle": "https://example.com/61056dd9-8230-42df-bf7a-395b03d09f98",
"image-depth": 2248,
"image-camera-yaw-degrees": 20
}
}
}

0 comments on commit 1feda4b

Please sign in to comment.