Skip to content

Commit

Permalink
implementing geojson response for all /groupBy/boundary requests
Browse files Browse the repository at this point in the history
works so far only if geojson is given as input
  • Loading branch information
kowatsch committed Jul 16, 2018
1 parent d193b96 commit 5bd6f4c
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class ParameterDescriptions {
"OSM value(s) e.g.: 'primary', 'residential'; default: no value";
public static final String USERIDS_DESCR = "OSM userids; default: no userid";
public static final String TIME_DESCR = "ISO-8601 conform timestring(s); default: today";
public static final String FORMAT_DESCR = "Output format, e.g.: geojson; default: json";
public static final String SHOW_METADATA_DESCR =
"'Boolean' operator 'true' or 'false'; default: 'false'";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,15 @@ public GroupByResponse getAreaGroupByBoundary(
required = false) String[] userids,
@ApiParam(hidden = true) @RequestParam(value = "time", defaultValue = "",
required = false) String[] time,
@ApiParam(hidden = true) @RequestParam(value = "format", defaultValue = "",
required = false) String format,
@ApiParam(hidden = true) @RequestParam(value = "showMetadata",
defaultValue = "false") String showMetadata)
throws UnsupportedOperationException, Exception {

return ElementsRequestExecutor.executeCountLengthPerimeterAreaGroupByBoundary(
RequestResource.AREA, new RequestParameters(false, true, false, bboxes, bcircles, bpolys,
types, keys, values, userids, time, showMetadata));
RequestResource.AREA, RequestParameters.of(false, true, false, bboxes, bcircles, bpolys,
types, keys, values, userids, time, format, showMetadata));
}

/**
Expand Down Expand Up @@ -819,6 +821,8 @@ public GroupByResponse postAreaGroupByUser(String bboxes, String bcircles, Strin
@ApiImplicitParam(name = "time", paramType = "form", dataType = "string",
defaultValue = DefaultSwaggerParameters.TIME, required = false,
value = ParameterDescriptions.TIME_DESCR),
@ApiImplicitParam(name = "format", paramType = "form", dataType = "string", required = false,
value = ParameterDescriptions.FORMAT_DESCR),
@ApiImplicitParam(name = "showMetadata", paramType = "form", dataType = "string",
defaultValue = DefaultSwaggerParameters.SHOW_METADATA, required = false,
value = ParameterDescriptions.SHOW_METADATA_DESCR)})
Expand All @@ -830,8 +834,8 @@ public GroupByResponse postAreaGroupByBoundary(String bboxes, String bcircles, S
throws UnsupportedOperationException, Exception, BadRequestException {

return ElementsRequestExecutor.executeCountLengthPerimeterAreaGroupByBoundary(
RequestResource.AREA, new RequestParameters(true, true, false, bboxes, bcircles, bpolys,
types, keys, values, userids, time, showMetadata));
RequestResource.AREA, RequestParameters.of(false, true, false, bboxes, bcircles, bpolys,
types, keys, values, userids, time, format, showMetadata));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -843,18 +843,21 @@ public GroupByResponse postCountGroupByUser(String bboxes, String bcircles, Stri
@ApiImplicitParam(name = "time", paramType = "form", dataType = "string",
defaultValue = DefaultSwaggerParameters.TIME, required = false,
value = ParameterDescriptions.TIME_DESCR),
@ApiImplicitParam(name = "format", paramType = "form", dataType = "string", required = false,
value = ParameterDescriptions.FORMAT_DESCR),
@ApiImplicitParam(name = "showMetadata", paramType = "form", dataType = "string",
defaultValue = DefaultSwaggerParameters.SHOW_METADATA, required = false,
value = ParameterDescriptions.SHOW_METADATA_DESCR)})
@RequestMapping(value = "/groupBy/boundary", method = RequestMethod.POST,
produces = "application/json", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public GroupByResponse postCountGroupByBoundary(String bboxes, String bcircles, String bpolys,
String[] types, String[] keys, String[] values, String[] userids, String[] time,
String showMetadata) throws UnsupportedOperationException, Exception, BadRequestException {
String format, String showMetadata)
throws UnsupportedOperationException, Exception, BadRequestException {

return ElementsRequestExecutor.executeCountLengthPerimeterAreaGroupByBoundary(
RequestResource.COUNT, new RequestParameters(true, true, false, bboxes, bcircles, bpolys,
types, keys, values, userids, time, showMetadata));
RequestResource.COUNT, RequestParameters.of(true, true, false, bboxes, bcircles, bpolys,
types, keys, values, userids, time, format, showMetadata));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,15 @@ public GroupByResponse getLengthGroupByBoundary(
required = false) String[] userids,
@ApiParam(hidden = true) @RequestParam(value = "time", defaultValue = "",
required = false) String[] time,
@ApiParam(hidden = true) @RequestParam(value = "format", defaultValue = "",
required = false) String format,
@ApiParam(hidden = true) @RequestParam(value = "showMetadata",
defaultValue = "false") String showMetadata)
throws UnsupportedOperationException, Exception {

return ElementsRequestExecutor.executeCountLengthPerimeterAreaGroupByBoundary(
RequestResource.LENGTH, new RequestParameters(false, true, false, bboxes, bcircles, bpolys,
types, keys, values, userids, time, showMetadata));
RequestResource.LENGTH, RequestParameters.of(false, true, false, bboxes, bcircles, bpolys,
types, keys, values, userids, time, format, showMetadata));
}

/**
Expand Down Expand Up @@ -692,6 +694,8 @@ RequestResource.LENGTH, new RequestParameters(true, true, false, bboxes, bcircle
@ApiImplicitParam(name = "time", paramType = "form", dataType = "string",
defaultValue = DefaultSwaggerParameters.TIME, required = false,
value = ParameterDescriptions.TIME_DESCR),
@ApiImplicitParam(name = "format", paramType = "form", dataType = "string", required = false,
value = ParameterDescriptions.FORMAT_DESCR),
@ApiImplicitParam(name = "showMetadata", paramType = "form", dataType = "string",
defaultValue = DefaultSwaggerParameters.SHOW_METADATA, required = false,
value = ParameterDescriptions.SHOW_METADATA_DESCR)})
Expand All @@ -703,8 +707,8 @@ public GroupByResponse postLengthGroupByBoundary(String bboxes, String bcircles,
throws UnsupportedOperationException, Exception, BadRequestException {

return ElementsRequestExecutor.executeCountLengthPerimeterAreaGroupByBoundary(
RequestResource.LENGTH, new RequestParameters(true, true, false, bboxes, bcircles, bpolys,
types, keys, values, userids, time, showMetadata));
RequestResource.LENGTH, RequestParameters.of(true, true, false, bboxes, bcircles, bpolys,
types, keys, values, userids, time, format, showMetadata));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,15 @@ public GroupByResponse getPerimeterGroupByBoundary(
required = false) String[] userids,
@ApiParam(hidden = true) @RequestParam(value = "time", defaultValue = "",
required = false) String[] time,
@ApiParam(hidden = true) @RequestParam(value = "format", defaultValue = "",
required = false) String format,
@ApiParam(hidden = true) @RequestParam(value = "showMetadata",
defaultValue = "false") String showMetadata)
throws UnsupportedOperationException, Exception {

return ElementsRequestExecutor.executeCountLengthPerimeterAreaGroupByBoundary(
RequestResource.PERIMETER, new RequestParameters(false, true, false, bboxes, bcircles,
bpolys, types, keys, values, userids, time, showMetadata));
RequestResource.PERIMETER, RequestParameters.of(false, true, false, bboxes, bcircles,
bpolys, types, keys, values, userids, time, format, showMetadata));
}

/**
Expand Down Expand Up @@ -820,6 +822,8 @@ RequestResource.PERIMETER, new RequestParameters(true, true, false, bboxes, bcir
@ApiImplicitParam(name = "time", paramType = "form", dataType = "string",
defaultValue = DefaultSwaggerParameters.TIME, required = false,
value = ParameterDescriptions.TIME_DESCR),
@ApiImplicitParam(name = "format", paramType = "form", dataType = "string", required = false,
value = ParameterDescriptions.FORMAT_DESCR),
@ApiImplicitParam(name = "showMetadata", paramType = "form", dataType = "string",
defaultValue = DefaultSwaggerParameters.SHOW_METADATA, required = false,
value = ParameterDescriptions.SHOW_METADATA_DESCR)})
Expand All @@ -831,8 +835,8 @@ public GroupByResponse postPerimeterGroupByBoundary(String bboxes, String bcircl
throws UnsupportedOperationException, Exception, BadRequestException {

return ElementsRequestExecutor.executeCountLengthPerimeterAreaGroupByBoundary(
RequestResource.PERIMETER, new RequestParameters(true, true, false, bboxes, bcircles,
bpolys, types, keys, values, userids, time, showMetadata));
RequestResource.PERIMETER, RequestParameters.of(true, true, false, bboxes, bcircles, bpolys,
types, keys, values, userids, time, format, showMetadata));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ public static GroupByResponse executeCountLengthPerimeterAreaGroupByBoundary(
metadata = new Metadata(duration, Description.countLengthPerimeterAreaGroupByBoundary(
requestResource.getLabel(), requestResource.getUnit()), requestURL);
}

if (rPs.getFormat() != null && rPs.getFormat().equalsIgnoreCase("geojson")) {
GroupByResponse response = GroupByResponse.of(new Attribution(url, text),
Application.apiVersion, metadata, "FeatureCollection",
Expand Down

0 comments on commit 5bd6f4c

Please sign in to comment.