use of com.github.sebastianfrey.joa.models.Queryables 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.Queryables in project joa by sebastianfrey.
the class GeoPackageServiceTest method should_return_queryables_from_collection_of_lines.
@Test
public void should_return_queryables_from_collection_of_lines() {
Queryables queryables = geoPackageService.getQueryables(TEST_SERVICE, TEST_COLLECTION_LINE);
assertThat(queryables).isNotNull();
assertThat(queryables.getServiceId()).isEqualTo("example");
assertThat(queryables.getCollectionId()).isEqualTo("line1");
assertThat(queryables.getSchema()).satisfies((schema) -> {
assertThat(schema.getProperties()).isNotEmpty();
assertThat(schema.getProperties()).containsKey("geometry");
assertThat(schema.getProperties()).containsValue(Schemas.GeoJSON.lineString());
});
}
use of com.github.sebastianfrey.joa.models.Queryables in project joa by sebastianfrey.
the class GeoPackageServiceTest method should_return_queryables_from_collection_of_points.
@Test
public void should_return_queryables_from_collection_of_points() {
Queryables queryables = geoPackageService.getQueryables(TEST_SERVICE, TEST_COLLECTION_POINT);
assertThat(queryables).isNotNull();
assertThat(queryables.getServiceId()).isEqualTo("example");
assertThat(queryables.getCollectionId()).isEqualTo("point1");
assertThat(queryables.getSchema()).satisfies((schema) -> {
assertThat(schema.getProperties()).isNotEmpty();
assertThat(schema.getProperties()).containsKey("geometry");
assertThat(schema.getProperties()).containsValue(Schemas.GeoJSON.point());
});
}
use of com.github.sebastianfrey.joa.models.Queryables in project joa by sebastianfrey.
the class GeoPackageService method getQueryables.
@Override
public Queryables getQueryables(String serviceId, String collectionId) {
try (GeoPackage gpkg = loadService(serviceId)) {
ObjectType schema = JSONSchemaBuilder.objectType().title(collectionId).schema(Schemas.DRAFT_2019_09);
FeatureDao featureDao = loadCollection(gpkg, collectionId);
String geometryColumn = featureDao.getGeometryColumnName();
featureDao.getColumns().stream().forEach((column) -> {
if (column.isGeometry()) {
return;
}
Long max = column.getMax();
Object defaultValue = column.getDefaultValue();
GenericType<?> type = null;
switch(column.getDataType()) {
case BOOLEAN:
type = JSONSchemaBuilder.booleanType();
break;
case BLOB:
case TINYINT:
case TEXT:
type = JSONSchemaBuilder.stringType().maxLength(max);
break;
case DATE:
type = JSONSchemaBuilder.stringType().maxLength(max).format("date");
break;
case DATETIME:
type = JSONSchemaBuilder.stringType().maxLength(max).format("date-time");
break;
case DOUBLE:
case FLOAT:
case REAL:
type = JSONSchemaBuilder.numberType();
break;
case INT:
case INTEGER:
case MEDIUMINT:
case SMALLINT:
type = JSONSchemaBuilder.integerType().maximum(max);
break;
default:
break;
}
if (type == null) {
return;
}
String columnName = column.getName();
type.title(columnName);
if (defaultValue != null) {
type.defaultValue(defaultValue.toString());
}
schema.property(columnName, type);
});
GeometryType geometryType = featureDao.getGeometryType();
JSONSchema geometrySchema = null;
switch(geometryType) {
case GEOMETRY:
geometrySchema = Schemas.GeoJSON.geometry();
break;
case POINT:
geometrySchema = Schemas.GeoJSON.point();
break;
case LINESTRING:
geometrySchema = Schemas.GeoJSON.lineString();
break;
case POLYGON:
geometrySchema = Schemas.GeoJSON.polygon();
break;
case MULTIPOINT:
geometrySchema = Schemas.GeoJSON.multiPoint();
break;
case MULTILINESTRING:
geometrySchema = Schemas.GeoJSON.multiLineString();
break;
case MULTIPOLYGON:
geometrySchema = Schemas.GeoJSON.multiPolygon();
break;
default:
break;
}
if (geometrySchema != null) {
schema.property(geometryColumn, geometrySchema);
}
return new Queryables().serviceId(serviceId).collectionId(collectionId).schema(schema);
}
}
use of com.github.sebastianfrey.joa.models.Queryables in project joa by sebastianfrey.
the class GeoPackageServiceTest method should_return_queryables_from_collection_of_polygons.
@Test
public void should_return_queryables_from_collection_of_polygons() {
Queryables queryables = geoPackageService.getQueryables(TEST_SERVICE, TEST_COLLECTION_POLYGON);
assertThat(queryables).isNotNull();
assertThat(queryables.getServiceId()).isEqualTo("example");
assertThat(queryables.getCollectionId()).isEqualTo("polygon1");
assertThat(queryables.getSchema()).satisfies((schema) -> {
assertThat(schema.getProperties()).isNotEmpty();
assertThat(schema.getProperties()).containsKey("geometry");
assertThat(schema.getProperties()).containsValue(Schemas.GeoJSON.polygon());
});
}
Aggregations