use of com.github.sebastianfrey.joa.models.Collection in project joa by sebastianfrey.
the class GeoPackageService method createCollection.
public Collection createCollection(String serviceId, FeatureDao featureDao) {
Contents contents = featureDao.getContents();
String collectionId = contents.getTableName();
String title = contents.getIdentifier();
String description = contents.getDescription();
String crs = CrsUtils.epsg(contents.getSrsId());
GeometryEnvelope envelope = contents.getBoundingBox().buildEnvelope();
Bbox bbox = new Bbox().minX(envelope.getMinX()).minY(envelope.getMinY()).minZ(envelope.getMinZ()).maxX(envelope.getMaxX()).maxY(envelope.getMaxY()).maxZ(envelope.getMaxZ());
List<String> temporal = new ArrayList<String>();
temporal.add(null);
temporal.add(null);
Collection collection = new Collection().serviceId(serviceId).collectionId(collectionId).title(title).description(description).crs(crs).itemType("feature").spatial(new Spatial().bbox(bbox).crs(crs)).interval(temporal);
return collection;
}
use of com.github.sebastianfrey.joa.models.Collection in project joa by sebastianfrey.
the class GeoPackageService method getCollections.
/**
* Returns all collections for a given GeoPackage aka Service.
*
* @param serviceId The name of the GeoPackage file.
*
* @return
*/
@Override
public Collections getCollections(String serviceId) {
Collections collections = new Collections().serviceId(serviceId).title(serviceId);
try (GeoPackage gpkg = loadService(serviceId)) {
List<String> collectionIds = gpkg.getFeatureTables();
for (String collectionId : collectionIds) {
Collection collection = getCollection(gpkg, serviceId, collectionId);
collections.collection(collection);
}
}
return collections;
}
use of com.github.sebastianfrey.joa.models.Collection in project joa by sebastianfrey.
the class OGCAPIServiceResourceTest method setup.
@BeforeEach
void setup() {
queryables = new Queryables();
service = new Service().serviceId("service1").title("service1 title").description("service1 description");
services = new Services().service(service);
bbox = new Bbox().minX(-104.807496).minY(39.71408499999999).maxX(-104.79948).maxY(39.72001399999999);
spatial = new Spatial().bbox(bbox).crs(CrsUtils.crs84());
collection = new Collection().serviceId("service1").collectionId("collection1").crs(CrsUtils.crs84()).spatial(spatial).title("collection1 title").description("collection1 description");
collections = new Collections().serviceId("serviceId").title("collections title").collection(collection);
items = new TestItems().serviceId("service1").collectionId("collection1").numberMatched(Long.valueOf(0));
item = new TestItem().serviceId("service1").collectionId("collection1");
conformance = new Conformance().serviceId("service1").conformsTo(Conformance.FEATURES_CORE).conformsTo(Conformance.FEATURES_GEOJSON).conformsTo(Conformance.FEATURES_OAS30);
}
use of com.github.sebastianfrey.joa.models.Collection in project joa by sebastianfrey.
the class OGCAPIServiceResourceTest method should_return_the_requested_collection.
@Test
public void should_return_the_requested_collection() throws Exception {
when(DAO.getCollection("service1", "collection1")).thenReturn(collection);
Collection found = EXT.target("/service1/collections/collection1").queryParam("f", "json").request().get(Collection.class);
// verify that ogcApisService.getCollection(...) was called
verify(DAO).getCollection("service1", "collection1");
assertThat(found.getId()).isEqualTo(collection.getId());
assertThat(found.getItemType()).isEqualTo(collection.getItemType());
assertThat(found.getTitle()).isEqualTo(collection.getTitle());
assertThat(found.getDescription()).isEqualTo(collection.getDescription());
assertThat(found.getCrs()).containsExactlyElementsOf(collection.getCrs());
assertThat(found.getExtent()).satisfies(($extent) -> {
assertThat($extent.getSpatial()).satisfies(($spatial) -> {
assertThat($spatial.getBbox()).isNotEmpty();
assertThat($spatial.getBbox().get(0)).containsExactlyElementsOf(spatial.getBbox().get(0));
});
});
assertThat(found.getLinks()).satisfies((links) -> {
assertThat(links).isNotEmpty();
assertThat(links).anyMatch((link) -> link.getRel().equals(Linkable.SELF));
assertThat(links).anyMatch((link) -> link.getRel().equals(Linkable.ITEMS));
assertThat(links).anyMatch((link) -> link.getRel().equals(Linkable.QUERYABLES));
});
}
use of com.github.sebastianfrey.joa.models.Collection in project joa by sebastianfrey.
the class GeoPackageServiceTest method should_return_collection_from_service.
@Test
public void should_return_collection_from_service() {
Collection collection = geoPackageService.getCollection(TEST_SERVICE, TEST_COLLECTION_POINT);
assertThat(collection).isNotNull();
assertThat(collection.getServiceId()).isEqualTo("example");
assertThat(collection.getCollectionId()).isEqualTo("point1");
assertThat(collection.getId()).isEqualTo("point1");
assertThat(collection.getTitle()).isEqualTo("point1");
assertThat(collection.getExtent()).satisfies((extent) -> {
assertThat(extent.getSpatial().getBbox()).isNotEmpty();
assertThat(extent.getTemporal().getInterval()).isNotEmpty();
});
}
Aggregations