From 722f4dba1f4100965f5e0a1b557e59e6f4d0bd1e Mon Sep 17 00:00:00 2001 From: dingjingjing Date: Mon, 10 May 2021 11:23:06 +0800 Subject: [PATCH] Use LevelID as ArcGIS cache gridset's name --- .../arcgis/layer/GridSetBuilder.java | 19 +++++++++++++++++-- .../arcgis/layer/GridSetBuilderTest.java | 1 + 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/geowebcache/arcgiscache/src/main/java/org/geowebcache/arcgis/layer/GridSetBuilder.java b/geowebcache/arcgiscache/src/main/java/org/geowebcache/arcgis/layer/GridSetBuilder.java index 7f3a319db0..75b489b6d8 100644 --- a/geowebcache/arcgiscache/src/main/java/org/geowebcache/arcgis/layer/GridSetBuilder.java +++ b/geowebcache/arcgiscache/src/main/java/org/geowebcache/arcgis/layer/GridSetBuilder.java @@ -55,7 +55,7 @@ public GridSet buildGridset( */ final double[] scaleDenominators = null; final Double metersPerUnit; - final String[] scaleNames = null; + final String[] scaleNames; final int tileWidth = tileCacheInfo.getTileCols(); final int tileHeight = tileCacheInfo.getTileRows(); final boolean yCoordinateFirst = false; @@ -71,6 +71,9 @@ public GridSet buildGridset( resolutions = resAndScales[0]; double[] scales = resAndScales[1]; + + scaleNames = getScaleNames(lodInfos); + // TODO: check whether pixelSize computed above should be used instead metersPerUnit = (GridSetFactory.DEFAULT_PIXEL_SIZE_METER * scales[0]) / resolutions[0]; } @@ -126,13 +129,25 @@ public GridSet buildGridset( private double[][] getResolutions(List lodInfos) { final int numLevelsOfDetail = lodInfos.size(); - double[][] resolutionsAndScales = new double[2][numLevelsOfDetail]; + double[][] resolutionsAndScales = new double[3][numLevelsOfDetail]; LODInfo lodInfo; for (int i = 0; i < numLevelsOfDetail; i++) { lodInfo = lodInfos.get(i); resolutionsAndScales[0][i] = lodInfo.getResolution(); resolutionsAndScales[1][i] = lodInfo.getScale(); + resolutionsAndScales[2][i] = lodInfo.getLevelID(); } return resolutionsAndScales; } + + private String[] getScaleNames(List lodInfos) { + final int numLevelsOfDetail = lodInfos.size(); + String[] scaleNames = new String[numLevelsOfDetail]; + LODInfo lodInfo; + for (int i = 0; i < numLevelsOfDetail; i++) { + lodInfo = lodInfos.get(i); + scaleNames[i] = String.valueOf(lodInfo.getLevelID()); + } + return scaleNames; + } } diff --git a/geowebcache/arcgiscache/src/test/java/org/geowebcache/arcgis/layer/GridSetBuilderTest.java b/geowebcache/arcgiscache/src/test/java/org/geowebcache/arcgis/layer/GridSetBuilderTest.java index 280cf02088..0b2afdc4b6 100644 --- a/geowebcache/arcgiscache/src/test/java/org/geowebcache/arcgis/layer/GridSetBuilderTest.java +++ b/geowebcache/arcgiscache/src/test/java/org/geowebcache/arcgis/layer/GridSetBuilderTest.java @@ -66,6 +66,7 @@ public void testResolutionsAndScaleDenoms() { LODInfo lodInfo = lodInfos.get(i); Assert.assertEquals(lodInfo.getResolution(), resolutions[i], 0d); Assert.assertEquals(lodInfo.getScale(), gridset.getGrid(i).getScaleDenominator(), 1e-6); + Assert.assertEquals(String.valueOf(lodInfo.getLevelID()), gridset.getGrid(i).getName()); } } }