Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;

import java.math.BigDecimal;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Date;
Expand Down Expand Up @@ -206,9 +207,10 @@ default <D extends StacCollectionModel> Collection getCollection(D m, Filter fil
}

if (g != null && !g.isEmpty()) {
List<List<BigDecimal>> centroid = createCentroid(g);
collection.getProperties().put(
CollectionProperty.centroid,
createCentroid(g)
centroid
);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ public BBoxImpl(Expression geometry, Expression bounds, MultiValuedFilter.MatchA
if (bounds instanceof Literal literal) {
Object value = literal.getValue();
if (value instanceof BoundingBox3D boundingBox3D) {
//TODO: Handle BoundingBox3D
}
else if (value instanceof Geometry g && geometry instanceof PropertyName name) {
if (g.getUserData() instanceof CoordinateReferenceSystem crs) {
//TODO: Handle CRS
}
}
}
Expand All @@ -57,8 +59,6 @@ public BBoxImpl(
catch (NoSuchAuthorityCodeException var16) {
crs = CRS.parseWKT(srs);
}
} else {
crs = null;
}
this.bounds = new ReferencedEnvelope(minx, maxx, miny, maxy, crs);
this.geometry = BboxUtils.normalizeBbox(minx, maxx, miny, maxy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import au.org.aodn.ogcapi.server.core.model.enumeration.CQLFields;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.annotation.Lazy;

Expand Down Expand Up @@ -45,4 +46,12 @@ public Map<String, StacCollectionModel> getAllNoLandGeometry() {
.stream()
.collect(Collectors.toMap(StacCollectionModel::getUuid, Function.identity()));
}
/**
* Call this through the Spring bean
* so the {@code @CacheEvict} advice runs. The next {@link #getAllNoLandGeometry()} reloads it.
*/
@CacheEvict(value = ALL_NO_LAND_GEOMETRY, allEntries = true)
public void evictAllNoLandGeometry() {
log.info("Evicting cache {}", ALL_NO_LAND_GEOMETRY);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,6 @@ protected void insertJsonToElasticRecordIndex(String... filenames) throws IOExce
this.insertJsonToElasticIndex(record_index_name, filenames);
}

protected void insertJsonToElasticCODataIndex(String... filenames) throws IOException {
this.insertJsonToElasticIndex(co_data_index_name, filenames);
}

protected Response getClusterHealth() throws IOException {
return transport.restClient().performRequest(new Request("GET", "/_cluster/health"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import au.org.aodn.ogcapi.server.core.model.ErrorResponse;
import au.org.aodn.ogcapi.server.core.model.ExtendedCollections;
import au.org.aodn.ogcapi.server.core.model.enumeration.OGCMediaTypeMapper;
import au.org.aodn.ogcapi.server.core.service.CacheNoLandGeometry;
import org.junit.jupiter.api.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpMethod;
Expand All @@ -24,6 +26,9 @@
@TestInstance(TestInstance.Lifecycle.PER_CLASS) // We need to use @BeforeAll @AfterAll with not static method
public class RestApiTest extends BaseTestClass {

@Autowired
private CacheNoLandGeometry cacheNoLandGeometry;

@BeforeAll
public void beforeClass() {
super.createElasticIndex();
Expand Down Expand Up @@ -842,4 +847,23 @@ public void verifyCacheHeaderSetForQuery() throws IOException {

assertNotNull(collections.getHeaders().getFirst("Cache-Control"));
}

@Test
public void verifyCentroidCalIsCorrect() throws IOException {
super.insertJsonToElasticRecordIndex("097a5435-91f4-4730-90aa-ddae94afcbda.json");
// The json is insert after cache created, we need to evit it so it can reload
cacheNoLandGeometry.evictAllNoLandGeometry();

String expected = """
{"links":[],"collections":[{"properties":{"centroid":[[129.19579,-33.09197]]},"id":"097a5435-91f4-4730-90aa-ddae94afcbda","links":[],"itemType":"Collection"}],"total":1,"search_after":["0.0","str:097a5435-91f4-4730-90aa-ddae94afcbda"]}""";

ResponseEntity<String> collections = testRestTemplate.exchange(
getBasePath() + "/collections?properties=id,centroid&q=097a5435-91f4-4730-90aa-ddae94afcbda&filter=page_size=800 AND BBOX(geometry,117.21720908167362,-34.63803401514584,149.78279091832303,-16.36196598484962)&sortby=id",
HttpMethod.GET,
null,
new ParameterizedTypeReference<>() {});

assertNotNull(collections.getBody());
assertEquals(expected, collections.getBody());
}
}

Large diffs are not rendered by default.

Loading