use of io.arlas.server.core.model.CollectionReference in project ARLAS-server by gisaia.
the class GeoAggregateRESTService method geotilegeoaggregate.
@Timed
@Path("{collection}/_geoaggregate/{z}/{x}/{y}")
@GET
@Produces(UTF8JSON)
@Consumes(UTF8JSON)
@ApiOperation(value = "GeoAggregate on a geotile", produces = UTF8JSON, notes = Documentation.GEOTILE_GEOAGGREGATION_OPERATION, consumes = UTF8JSON, response = FeatureCollection.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation", response = FeatureCollection.class, responseContainer = "FeatureCollection"), @ApiResponse(code = 500, message = "Arlas Server Error.", response = Error.class), @ApiResponse(code = 400, message = "Bad request.", response = Error.class), @ApiResponse(code = 501, message = "Not implemented functionality.", response = Error.class) })
public Response geotilegeoaggregate(// --------------------------------------------------------
@ApiParam(name = "collection", value = "collection", required = true) @PathParam(value = "collection") String collection, @ApiParam(name = "z", value = "z", required = true) @PathParam(value = "z") Integer z, @ApiParam(name = "x", value = "x", required = true) @PathParam(value = "x") Integer x, @ApiParam(name = "y", value = "y", required = true) @PathParam(value = "y") Integer y, // --------------------------------------------------------
@ApiParam(name = "agg", value = Documentation.GEOAGGREGATION_PARAM_AGG) @QueryParam(value = "agg") List<String> agg, // --------------------------------------------------------
@ApiParam(name = "f", value = Documentation.FILTER_PARAM_F, allowMultiple = true) @QueryParam(value = "f") List<String> f, @ApiParam(name = "q", value = Documentation.FILTER_PARAM_Q, allowMultiple = true) @QueryParam(value = "q") List<String> q, @ApiParam(name = "dateformat", value = Documentation.FILTER_DATE_FORMAT) @QueryParam(value = "dateformat") String dateformat, @ApiParam(hidden = true) @HeaderParam(value = "partition-filter") String partitionFilter, @ApiParam(hidden = true) @HeaderParam(value = "Column-Filter") Optional<String> columnFilter, // --------------------------------------------------------
@ApiParam(name = "pretty", value = Documentation.FORM_PRETTY, defaultValue = "false") @QueryParam(value = "pretty") Boolean pretty, @ApiParam(name = "flat", value = Documentation.FORM_FLAT, defaultValue = "false") @QueryParam(value = "flat") Boolean flat, // --------------------------------------------------------
@ApiParam(value = "max-age-cache") @QueryParam(value = "max-age-cache") Integer maxagecache) throws NotFoundException, ArlasException {
CollectionReference collectionReference = exploreService.getCollectionReferenceService().getCollectionReference(collection);
if (collectionReference == null) {
throw new NotFoundException(collection);
}
if (agg == null || agg.size() == 0) {
agg = Collections.singletonList("geotile:" + collectionReference.params.centroidPath + ":interval-" + (z + 3));
}
List<BoundingBox> bboxes = getBoundingBoxes(z, x, y, agg, collectionReference);
List<CompletableFuture<AggregationResponse>> futureList = new ArrayList<>();
AggregationTypeEnum aggType = null;
for (BoundingBox b : bboxes) {
Expression pwithinBbox = new Expression(collectionReference.params.centroidPath, OperatorEnum.within, b.getWest() + "," + b.getSouth() + "," + String.format(Locale.ROOT, "%.8f", b.getEast() - GEOHASH_EPSILON) + "," + String.format(Locale.ROOT, "%.8f", b.getNorth() - GEOHASH_EPSILON));
MixedRequest request = getGeoaggregateRequest(collectionReference, ParamsParser.getFilter(collectionReference, f, q, dateformat, b, pwithinBbox), partitionFilter, columnFilter, agg);
aggType = ((AggregationsRequest) request.basicRequest).aggregations.get(0).type;
futureList.add(CompletableFuture.supplyAsync(() -> {
try {
return exploreService.aggregate(request, collectionReference, true, ((AggregationsRequest) request.basicRequest).aggregations, 0, System.nanoTime());
} catch (ArlasException e) {
throw new RuntimeException(e);
}
}));
}
List<AggregationResponse> aggResponses = futureList.stream().map(CompletableFuture::join).collect(Collectors.toList());
return cache(Response.ok(toGeoJson(merge(aggResponses), aggType, Boolean.TRUE.equals(flat), Optional.of(z + "/" + x + "/" + y))), maxagecache);
}
use of io.arlas.server.core.model.CollectionReference in project ARLAS-server by gisaia.
the class ComputeRESTService method computePost.
@Timed
@Path("{collection}/_compute")
@POST
@Produces(UTF8JSON)
@Consumes(UTF8JSON)
@ApiOperation(value = "Compute", produces = UTF8JSON, notes = Documentation.COMPUTE_OPERATION, consumes = UTF8JSON, response = ComputationResponse.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation", response = ComputationResponse.class, responseContainer = "ArlasComputation"), @ApiResponse(code = 500, message = "Arlas Server Error.", response = Error.class), @ApiResponse(code = 400, message = "Bad request.", response = Error.class) })
public Response computePost(// --------------------------------------------------------
@ApiParam(name = "collection", value = "collection", required = true) @PathParam(value = "collection") String collection, // --------------------------------------------------------
ComputationRequest computationRequest, @ApiParam(hidden = true) @HeaderParam(value = "partition-filter") String partitionFilter, @ApiParam(hidden = true) @HeaderParam(value = "Column-Filter") Optional<String> columnFilter, // --------------------------------------------------------
@ApiParam(name = "pretty", value = Documentation.FORM_PRETTY, defaultValue = "false") @QueryParam(value = "pretty") Boolean pretty, // --------------------------------------------------------
@ApiParam(value = "max-age-cache") @QueryParam(value = "max-age-cache") Integer maxagecache) throws NotFoundException, ArlasException {
CollectionReference collectionReference = exploreService.getCollectionReferenceService().getCollectionReference(collection);
if (collectionReference == null) {
throw new NotFoundException(collection);
}
ComputationRequest computationRequestHeader = new ComputationRequest();
computationRequestHeader.filter = ParamsParser.getFilter(partitionFilter);
MixedRequest request = new MixedRequest();
exploreService.setValidGeoFilters(collectionReference, computationRequest);
exploreService.setValidGeoFilters(collectionReference, computationRequestHeader);
ColumnFilterUtil.assertRequestAllowed(columnFilter, collectionReference, computationRequest);
request.basicRequest = computationRequest;
request.headerRequest = computationRequestHeader;
request.columnFilter = ColumnFilterUtil.getCollectionRelatedColumnFilter(columnFilter, collectionReference);
ComputationResponse computationResponse = exploreService.compute(request, collectionReference);
return cache(Response.ok(computationResponse), maxagecache);
}
use of io.arlas.server.core.model.CollectionReference in project ARLAS-server by gisaia.
the class RawRESTService method getArlasHit.
@Timed
@Path("{collection}/{identifier}")
@GET
@Produces(UTF8JSON)
@Consumes(UTF8JSON)
@ApiOperation(value = "Get an Arlas document", produces = UTF8JSON, notes = "Returns a raw indexed document.", consumes = UTF8JSON, response = Hit.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation", response = Hit.class), @ApiResponse(code = 500, message = "Arlas Server Error.", response = Error.class), @ApiResponse(code = 400, message = "Bad request.", response = Error.class), @ApiResponse(code = 404, message = "Not Found Error.", response = Error.class) })
public Response getArlasHit(// --------------------------------------------------------
@ApiParam(name = "collection", value = "collection", required = true) @PathParam(value = "collection") String collection, @ApiParam(name = "identifier", value = "identifier", required = true) @PathParam(value = "identifier") String identifier, // --------------------------------------------------------
@ApiParam(name = "pretty", value = "Pretty print", defaultValue = "false") @QueryParam(value = "pretty") Boolean pretty, @ApiParam(name = "flat", value = Documentation.FORM_FLAT, defaultValue = "false") @QueryParam(value = "flat") Boolean flat, @ApiParam(hidden = true) @HeaderParam(value = "Column-Filter") Optional<String> columnFilter, // --------------------------------------------------------
@ApiParam(value = "max-age-cache") @QueryParam(value = "max-age-cache") Integer maxagecache) throws ArlasException {
CollectionReference collectionReference = exploreService.getCollectionReferenceService().getCollectionReference(collection);
if (collectionReference == null) {
throw new NotFoundException("Collection " + collection + " not found.");
}
ColumnFilterUtil.assertCollectionsAllowed(columnFilter, Collections.singletonList(collectionReference));
String[] includes = ColumnFilterUtil.cleanColumnFilter(columnFilter).map(cf -> cf + "," + String.join(",", ColumnFilterUtil.getCollectionMandatoryPaths(collectionReference))).map(i -> i.split(",")).orElse(null);
Map<String, Object> source = exploreService.getRawDoc(collectionReference, identifier, includes);
if (source == null || source.isEmpty()) {
throw new NotFoundException("Document " + identifier + " not found.");
}
Hit hit = new Hit(collectionReference, source, Boolean.TRUE.equals(flat), false);
return cache(Response.ok(hit), maxagecache);
}
use of io.arlas.server.core.model.CollectionReference in project ARLAS-server by gisaia.
the class GeoSearchRESTService method tiledgeosearch.
@Timed
@Path("{collection}/_geosearch/{z}/{x}/{y}")
@GET
@Produces(UTF8JSON)
@Consumes(UTF8JSON)
@ApiOperation(value = "Tiled GeoSearch", produces = UTF8JSON, notes = Documentation.TILED_GEOSEARCH_OPERATION, consumes = UTF8JSON, response = FeatureCollection.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation", response = FeatureCollection.class, responseContainer = "FeatureCollection"), @ApiResponse(code = 500, message = "Arlas Server Error.", response = Error.class), @ApiResponse(code = 400, message = "Bad request.", response = Error.class) })
public Response tiledgeosearch(// --------------------------------------------------------
@ApiParam(name = "collection", value = "collection", required = true) @PathParam(value = "collection") String collection, @ApiParam(name = "x", value = "x", required = true) @PathParam(value = "x") Integer x, @ApiParam(name = "y", value = "y", required = true) @PathParam(value = "y") Integer y, @ApiParam(name = "z", value = "z", required = true) @PathParam(value = "z") Integer z, // --------------------------------------------------------
@ApiParam(name = "f", value = Documentation.FILTER_PARAM_F, allowMultiple = true) @QueryParam(value = "f") List<String> f, @ApiParam(name = "q", value = Documentation.FILTER_PARAM_Q, allowMultiple = true) @QueryParam(value = "q") List<String> q, @ApiParam(name = "dateformat", value = Documentation.FILTER_DATE_FORMAT) @QueryParam(value = "dateformat") String dateformat, @ApiParam(hidden = true) @HeaderParam(value = "partition-filter") String partitionFilter, @ApiParam(hidden = true) @HeaderParam(value = "Column-Filter") Optional<String> columnFilter, // --------------------------------------------------------
@ApiParam(name = "pretty", value = Documentation.FORM_PRETTY, defaultValue = "false") @QueryParam(value = "pretty") Boolean pretty, @ApiParam(name = "flat", value = Documentation.FORM_FLAT, defaultValue = "false") @QueryParam(value = "flat") Boolean flat, @ApiParam(name = "include", value = Documentation.PROJECTION_PARAM_INCLUDE, allowMultiple = true, defaultValue = "*") @QueryParam(value = "include") String include, @ApiParam(name = "exclude", value = Documentation.PROJECTION_PARAM_EXCLUDE, allowMultiple = true, defaultValue = "") @QueryParam(value = "exclude") String exclude, @ApiParam(name = "returned_geometries", value = Documentation.PROJECTION_PARAM_RETURNED_GEOMETRIES, defaultValue = "") @QueryParam(value = "returned_geometries") String returned_geometries, @ApiParam(name = "size", value = Documentation.PAGE_PARAM_SIZE, defaultValue = "10", allowableValues = "range[1, infinity]", type = "integer") @DefaultValue("10") @QueryParam(value = "size") IntParam size, @ApiParam(name = "from", value = Documentation.PAGE_PARAM_FROM, defaultValue = "0", allowableValues = "range[0, infinity]", type = "integer") @DefaultValue("0") @QueryParam(value = "from") IntParam from, @ApiParam(name = "sort", value = Documentation.PAGE_PARAM_SORT, allowMultiple = true) @QueryParam(value = "sort") String sort, @ApiParam(name = "after", value = Documentation.PAGE_PARAM_AFTER) @QueryParam(value = "after") String after, @ApiParam(name = "before", value = Documentation.PAGE_PARAM_BEFORE) @QueryParam(value = "before") String before, // --------------------------------------------------------
@ApiParam(value = "max-age-cache") @QueryParam(value = "max-age-cache") Integer maxagecache) throws NotFoundException, ArlasException {
CollectionReference collectionReference = exploreService.getCollectionReferenceService().getCollectionReference(collection);
if (collectionReference == null) {
throw new NotFoundException(collection);
}
BoundingBox bbox = GeoTileUtil.getBoundingBox(new Tile(x, y, z));
// west, south, east, north
Expression pwithinBbox = new Expression(collectionReference.params.centroidPath, OperatorEnum.within, bbox.getWest() + "," + bbox.getSouth() + "," + bbox.getEast() + "," + bbox.getNorth());
return geosearch(collectionReference, ParamsParser.getFilter(collectionReference, f, q, dateformat, bbox, pwithinBbox), partitionFilter, columnFilter, flat, include, exclude, size, from, sort, after, before, maxagecache, returned_geometries, false);
}
use of io.arlas.server.core.model.CollectionReference in project ARLAS-server by gisaia.
the class GeoSearchRESTService method geosearchPost.
@Timed
@Path("{collection}/_geosearch")
@POST
@Produces(UTF8JSON)
@Consumes(UTF8JSON)
@ApiOperation(value = "GeoSearch", produces = UTF8JSON, notes = Documentation.GEOSEARCH_OPERATION, consumes = UTF8JSON, response = FeatureCollection.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation", response = FeatureCollection.class, responseContainer = "FeatureCollection"), @ApiResponse(code = 500, message = "Arlas Server Error.", response = Error.class), @ApiResponse(code = 400, message = "Bad request.", response = Error.class) })
public Response geosearchPost(// --------------------------------------------------------
@ApiParam(name = "collection", value = "collection", required = true) @PathParam(value = "collection") String collection, // --------------------------------------------------------
Search search, @ApiParam(hidden = true) @HeaderParam(value = "partition-filter") String partitionFilter, @ApiParam(hidden = true) @HeaderParam(value = "Column-Filter") Optional<String> columnFilter, // --------------------------------------------------------
@ApiParam(name = "pretty", value = Documentation.FORM_PRETTY, defaultValue = "false") @QueryParam(value = "pretty") Boolean pretty, // --------------------------------------------------------
@ApiParam(value = "max-age-cache") @QueryParam(value = "max-age-cache") Integer maxagecache) throws NotFoundException, ArlasException {
CollectionReference collectionReference = exploreService.getCollectionReferenceService().getCollectionReference(collection);
if (collectionReference == null) {
throw new NotFoundException(collection);
}
String includes = search.projection != null ? search.projection.includes : null;
String excludes = search.projection != null ? search.projection.excludes : null;
CheckParams.checkReturnedGeometries(collectionReference, includes, excludes, search.returned_geometries);
Search searchHeader = new Search();
searchHeader.filter = ParamsParser.getFilter(partitionFilter);
exploreService.setValidGeoFilters(collectionReference, search);
exploreService.setValidGeoFilters(collectionReference, searchHeader);
ColumnFilterUtil.assertRequestAllowed(columnFilter, collectionReference, search);
search.projection = ParamsParser.enrichIncludes(search.projection, search.returned_geometries);
MixedRequest request = new MixedRequest();
request.basicRequest = search;
request.headerRequest = searchHeader;
request.columnFilter = ColumnFilterUtil.getCollectionRelatedColumnFilter(columnFilter, collectionReference);
FeatureCollection fc = exploreService.getFeatures(request, collectionReference, (search.form != null && search.form.flat));
return cache(Response.ok(fc), maxagecache);
}
Aggregations