Skip to content

Commit

Permalink
Use LevelID as ArcGIS cache gridset's name
Browse files Browse the repository at this point in the history
  • Loading branch information
initialdmg committed May 10, 2021
1 parent 0975a50 commit b27e5b4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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];
}
Expand Down Expand Up @@ -126,13 +129,25 @@ public GridSet buildGridset(

private double[][] getResolutions(List<LODInfo> 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<LODInfo> 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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
}

0 comments on commit b27e5b4

Please sign in to comment.