Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WCS loader to skip coverages with wrong spatial axes labels. #91

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/main/java/org/openeo/spring/loaders/WCSCollectionsLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ public class WCSCollectionsLoader implements ICollectionsLoader {
/** Default internal concurrency. */
public static final int DEFAULT_NTHREADS = 5;

/**
* Index of elements not found in a Java lists.
* @see List#indexOf(Object)
*/
private static final int NOT_FOUND = -1;

/*
* members
*/
Expand Down Expand Up @@ -621,7 +627,7 @@ static Collection parseCollection(String coverageID, InputStream stream,

// guard
if (!axisLabels.contains(abbrev)) {
log.error("Spatial axis '{}' not found in coverage definition.", label);
log.warn("{}: spatial axis '{}' not found in coverage definition.", coverageID, label);
// skip or lenient?
}
}
Expand Down Expand Up @@ -829,6 +835,12 @@ else if (TEMPORAL_AXIS_LABELS.contains(label)) {
.map(x -> axisLabels.indexOf(x))
.collect(Collectors.toList()); //Java 9: .toList());

if (indexes.contains(NOT_FOUND)) {
log.error("{}: wrong spatial axes label(s): {}. Expected full list: {}",
coverageID, spatialAxisLabels, axisLabels);
return null;
}

double[] lowerCorner = indexes.stream()
.map(i -> Double.parseDouble(minValues[i]))
.mapToDouble(Double::doubleValue)
Expand Down Expand Up @@ -920,6 +932,7 @@ else if (TEMPORAL_AXIS_LABELS.contains(label)) {
List<Link> links = new ArrayList<>();

// licence link
// FIXME: <About_Link> of eg. ADO_SM_anomalies_ERA5 is not link, but a sentence containing links
String licenseLink = metadataElement.getChildText("License_Link", gmlNS);
if (null != licenseLink) {
Link link = new Link();
Expand All @@ -940,6 +953,7 @@ else if (TEMPORAL_AXIS_LABELS.contains(label)) {
}

// about link
// FIXME
String aboutLink = metadataElement.getChildText("About_Link");
if (null != aboutLink) {
Link link = new Link();
Expand Down Expand Up @@ -1067,7 +1081,7 @@ else if (TEMPORAL_AXIS_LABELS.contains(label)) {
provider.setUrl(new URI(link));
providers.add(provider);
} catch (URISyntaxException e) {
log.error("Invalid provider link. ", e);
log.error("{}: Invalid provider link.", coverageID, e);
return null;
}
}
Expand Down
Loading