Search in sources :

Example 1 with Bbox

use of com.github.sebastianfrey.joa.models.Bbox 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;
}
Also used : Contents(mil.nga.geopackage.contents.Contents) Spatial(com.github.sebastianfrey.joa.models.Spatial) Bbox(com.github.sebastianfrey.joa.models.Bbox) GeometryEnvelope(mil.nga.sf.GeometryEnvelope) ArrayList(java.util.ArrayList) Collection(com.github.sebastianfrey.joa.models.Collection)

Example 2 with Bbox

use of com.github.sebastianfrey.joa.models.Bbox 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 Bbox

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

the class GeoPackageQuery method buildBboxWhere.

public void buildBboxWhere(StringBuilder whereBuilder, List<String> whereArgs) throws Exception {
    // verify bbox
    Bbox bbox = query.getBbox();
    if (bbox == null) {
        return;
    }
    String geometryColumn = featureDao.getGeometryColumnName();
    String polygon = objectMapper.writeValueAsString(toPolygon(bbox));
    whereBuilder.append(" AND (ST_Intersects(").append(geometryColumn).append(", GeomFromGeoJSON(?)))");
    whereArgs.add(polygon);
}
Also used : Bbox(com.github.sebastianfrey.joa.models.Bbox)

Example 4 with Bbox

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

the class GeoPackageServiceTest method should_return_items_from_collection.

@Test
public void should_return_items_from_collection() throws Exception {
    FeatureQueryRequest query = new FeatureQueryRequest().offset(Long.valueOf(0)).limit(10).datetime(new Datetime("2021-03-04T17:44:25.873Z")).bbox(new Bbox().minX(-180.0).minY(-90.0).maxX(80.0).maxY(90.0));
    GeoPackageItems items = geoPackageService.getItems(TEST_SERVICE, TEST_COLLECTION_POINT, query);
    assertThat(items).isNotNull();
    assertThat(items.getServiceId()).isEqualTo("example");
    assertThat(items.getCollectionId()).isEqualTo("point1");
    assertThat(items.getFeatures()).isNotEmpty();
    assertThat(items.getNumberMatched()).isGreaterThan(Long.valueOf(0));
    assertThat(items.getNumberReturned()).isGreaterThan(0);
    assertThatCode(() -> Instant.parse(items.getTimeStamp())).doesNotThrowAnyException();
}
Also used : FeatureQueryRequest(com.github.sebastianfrey.joa.resources.request.FeatureQueryRequest) Bbox(com.github.sebastianfrey.joa.models.Bbox) Datetime(com.github.sebastianfrey.joa.models.Datetime) Test(org.junit.jupiter.api.Test)

Aggregations

Bbox (com.github.sebastianfrey.joa.models.Bbox)4 Collection (com.github.sebastianfrey.joa.models.Collection)2 Spatial (com.github.sebastianfrey.joa.models.Spatial)2 Collections (com.github.sebastianfrey.joa.models.Collections)1 Conformance (com.github.sebastianfrey.joa.models.Conformance)1 Datetime (com.github.sebastianfrey.joa.models.Datetime)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 FeatureQueryRequest (com.github.sebastianfrey.joa.resources.request.FeatureQueryRequest)1 OGCAPIService (com.github.sebastianfrey.joa.services.OGCAPIService)1 ArrayList (java.util.ArrayList)1 Contents (mil.nga.geopackage.contents.Contents)1 GeometryEnvelope (mil.nga.sf.GeometryEnvelope)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Test (org.junit.jupiter.api.Test)1