Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ public class ArcGISCompactCacheV1 extends ArcGISCompactCache {
* contain directories for zoom levels (named "Lxx").
*/
public ArcGISCompactCacheV1(String pathToCacheRoot) {
if (pathToCacheRoot.endsWith("" + File.separatorChar))
this.pathToCacheRoot = pathToCacheRoot;
if (pathToCacheRoot.endsWith("" + File.separatorChar)) this.pathToCacheRoot = pathToCacheRoot;
else this.pathToCacheRoot = pathToCacheRoot + File.separatorChar;

indexCache = new BundlxCache(10000);
Expand All @@ -60,16 +59,14 @@ public Resource getBundleFileResource(int zoom, int row, int col) {
Resource res = null;

if ((entry = indexCache.get(key)) != null) {
if (entry.size > 0)
res = new BundleFileResource(entry.pathToBundleFile, entry.offset, entry.size);
if (entry.size > 0) res = new BundleFileResource(entry.pathToBundleFile, entry.offset, entry.size);
} else {

String basePath = buildBundleFilePath(zoom, row, col);
String pathToBundlxFile = basePath + BUNDLX_EXT;
String pathToBundleFile = basePath + BUNDLE_EXT;

if (!(new File(pathToBundleFile)).exists() || !(new File(pathToBundlxFile)).exists())
return null;
if (!(new File(pathToBundleFile)).exists() || !(new File(pathToBundlxFile)).exists()) return null;

long tileOffset = readTileStartOffset(pathToBundlxFile, row, col);
int tileSize = readTileSize(pathToBundleFile, tileOffset);
Expand All @@ -89,8 +86,7 @@ public Resource getBundleFileResource(int zoom, int row, int col) {
private long readTileStartOffset(String bundlxFile, int row, int col) {
int index = BUNDLX_MAXIDX * (col % BUNDLX_MAXIDX) + (row % BUNDLX_MAXIDX);

ByteBuffer idxBytes =
readFromLittleEndianFile(bundlxFile, (index * 5) + COMPACT_CACHE_HEADER_LENGTH, 5);
ByteBuffer idxBytes = readFromLittleEndianFile(bundlxFile, (index * 5) + COMPACT_CACHE_HEADER_LENGTH, 5);

return idxBytes.getLong();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ public class ArcGISCompactCacheV2 extends ArcGISCompactCache {
* contain directories for zoom levels (named "Lxx").
*/
public ArcGISCompactCacheV2(String pathToCacheRoot) {
if (pathToCacheRoot.endsWith("" + File.separatorChar))
this.pathToCacheRoot = pathToCacheRoot;
if (pathToCacheRoot.endsWith("" + File.separatorChar)) this.pathToCacheRoot = pathToCacheRoot;
else this.pathToCacheRoot = pathToCacheRoot + File.separatorChar;

indexCache = new BundlxCache(10000);
Expand All @@ -62,8 +61,7 @@ public Resource getBundleFileResource(int zoom, int row, int col) {
Resource res = null;

if ((entry = indexCache.get(key)) != null) {
if (entry.size > 0)
res = new BundleFileResource(entry.pathToBundleFile, entry.offset, entry.size);
if (entry.size > 0) res = new BundleFileResource(entry.pathToBundleFile, entry.offset, entry.size);
} else {

String basePath = buildBundleFilePath(zoom, row, col);
Expand All @@ -73,8 +71,7 @@ public Resource getBundleFileResource(int zoom, int row, int col) {

entry = createCacheEntry(pathToBundleFile, row, col);

if (entry.size > 0)
res = new BundleFileResource(pathToBundleFile, entry.offset, entry.size);
if (entry.size > 0) res = new BundleFileResource(pathToBundleFile, entry.offset, entry.size);

indexCache.put(key, entry);
}
Expand All @@ -87,16 +84,16 @@ private BundlxCache.CacheEntry createCacheEntry(String bundleFile, int row, int
int index = BUNDLX_MAXIDX * (row % BUNDLX_MAXIDX) + (col % BUNDLX_MAXIDX);

// to save one addtional read, we read all 8 bytes in one read
ByteBuffer offsetAndSize =
readFromLittleEndianFile(bundleFile, (index * 8) + COMPACT_CACHE_HEADER_LENGTH, 8);
ByteBuffer offsetAndSize = readFromLittleEndianFile(bundleFile, (index * 8) + COMPACT_CACHE_HEADER_LENGTH, 8);

byte[] offsetBytes = new byte[8];
byte[] sizeBytes = new byte[4];

offsetAndSize.get(offsetBytes, 0, 5);
offsetAndSize.get(sizeBytes, 0, 3);

long tileOffset = ByteBuffer.wrap(offsetBytes).order(ByteOrder.LITTLE_ENDIAN).getLong();
long tileOffset =
ByteBuffer.wrap(offsetBytes).order(ByteOrder.LITTLE_ENDIAN).getLong();
int tileSize = ByteBuffer.wrap(sizeBytes).order(ByteOrder.LITTLE_ENDIAN).getInt();

return new BundlxCache.CacheEntry(bundleFile, tileOffset, tileSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ public long transferTo(WritableByteChannel target) throws IOException {
FileChannel in = fin.getChannel()) {
final long size = tileSize;
long written = 0;
while ((written += in.transferTo(tileOffset + written, size, target)) < size) ;
while ((written += in.transferTo(tileOffset + written, size, target)) < size)
;
return size;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ public BoundingBox parseLayerBounds(final Reader layerBoundsFile) {

EnvelopeN envN = (EnvelopeN) getConfiguredXStream().fromXML(layerBoundsFile);

BoundingBox bbox =
new BoundingBox(envN.getXmin(), envN.getYmin(), envN.getXmax(), envN.getYmax());
BoundingBox bbox = new BoundingBox(envN.getXmin(), envN.getYmin(), envN.getXmax(), envN.getYmax());

return bbox;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,20 +158,16 @@ protected boolean initializeInternal(GridSetBroker gridSetBroker) {
this.enabled = true;
}
if (this.tilingScheme == null) {
throw new IllegalStateException(
"tilingScheme has not been set. It should point to the ArcGIS "
+ "cache tiling scheme file for this layer (conf.xml)");
throw new IllegalStateException("tilingScheme has not been set. It should point to the ArcGIS "
+ "cache tiling scheme file for this layer (conf.xml)");
}
if (tileCachePath != null) {
if (!tileCachePath.exists()
|| !tileCachePath.isDirectory()
|| !tileCachePath.canRead()) {
throw new IllegalStateException(
"tileCachePath property for layer '"
+ getName()
+ "' is set to '"
+ tileCachePath
+ "' but the directory either does not exist or is not readable");
if (!tileCachePath.exists() || !tileCachePath.isDirectory() || !tileCachePath.canRead()) {
throw new IllegalStateException("tileCachePath property for layer '"
+ getName()
+ "' is set to '"
+ tileCachePath
+ "' but the directory either does not exist or is not readable");
}
}
if (this.hexZoom == null) {
Expand All @@ -182,8 +178,7 @@ protected boolean initializeInternal(GridSetBroker gridSetBroker) {
cacheInfo = tilingSchemeLoader.load(new FileReader(tilingScheme));
File layerBoundsFile = new File(tilingScheme.getParentFile(), "conf.cdi");
if (!layerBoundsFile.exists()) {
throw new RuntimeException(
"Layer bounds file not found: " + layerBoundsFile.getAbsolutePath());
throw new RuntimeException("Layer bounds file not found: " + layerBoundsFile.getAbsolutePath());
}
log.info("Parsing layer bounds for " + getName());
this.layerBounds = tilingSchemeLoader.parseLayerBounds(new FileReader(layerBoundsFile));
Expand All @@ -204,14 +199,12 @@ protected boolean initializeInternal(GridSetBroker gridSetBroker) {
}
}
} catch (FileNotFoundException e) {
throw new IllegalStateException(
"Tiling scheme file not found: " + tilingScheme.getAbsolutePath());
throw new IllegalStateException("Tiling scheme file not found: " + tilingScheme.getAbsolutePath());
}
log.info(
"Configuring layer "
+ getName()
+ " out of the ArcGIS tiling scheme "
+ tilingScheme.getAbsolutePath());
log.info("Configuring layer "
+ getName()
+ " out of the ArcGIS tiling scheme "
+ tilingScheme.getAbsolutePath());

super.subSets = createGridSubsets(gridSetBroker);
super.formats = loadMimeTypes();
Expand Down Expand Up @@ -251,8 +244,7 @@ private HashMap<String, GridSubset> createGridSubsets(final GridSetBroker gridSe
Integer zoomStart = lodInfos.get(0).getLevelID();
Integer zoomStop = lodInfos.get(lodInfos.size() - 1).getLevelID();

GridSubset subSet =
GridSubsetFactory.createGridSubSet(gridSet, this.layerBounds, zoomStart, zoomStop);
GridSubset subSet = GridSubsetFactory.createGridSubSet(gridSet, this.layerBounds, zoomStart, zoomStop);

HashMap<String, GridSubset> subsets = new HashMap<>();
subsets.put(gridSet.getName(), subSet);
Expand Down Expand Up @@ -465,8 +457,7 @@ public ConveyorTile getNoncachedTile(ConveyorTile tile) throws GeoWebCacheExcept
* @see org.geowebcache.layer.TileLayer#seedTile(org.geowebcache.conveyor.ConveyorTile, boolean)
*/
@Override
public void seedTile(ConveyorTile tile, boolean tryCache)
throws GeoWebCacheException, IOException {
public void seedTile(ConveyorTile tile, boolean tryCache) throws GeoWebCacheException, IOException {
throw new UnsupportedOperationException();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
class GridSetBuilder {

/** Creates a {@link GridSet} out of a ArcGIS tiling scheme */
public GridSet buildGridset(
final String layerName, final CacheInfo info, final BoundingBox layerBounds) {
public GridSet buildGridset(final String layerName, final CacheInfo info, final BoundingBox layerBounds) {

Assert.notNull(layerName, "Layer name must be non null");
Assert.notNull(info, "Layer name must be non null");
Expand Down Expand Up @@ -106,20 +105,19 @@ public GridSet buildGridset(
}

String gridsetName = srs.toString() + "_" + layerName;
GridSet layerGridset =
GridSetFactory.createGridSet(
gridsetName,
srs,
gridSetExtent,
alignTopLeft,
resolutions,
scaleDenominators,
metersPerUnit,
pixelSize,
scaleNames,
tileWidth,
tileHeight,
yCoordinateFirst);
GridSet layerGridset = GridSetFactory.createGridSet(
gridsetName,
srs,
gridSetExtent,
alignTopLeft,
resolutions,
scaleDenominators,
metersPerUnit,
pixelSize,
scaleNames,
tileWidth,
tileHeight,
yCoordinateFirst);

return layerGridset;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,7 @@
*/
public class ArcGISCompactCacheTest {
private static final byte[] JFIFHeader = {
(byte) 0xFF,
(byte) 0xD8,
(byte) 0xFF,
(byte) 0xE0,
0x00,
0x10,
0x4A,
0x46,
0x49,
0x46,
0x00,
0x01
(byte) 0xFF, (byte) 0xD8, (byte) 0xFF, (byte) 0xE0, 0x00, 0x10, 0x4A, 0x46, 0x49, 0x46, 0x00, 0x01
};

@Test
Expand Down
Loading