Search in sources :

Example 1 with Collections

use of com.github.sebastianfrey.joa.models.Collections 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;
}
Also used : Collection(com.github.sebastianfrey.joa.models.Collection) GeoPackage(mil.nga.geopackage.GeoPackage) Collections(com.github.sebastianfrey.joa.models.Collections)

Example 2 with Collections

use of com.github.sebastianfrey.joa.models.Collections 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);
}
Also used : Queryables(com.github.sebastianfrey.joa.models.Queryables) Services(com.github.sebastianfrey.joa.models.Services) Spatial(com.github.sebastianfrey.joa.models.Spatial) Bbox(com.github.sebastianfrey.joa.models.Bbox) OGCAPIService(com.github.sebastianfrey.joa.services.OGCAPIService) Service(com.github.sebastianfrey.joa.models.Service) Collection(com.github.sebastianfrey.joa.models.Collection) Conformance(com.github.sebastianfrey.joa.models.Conformance) Collections(com.github.sebastianfrey.joa.models.Collections) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with Collections

use of com.github.sebastianfrey.joa.models.Collections in project joa by sebastianfrey.

the class OGCAPIServiceResourceTest method should_return_the_collections.

@Test
public void should_return_the_collections() {
    when(DAO.getCollections("service1")).thenReturn(collections);
    Collections found = EXT.target("/service1/collections").queryParam("f", "json").request().get(Collections.class);
    // verify that ogcApisService.getCollections(...) was called
    verify(DAO).getCollections("service1");
    assertThat(found.getTitle()).isEqualTo(collections.getTitle());
    assertThat(found.getDescription()).isEqualTo(collections.getDescription());
    assertThat(found.getCollections()).satisfies(($collections) -> {
        // there must be at least one collection
        assertThat($collections).isNotEmpty();
        assertThat($collections.get(0)).satisfies(($collection) -> {
            assertThat($collection.getId()).isEqualTo(collection.getId());
            assertThat($collection.getItemType()).isEqualTo(collection.getItemType());
            assertThat($collection.getTitle()).isEqualTo(collection.getTitle());
            assertThat($collection.getDescription()).isEqualTo(collection.getDescription());
            assertThat($collection.getCrs()).containsExactlyElementsOf(collection.getCrs());
            assertThat($collection.getExtent()).satisfies(($extent) -> {
                assertThat($extent.getSpatial()).satisfies(($spatial) -> {
                    assertThat($spatial.getBbox()).isNotEmpty();
                    assertThat($spatial.getBbox().get(0)).containsExactlyElementsOf(spatial.getBbox().get(0));
                });
            });
            assertThat($collection.getLinks()).satisfies((links) -> {
                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));
            });
        });
    });
    assertThat(found.getLinks()).satisfies((links) -> {
        assertThat(links).isNotEmpty();
        assertThat(links).anyMatch((link) -> link.getRel().equals(Linkable.SELF));
    });
}
Also used : Collections(com.github.sebastianfrey.joa.models.Collections) Test(org.junit.jupiter.api.Test)

Example 4 with Collections

use of com.github.sebastianfrey.joa.models.Collections in project joa by sebastianfrey.

the class GeoPackageServiceTest method should_return_collections_from_service.

@Test
public void should_return_collections_from_service() {
    Collections collections = geoPackageService.getCollections(TEST_SERVICE);
    assertThat(collections).isNotNull();
    assertThat(collections.getServiceId()).isEqualTo("example");
    assertThat(collections.getTitle()).isEqualTo("example");
    assertThat(collections.getCollections()).isNotEmpty();
}
Also used : Collections(com.github.sebastianfrey.joa.models.Collections) Test(org.junit.jupiter.api.Test)

Aggregations

Collections (com.github.sebastianfrey.joa.models.Collections)4 Collection (com.github.sebastianfrey.joa.models.Collection)2 Test (org.junit.jupiter.api.Test)2 Bbox (com.github.sebastianfrey.joa.models.Bbox)1 Conformance (com.github.sebastianfrey.joa.models.Conformance)1 Queryables (com.github.sebastianfrey.joa.models.Queryables)1 Service (com.github.sebastianfrey.joa.models.Service)1 Services (com.github.sebastianfrey.joa.models.Services)1 Spatial (com.github.sebastianfrey.joa.models.Spatial)1 OGCAPIService (com.github.sebastianfrey.joa.services.OGCAPIService)1 GeoPackage (mil.nga.geopackage.GeoPackage)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1