Skip to content

Commit

Permalink
Merge branch 'hotfix/v0.3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
emxsys committed Jul 29, 2017
2 parents 363b558 + 35a0cc0 commit e1edfd9
Show file tree
Hide file tree
Showing 9 changed files with 126 additions and 39 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

<groupId>gov.nasa.worldwind.server</groupId>
<artifactId>worldwind-serverkit</artifactId>
<version>0.3.0</version>
<version>0.3.1</version>
<packaging>pom</packaging>

<!--=====================================================================-->
Expand Down
2 changes: 1 addition & 1 deletion worldwind-geoserver-dist/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>gov.nasa.worldwind.server</groupId>
<artifactId>worldwind-serverkit</artifactId>
<version>0.3.0</version>
<version>0.3.1</version>
</parent>
<artifactId>worldwind-geoserver-dist</artifactId>
<packaging>pom</packaging>
Expand Down
2 changes: 1 addition & 1 deletion worldwind-geoserver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>gov.nasa.worldwind.server</groupId>
<artifactId>worldwind-serverkit</artifactId>
<version>0.3.0</version>
<version>0.3.1</version>
</parent>
<artifactId>worldwind-geoserver</artifactId>
<packaging>war</packaging>
Expand Down
41 changes: 21 additions & 20 deletions worldwind-geoserver/src/main/webapp/data/global.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
<global>
<contact>
<contactOrganization>NASA World Wind</contactOrganization>
<contactPerson>Patrick Hogan</contactPerson>
</contact> <jai>
<allowInterpolation>false</allowInterpolation>
<recycling>true</recycling>
<tilePriority>5</tilePriority>
<tileThreads>7</tileThreads>
<memoryCapacity>0.5</memoryCapacity>
<memoryThreshold>0.75</memoryThreshold>
<imageIOCache>false</imageIOCache>
<pngAcceleration>false</pngAcceleration>
<jpegAcceleration>false</jpegAcceleration>
<allowNativeMosaic>false</allowNativeMosaic>
</jai>
<charset>UTF-8</charset>
<numDecimals>8</numDecimals>
<onlineResource>http://geoserver.org</onlineResource>
<verbose>false</verbose>
<verboseExceptions>false</verboseExceptions>
<updateSequence>0</updateSequence>
<contactOrganization>NASA WorldWind</contactOrganization>
<contactPerson>Patrick Hogan</contactPerson>
</contact>
<jai>
<allowInterpolation>false</allowInterpolation>
<recycling>true</recycling>
<tilePriority>5</tilePriority>
<tileThreads>7</tileThreads>
<memoryCapacity>0.5</memoryCapacity>
<memoryThreshold>0.75</memoryThreshold>
<imageIOCache>false</imageIOCache>
<pngAcceleration>false</pngAcceleration>
<jpegAcceleration>false</jpegAcceleration>
<allowNativeMosaic>false</allowNativeMosaic>
</jai>
<charset>UTF-8</charset>
<numDecimals>8</numDecimals>
<onlineResource>http://geoserver.org</onlineResource>
<verbose>false</verbose>
<verboseExceptions>false</verboseExceptions>
<updateSequence>0</updateSequence>
</global>
2 changes: 1 addition & 1 deletion worldwind-gs-geopkg/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ application directory.
<parent>
<groupId>gov.nasa.worldwind.server</groupId>
<artifactId>worldwind-serverkit</artifactId>
<version>0.3.0</version>
<version>0.3.1</version>
</parent>

<groupId>gov.nasa.worldwind.server</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
import gov.nasa.worldwind.geopkg.Tile;
import gov.nasa.worldwind.geopkg.TileEntry;
import gov.nasa.worldwind.geopkg.TileMatrix;

import gov.nasa.worldwind.gs.wms.map.MapResponseOutputStreamAdaptor;
import java.io.ByteArrayOutputStream;

import static java.lang.String.format;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
Expand Down Expand Up @@ -44,15 +45,18 @@
import org.geoserver.wms.map.RawMap;
import org.geoserver.wms.map.RenderedImageMap;
import org.geoserver.wms.map.RenderedImageMapResponse;
import org.geotools.coverage.grid.io.GridCoverage2DReader;

import org.geotools.geometry.jts.ReferencedEnvelope;
import org.geotools.referencing.CRS;
import org.geotools.renderer.lite.RendererUtilities;
import org.geotools.util.logging.Logging;

import org.geowebcache.grid.Grid;
import org.geowebcache.grid.GridSet;
import org.geowebcache.grid.GridSubset;

import org.opengis.coverage.grid.GridEnvelope;
import org.opengis.referencing.crs.CoordinateReferenceSystem;

/**
Expand Down Expand Up @@ -245,6 +249,67 @@ public WebMap produceMap(WMSMapContent mapContent) throws ServiceException, IOEx
return super.produceMap(mapContent);
}

/**
* Returns the zoom level, plus one, closest to the highest resolution
* coverage used in the map request. This is the ending value used in loops
* that process the levels, it is not the max zoom level in the GeoPackage.
*
* Overrides the base class behavior which returned a "zoom level + 1" where
* the zoom level contained at least 256 tiles.
*
* @param gridSubset the grid for the GeoPackage
* @param minZoom the starting zoom level
* @param request the map request containing the layer coverages
* @return the selected maximum zoom level + 1
*/
@Override
protected Integer findMaxZoomAuto(GridSubset gridSubset, Integer minZoom, GetMapRequest request) {

// Get the maximum scale for the highest resolution layer:
// loop through the layer coverages associated with the request
// and compute the scale for each.
List<MapLayerInfo> layers = request.getLayers();
double reqScaleDenominator = Double.MAX_VALUE;
for (MapLayerInfo layer : layers) {
try {
if (layer.getType() == MapLayerInfo.TYPE_RASTER) {
// Get the width of the underlying coverage
GridCoverage2DReader coverageReader = (GridCoverage2DReader) layer.getCoverageReader();
GridEnvelope originalGridRange = coverageReader.getOriginalGridRange();
int imageWidth = originalGridRange.getSpan(0); // 0=cols, 1=rows
// Compute the scale demonimator
ReferencedEnvelope bounds = this.bounds(request);
double scale = RendererUtilities.calculateOGCScale(bounds, imageWidth, null);
// Select the largest scale (the smallest denominator)
reqScaleDenominator = Math.min(scale, reqScaleDenominator);
}
} catch (Exception e) {
LOGGER.warning(
format("Exception caught computing the scale for layer %s: %s",
layer.getName(), e.toString()));
}
}
if (reqScaleDenominator < Double.MAX_VALUE) {
// Find the level with the closest scale denominator to the required scale
GridSet gridSet = gridSubset.getGridSet();
int i = minZoom;
double error = Math.abs(gridSet.getGrid(i).getScaleDenominator() - reqScaleDenominator);
while (i < gridSet.getNumLevels() - 1) {
Grid g = gridSet.getGrid(i + 1);
double e = Math.abs(g.getScaleDenominator() - reqScaleDenominator);
if (e > error) {
break;
}
error = e;
i++;
}
// Return the selected zoom level + 1; this is the ending index
// used in loops, not the max zoom level in the GeoPackage
return Math.max(i + 1, 0);
}
return super.findMaxZoomAuto(gridSubset, minZoom, request);
}

/**
* Gets a tile set name in the form of a valid SQLite table name from the
* map layers.
Expand Down
2 changes: 1 addition & 1 deletion worldwind-gs-wms/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>gov.nasa.worldwind.server</groupId>
<artifactId>worldwind-serverkit</artifactId>
<version>0.3.0</version>
<version>0.3.1</version>
</parent>
<artifactId>worldwind-gs-wms</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion worldwind-gt-geopkg/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<groupId>gov.nasa.worldwind.server</groupId>
<artifactId>worldwind-serverkit</artifactId>
<version>0.3.0</version>
<version>0.3.1</version>
</parent>

<!-- =========================================================== -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,21 +90,46 @@ public class GeoPackageReader extends AbstractGridCoverage2DReader {
protected File sourceFile;

protected Map<String, TileEntry> tiles = new HashMap<String, TileEntry>();

// TODO: store these gridRanges in the TileEntry class
protected Map<String, GridEnvelope2D> gridRanges = new HashMap<String, GridEnvelope2D>();

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

try {
// Set the coverage name to the name of the the first raster tileset.
coverageName = null; // default value was "geotools_coverage"
for (TileEntry tile : file.tiles()) {
tiles.put(tile.getTableName(), tile);
for (TileEntry tileset : file.tiles()) {
// Map the tileset to the coverage name (table name)
tiles.put(tileset.getTableName(), tileset);

// Set the default coverage name to the name of the the first raster tileset.
if (coverageName == null) {
coverageName = tile.getTableName();
coverageName = tileset.getTableName();
}

// TODO: Refactor this to compute the gridRange in the GeoPackage class
List<TileMatrix> matricies = tileset.getTileMatricies();
TileMatrix matrix = matricies.get(matricies.size() - 1);
int maxZoomLevel = matrix.getZoomLevel();
int minCol = file.getTileBound(tileset, maxZoomLevel, false, false); // booleans: isMax, isRow
int maxCol = file.getTileBound(tileset, maxZoomLevel, true, false);
int minRow = file.getTileBound(tileset, maxZoomLevel, false, true);
int maxRow = file.getTileBound(tileset, maxZoomLevel, true, true);
int numCols = (maxCol - minCol) + 1;
int numRows = (maxRow - minRow) + 1;

GridEnvelope2D gridRange = new GridEnvelope2D(
minCol * matrix.getTileWidth(),
minRow * matrix.getTileHeight(),
numCols * matrix.getTileWidth(),
numRows * matrix.getTileHeight());

gridRanges.put(tileset.getTableName(), gridRange);
}

} finally {
file.close();
}
Expand Down Expand Up @@ -148,10 +173,8 @@ public GridEnvelope getOriginalGridRange(String coverageName) {
throw new IllegalArgumentException("The specified coverageName " + coverageName
+ "is not supported");
}

List<TileMatrix> matrices = tiles.get(coverageName).getTileMatricies();
TileMatrix matrix = matrices.get(matrices.size() - 1);
return new GridEnvelope2D(new Rectangle(matrix.getMatrixWidth() * matrix.getTileWidth(), matrix.getMatrixHeight() * matrix.getTileHeight()));
// Return the envelope surrounding the tiles found in the maximum zoom level
return gridRanges.get(coverageName);
}

@Override
Expand Down Expand Up @@ -325,8 +348,7 @@ public GridCoverage2D read(String coverageName, GeneralParameterValue[] paramete
graphics.setStroke(new BasicStroke(thickness));
graphics.drawRect(0, 0, tileImage.getWidth(), tileImage.getHeight());
}
*/

*/
// Create the destination image that we draw into
if (image == null) {
image = getStartImage(width, height, inputTransparentColor);
Expand All @@ -350,7 +372,6 @@ public GridCoverage2D read(String coverageName, GeneralParameterValue[] paramete
image = getStartImage(width, height, inputTransparentColor);
}


// Apply the color transparency mask
if (inputTransparentColor != null) {
// Note: ImageWorker.makeColorTransparent only works
Expand Down

0 comments on commit e1edfd9

Please sign in to comment.