Skip to content

Commit e1edfd9

Browse files
committed
Merge branch 'hotfix/v0.3.1'
2 parents 363b558 + 35a0cc0 commit e1edfd9

File tree

9 files changed

+126
-39
lines changed

9 files changed

+126
-39
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
<groupId>gov.nasa.worldwind.server</groupId>
3131
<artifactId>worldwind-serverkit</artifactId>
32-
<version>0.3.0</version>
32+
<version>0.3.1</version>
3333
<packaging>pom</packaging>
3434

3535
<!--=====================================================================-->

worldwind-geoserver-dist/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>gov.nasa.worldwind.server</groupId>
66
<artifactId>worldwind-serverkit</artifactId>
7-
<version>0.3.0</version>
7+
<version>0.3.1</version>
88
</parent>
99
<artifactId>worldwind-geoserver-dist</artifactId>
1010
<packaging>pom</packaging>

worldwind-geoserver/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>gov.nasa.worldwind.server</groupId>
66
<artifactId>worldwind-serverkit</artifactId>
7-
<version>0.3.0</version>
7+
<version>0.3.1</version>
88
</parent>
99
<artifactId>worldwind-geoserver</artifactId>
1010
<packaging>war</packaging>
Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
<global>
22
<contact>
3-
<contactOrganization>NASA World Wind</contactOrganization>
4-
<contactPerson>Patrick Hogan</contactPerson>
5-
</contact> <jai>
6-
<allowInterpolation>false</allowInterpolation>
7-
<recycling>true</recycling>
8-
<tilePriority>5</tilePriority>
9-
<tileThreads>7</tileThreads>
10-
<memoryCapacity>0.5</memoryCapacity>
11-
<memoryThreshold>0.75</memoryThreshold>
12-
<imageIOCache>false</imageIOCache>
13-
<pngAcceleration>false</pngAcceleration>
14-
<jpegAcceleration>false</jpegAcceleration>
15-
<allowNativeMosaic>false</allowNativeMosaic>
16-
</jai>
17-
<charset>UTF-8</charset>
18-
<numDecimals>8</numDecimals>
19-
<onlineResource>http://geoserver.org</onlineResource>
20-
<verbose>false</verbose>
21-
<verboseExceptions>false</verboseExceptions>
22-
<updateSequence>0</updateSequence>
3+
<contactOrganization>NASA WorldWind</contactOrganization>
4+
<contactPerson>Patrick Hogan</contactPerson>
5+
</contact>
6+
<jai>
7+
<allowInterpolation>false</allowInterpolation>
8+
<recycling>true</recycling>
9+
<tilePriority>5</tilePriority>
10+
<tileThreads>7</tileThreads>
11+
<memoryCapacity>0.5</memoryCapacity>
12+
<memoryThreshold>0.75</memoryThreshold>
13+
<imageIOCache>false</imageIOCache>
14+
<pngAcceleration>false</pngAcceleration>
15+
<jpegAcceleration>false</jpegAcceleration>
16+
<allowNativeMosaic>false</allowNativeMosaic>
17+
</jai>
18+
<charset>UTF-8</charset>
19+
<numDecimals>8</numDecimals>
20+
<onlineResource>http://geoserver.org</onlineResource>
21+
<verbose>false</verbose>
22+
<verboseExceptions>false</verboseExceptions>
23+
<updateSequence>0</updateSequence>
2324
</global>

worldwind-gs-geopkg/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ application directory.
99
<parent>
1010
<groupId>gov.nasa.worldwind.server</groupId>
1111
<artifactId>worldwind-serverkit</artifactId>
12-
<version>0.3.0</version>
12+
<version>0.3.1</version>
1313
</parent>
1414

1515
<groupId>gov.nasa.worldwind.server</groupId>

worldwind-gs-geopkg/src/main/java/gov/nasa/worldwind/gs/geopkg/GeoPackageGetMapOutputFormat.java

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212
import gov.nasa.worldwind.geopkg.Tile;
1313
import gov.nasa.worldwind.geopkg.TileEntry;
1414
import gov.nasa.worldwind.geopkg.TileMatrix;
15-
1615
import gov.nasa.worldwind.gs.wms.map.MapResponseOutputStreamAdaptor;
17-
import java.io.ByteArrayOutputStream;
1816

17+
import static java.lang.String.format;
18+
19+
import java.io.ByteArrayOutputStream;
1920
import java.io.File;
2021
import java.io.IOException;
2122
import java.util.Iterator;
@@ -44,15 +45,18 @@
4445
import org.geoserver.wms.map.RawMap;
4546
import org.geoserver.wms.map.RenderedImageMap;
4647
import org.geoserver.wms.map.RenderedImageMapResponse;
48+
import org.geotools.coverage.grid.io.GridCoverage2DReader;
4749

4850
import org.geotools.geometry.jts.ReferencedEnvelope;
4951
import org.geotools.referencing.CRS;
52+
import org.geotools.renderer.lite.RendererUtilities;
5053
import org.geotools.util.logging.Logging;
5154

5255
import org.geowebcache.grid.Grid;
5356
import org.geowebcache.grid.GridSet;
5457
import org.geowebcache.grid.GridSubset;
5558

59+
import org.opengis.coverage.grid.GridEnvelope;
5660
import org.opengis.referencing.crs.CoordinateReferenceSystem;
5761

5862
/**
@@ -245,6 +249,67 @@ public WebMap produceMap(WMSMapContent mapContent) throws ServiceException, IOEx
245249
return super.produceMap(mapContent);
246250
}
247251

252+
/**
253+
* Returns the zoom level, plus one, closest to the highest resolution
254+
* coverage used in the map request. This is the ending value used in loops
255+
* that process the levels, it is not the max zoom level in the GeoPackage.
256+
*
257+
* Overrides the base class behavior which returned a "zoom level + 1" where
258+
* the zoom level contained at least 256 tiles.
259+
*
260+
* @param gridSubset the grid for the GeoPackage
261+
* @param minZoom the starting zoom level
262+
* @param request the map request containing the layer coverages
263+
* @return the selected maximum zoom level + 1
264+
*/
265+
@Override
266+
protected Integer findMaxZoomAuto(GridSubset gridSubset, Integer minZoom, GetMapRequest request) {
267+
268+
// Get the maximum scale for the highest resolution layer:
269+
// loop through the layer coverages associated with the request
270+
// and compute the scale for each.
271+
List<MapLayerInfo> layers = request.getLayers();
272+
double reqScaleDenominator = Double.MAX_VALUE;
273+
for (MapLayerInfo layer : layers) {
274+
try {
275+
if (layer.getType() == MapLayerInfo.TYPE_RASTER) {
276+
// Get the width of the underlying coverage
277+
GridCoverage2DReader coverageReader = (GridCoverage2DReader) layer.getCoverageReader();
278+
GridEnvelope originalGridRange = coverageReader.getOriginalGridRange();
279+
int imageWidth = originalGridRange.getSpan(0); // 0=cols, 1=rows
280+
// Compute the scale demonimator
281+
ReferencedEnvelope bounds = this.bounds(request);
282+
double scale = RendererUtilities.calculateOGCScale(bounds, imageWidth, null);
283+
// Select the largest scale (the smallest denominator)
284+
reqScaleDenominator = Math.min(scale, reqScaleDenominator);
285+
}
286+
} catch (Exception e) {
287+
LOGGER.warning(
288+
format("Exception caught computing the scale for layer %s: %s",
289+
layer.getName(), e.toString()));
290+
}
291+
}
292+
if (reqScaleDenominator < Double.MAX_VALUE) {
293+
// Find the level with the closest scale denominator to the required scale
294+
GridSet gridSet = gridSubset.getGridSet();
295+
int i = minZoom;
296+
double error = Math.abs(gridSet.getGrid(i).getScaleDenominator() - reqScaleDenominator);
297+
while (i < gridSet.getNumLevels() - 1) {
298+
Grid g = gridSet.getGrid(i + 1);
299+
double e = Math.abs(g.getScaleDenominator() - reqScaleDenominator);
300+
if (e > error) {
301+
break;
302+
}
303+
error = e;
304+
i++;
305+
}
306+
// Return the selected zoom level + 1; this is the ending index
307+
// used in loops, not the max zoom level in the GeoPackage
308+
return Math.max(i + 1, 0);
309+
}
310+
return super.findMaxZoomAuto(gridSubset, minZoom, request);
311+
}
312+
248313
/**
249314
* Gets a tile set name in the form of a valid SQLite table name from the
250315
* map layers.

worldwind-gs-wms/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>gov.nasa.worldwind.server</groupId>
66
<artifactId>worldwind-serverkit</artifactId>
7-
<version>0.3.0</version>
7+
<version>0.3.1</version>
88
</parent>
99
<artifactId>worldwind-gs-wms</artifactId>
1010
<packaging>jar</packaging>

worldwind-gt-geopkg/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<parent>
1313
<groupId>gov.nasa.worldwind.server</groupId>
1414
<artifactId>worldwind-serverkit</artifactId>
15-
<version>0.3.0</version>
15+
<version>0.3.1</version>
1616
</parent>
1717

1818
<!-- =========================================================== -->

worldwind-gt-geopkg/src/main/java/gov/nasa/worldwind/geopkg/mosaic/GeoPackageReader.java

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,21 +90,46 @@ public class GeoPackageReader extends AbstractGridCoverage2DReader {
9090
protected File sourceFile;
9191

9292
protected Map<String, TileEntry> tiles = new HashMap<String, TileEntry>();
93+
94+
// TODO: store these gridRanges in the TileEntry class
95+
protected Map<String, GridEnvelope2D> gridRanges = new HashMap<String, GridEnvelope2D>();
9396

9497
public GeoPackageReader(Object source, Hints hints) throws IOException {
9598
coverageFactory = CoverageFactoryFinder.getGridCoverageFactory(this.hints);
9699
sourceFile = GeoPackageFormat.getFileFromSource(source);
97100
GeoPackage file = new GeoPackage(sourceFile);
98101

99102
try {
100-
// Set the coverage name to the name of the the first raster tileset.
101103
coverageName = null; // default value was "geotools_coverage"
102-
for (TileEntry tile : file.tiles()) {
103-
tiles.put(tile.getTableName(), tile);
104+
for (TileEntry tileset : file.tiles()) {
105+
// Map the tileset to the coverage name (table name)
106+
tiles.put(tileset.getTableName(), tileset);
107+
108+
// Set the default coverage name to the name of the the first raster tileset.
104109
if (coverageName == null) {
105-
coverageName = tile.getTableName();
110+
coverageName = tileset.getTableName();
106111
}
112+
113+
// TODO: Refactor this to compute the gridRange in the GeoPackage class
114+
List<TileMatrix> matricies = tileset.getTileMatricies();
115+
TileMatrix matrix = matricies.get(matricies.size() - 1);
116+
int maxZoomLevel = matrix.getZoomLevel();
117+
int minCol = file.getTileBound(tileset, maxZoomLevel, false, false); // booleans: isMax, isRow
118+
int maxCol = file.getTileBound(tileset, maxZoomLevel, true, false);
119+
int minRow = file.getTileBound(tileset, maxZoomLevel, false, true);
120+
int maxRow = file.getTileBound(tileset, maxZoomLevel, true, true);
121+
int numCols = (maxCol - minCol) + 1;
122+
int numRows = (maxRow - minRow) + 1;
123+
124+
GridEnvelope2D gridRange = new GridEnvelope2D(
125+
minCol * matrix.getTileWidth(),
126+
minRow * matrix.getTileHeight(),
127+
numCols * matrix.getTileWidth(),
128+
numRows * matrix.getTileHeight());
129+
130+
gridRanges.put(tileset.getTableName(), gridRange);
107131
}
132+
108133
} finally {
109134
file.close();
110135
}
@@ -148,10 +173,8 @@ public GridEnvelope getOriginalGridRange(String coverageName) {
148173
throw new IllegalArgumentException("The specified coverageName " + coverageName
149174
+ "is not supported");
150175
}
151-
152-
List<TileMatrix> matrices = tiles.get(coverageName).getTileMatricies();
153-
TileMatrix matrix = matrices.get(matrices.size() - 1);
154-
return new GridEnvelope2D(new Rectangle(matrix.getMatrixWidth() * matrix.getTileWidth(), matrix.getMatrixHeight() * matrix.getTileHeight()));
176+
// Return the envelope surrounding the tiles found in the maximum zoom level
177+
return gridRanges.get(coverageName);
155178
}
156179

157180
@Override
@@ -325,8 +348,7 @@ public GridCoverage2D read(String coverageName, GeneralParameterValue[] paramete
325348
graphics.setStroke(new BasicStroke(thickness));
326349
graphics.drawRect(0, 0, tileImage.getWidth(), tileImage.getHeight());
327350
}
328-
*/
329-
351+
*/
330352
// Create the destination image that we draw into
331353
if (image == null) {
332354
image = getStartImage(width, height, inputTransparentColor);
@@ -350,7 +372,6 @@ public GridCoverage2D read(String coverageName, GeneralParameterValue[] paramete
350372
image = getStartImage(width, height, inputTransparentColor);
351373
}
352374

353-
354375
// Apply the color transparency mask
355376
if (inputTransparentColor != null) {
356377
// Note: ImageWorker.makeColorTransparent only works

0 commit comments

Comments
 (0)