Skip to content

Commit

Permalink
add indicators param to /tiles (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
sleeping-h authored Oct 29, 2024
1 parent 89f660f commit 472ee10
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

public interface InsightsApiClient {

ResponseEntity<byte[]> getBivariateTileMvt(Integer z, Integer x, Integer y, String indicatorsClass);
ResponseEntity<byte[]> getBivariateTileMvt(Integer z, Integer x, Integer y, String indicatorsClass, String indicators);

ResponseEntity<byte[]> getBivariateTileMvtV2(Integer z, Integer x, Integer y, String indicatorsClass);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
public class InsightsApiClientDummy implements InsightsApiClient {

@Override
public ResponseEntity<byte[]> getBivariateTileMvt(Integer z, Integer x, Integer y, String indicatorsClass) {
public ResponseEntity<byte[]> getBivariateTileMvt(Integer z, Integer x, Integer y, String indicatorsClass, String indicators) {
return ResponseEntity.ok()
.body(new byte[0]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ public InsightsApiClientImpl(RestTemplate insightsApiRestTemplate, MeterRegistry

@Override
@Timed(value = "insights.getBivariateTileMvt", histogram = true)
public ResponseEntity<byte[]> getBivariateTileMvt(Integer z, Integer x, Integer y, String indicatorsClass) {
public ResponseEntity<byte[]> getBivariateTileMvt(Integer z, Integer x, Integer y, String indicatorsClass, String indicators) {
if ("all".equals(indicatorsClass)) {
incrementForCorrectLabels(z, AUTHENTICATED);
} else {
incrementForCorrectLabels(z, NOT_AUTHENTICATED);
}
return insightsApiRestTemplate.getForEntity(String.format(INSIGHTS_API_TILE_MVT_URI, z, x, y, indicatorsClass),
return insightsApiRestTemplate.getForEntity(String.format(INSIGHTS_API_TILE_MVT_URI + (indicators == null ? "" : "&indicators=" + indicators), z, x, y, indicatorsClass),
byte[].class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ public class TileController {
content = @Content(mediaType = "application/vnd.mapbox-vector-tile", schema = @Schema(implementation = byte[].class)))
@GetMapping(value = "/bivariate/v1/{z}/{x}/{y}.mvt", produces = "application/vnd.mapbox-vector-tile")
public ResponseEntity<byte[]> getBivariateTileMvt(@PathVariable Integer z, @PathVariable Integer x, @PathVariable Integer y,
@RequestParam(defaultValue = "all") String indicatorsClass){
return tileService.getBivariateTileMvt(z, x, y, indicatorsClass);
@RequestParam(defaultValue = "all") String indicatorsClass,
@RequestParam(required = false) String indicators){
return tileService.getBivariateTileMvt(z, x, y, indicatorsClass, indicators);
}

@Operation(summary = "Returns bivariate mvt tile using z, x, y, indicator class and Insights API service version 2.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public class TileService {

private final InsightsApiClient insightsApiClient;

public ResponseEntity<byte[]> getBivariateTileMvt(Integer z, Integer x, Integer y, String indicatorsClass){
return insightsApiClient.getBivariateTileMvt(z, x, y, indicatorsClass);
public ResponseEntity<byte[]> getBivariateTileMvt(Integer z, Integer x, Integer y, String indicatorsClass, String indicators){
return insightsApiClient.getBivariateTileMvt(z, x, y, indicatorsClass, indicators);
}

public ResponseEntity<byte[]> getBivariateTileMvtV2(Integer z, Integer x, Integer y, String indicatorsClass){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void testGetBivariateTileMvt() {
MediaType.parseMediaType("application/vnd.mapbox-vector-tile")));

//when
byte[] tile = client.getBivariateTileMvt(z, x, y, "all").getBody();
byte[] tile = client.getBivariateTileMvt(z, x, y, "all", null).getBody();

//then
assertNotNull(tile);
Expand Down Expand Up @@ -86,4 +86,4 @@ public void testGetBivariateTileMvtV2() {
assertNotNull(tile);
assertEquals(100, tile.length);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ public void getBivariateTileMvtTest() {
Integer x = 8;
Integer y = 6;

when(insightsApiClient.getBivariateTileMvt(z, x, y, "all")).thenReturn(result);
when(insightsApiClient.getBivariateTileMvt(z, x, y, "all", null)).thenReturn(result);

byte[] tile = service.getBivariateTileMvt(z, x, y, "all").getBody();
byte[] tile = service.getBivariateTileMvt(z, x, y, "all", null).getBody();

verify(insightsApiClient).getBivariateTileMvt(z, x, y, "all");
verify(insightsApiClient).getBivariateTileMvt(z, x, y, "all", null);
assertEquals(100, tile.length);
}
}
}

0 comments on commit 472ee10

Please sign in to comment.