diff --git a/src/main/java/io/kontur/disasterninja/client/InsightsApiClient.java b/src/main/java/io/kontur/disasterninja/client/InsightsApiClient.java index 2dffbda0..85d61487 100644 --- a/src/main/java/io/kontur/disasterninja/client/InsightsApiClient.java +++ b/src/main/java/io/kontur/disasterninja/client/InsightsApiClient.java @@ -4,7 +4,7 @@ public interface InsightsApiClient { - ResponseEntity getBivariateTileMvt(Integer z, Integer x, Integer y, String indicatorsClass); + ResponseEntity getBivariateTileMvt(Integer z, Integer x, Integer y, String indicatorsClass, String indicators); ResponseEntity getBivariateTileMvtV2(Integer z, Integer x, Integer y, String indicatorsClass); } diff --git a/src/main/java/io/kontur/disasterninja/client/InsightsApiClientDummy.java b/src/main/java/io/kontur/disasterninja/client/InsightsApiClientDummy.java index 65561dfb..de41a452 100644 --- a/src/main/java/io/kontur/disasterninja/client/InsightsApiClientDummy.java +++ b/src/main/java/io/kontur/disasterninja/client/InsightsApiClientDummy.java @@ -5,7 +5,7 @@ public class InsightsApiClientDummy implements InsightsApiClient { @Override - public ResponseEntity getBivariateTileMvt(Integer z, Integer x, Integer y, String indicatorsClass) { + public ResponseEntity getBivariateTileMvt(Integer z, Integer x, Integer y, String indicatorsClass, String indicators) { return ResponseEntity.ok() .body(new byte[0]); } diff --git a/src/main/java/io/kontur/disasterninja/client/InsightsApiClientImpl.java b/src/main/java/io/kontur/disasterninja/client/InsightsApiClientImpl.java index 4e12166e..1d637c64 100644 --- a/src/main/java/io/kontur/disasterninja/client/InsightsApiClientImpl.java +++ b/src/main/java/io/kontur/disasterninja/client/InsightsApiClientImpl.java @@ -42,13 +42,13 @@ public InsightsApiClientImpl(RestTemplate insightsApiRestTemplate, MeterRegistry @Override @Timed(value = "insights.getBivariateTileMvt", histogram = true) - public ResponseEntity getBivariateTileMvt(Integer z, Integer x, Integer y, String indicatorsClass) { + public ResponseEntity 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); } diff --git a/src/main/java/io/kontur/disasterninja/controller/TileController.java b/src/main/java/io/kontur/disasterninja/controller/TileController.java index 9f35c14c..755f732d 100644 --- a/src/main/java/io/kontur/disasterninja/controller/TileController.java +++ b/src/main/java/io/kontur/disasterninja/controller/TileController.java @@ -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 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.", diff --git a/src/main/java/io/kontur/disasterninja/service/TileService.java b/src/main/java/io/kontur/disasterninja/service/TileService.java index bf07be82..04e41260 100644 --- a/src/main/java/io/kontur/disasterninja/service/TileService.java +++ b/src/main/java/io/kontur/disasterninja/service/TileService.java @@ -11,8 +11,8 @@ public class TileService { private final InsightsApiClient insightsApiClient; - public ResponseEntity getBivariateTileMvt(Integer z, Integer x, Integer y, String indicatorsClass){ - return insightsApiClient.getBivariateTileMvt(z, x, y, indicatorsClass); + public ResponseEntity getBivariateTileMvt(Integer z, Integer x, Integer y, String indicatorsClass, String indicators){ + return insightsApiClient.getBivariateTileMvt(z, x, y, indicatorsClass, indicators); } public ResponseEntity getBivariateTileMvtV2(Integer z, Integer x, Integer y, String indicatorsClass){ diff --git a/src/test/java/io/kontur/disasterninja/client/InsightsApiClientTest.java b/src/test/java/io/kontur/disasterninja/client/InsightsApiClientTest.java index afd22cc3..85b9904e 100644 --- a/src/test/java/io/kontur/disasterninja/client/InsightsApiClientTest.java +++ b/src/test/java/io/kontur/disasterninja/client/InsightsApiClientTest.java @@ -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); @@ -86,4 +86,4 @@ public void testGetBivariateTileMvtV2() { assertNotNull(tile); assertEquals(100, tile.length); } -} \ No newline at end of file +} diff --git a/src/test/java/io/kontur/disasterninja/service/TileServiceTest.java b/src/test/java/io/kontur/disasterninja/service/TileServiceTest.java index 1b25c797..301c51dc 100644 --- a/src/test/java/io/kontur/disasterninja/service/TileServiceTest.java +++ b/src/test/java/io/kontur/disasterninja/service/TileServiceTest.java @@ -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); } -} \ No newline at end of file +}