Skip to content

Commit

Permalink
Add gitattributes, renormalize files in repo
Browse files Browse the repository at this point in the history
  • Loading branch information
aaime committed Jan 8, 2022
1 parent d3dfec4 commit 5f670f0
Show file tree
Hide file tree
Showing 7 changed files with 603 additions and 525 deletions.
78 changes: 78 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Java sources
*.java text diff=java
*.kt text diff=java
*.groovy text diff=java
*.scala text diff=java
*.gradle text diff=java
*.gradle.kts text diff=java

# These files are text and should be normalized (Convert crlf => lf)
*.css text diff=css
*.scss text diff=css
*.sass text
*.df text
*.htm text diff=html
*.html text diff=html
*.js text
*.jsp text
*.jspf text
*.jspx text
*.properties text
*.tld text
*.tag text
*.tagx text
*.xml text
*.xsd text
*.sld text
*.csv text
*.jjt text
*.prj text
*.apt text
*.md text
*.pgw text
*.jgw text
*.txt text
*.rst text

# These files are binary and should be left untouched
# (binary is a macro for -text -diff)
*.class binary
*.dll binary
*.ear binary
*.jar binary
*.so binary
*.war binary
*.jks binary
*.shp binary
*.shx binary
*.dbf binary
*.qix binary
*.fix binary
*.tiff binary
*.tif binary
*.jpg binary
*.jpeg binary
*.png binary
*.zip binary
*.pdf binary
*.db binary
*.ecw binary
*.fgb binary
*.gif binary
*.gpkg binary
*.grb2 binary
*.grib2 binary
*.gz binary
*.img binary
*.jgrass binary
*.jp2 binary
*.mbtiles binary
*.msk binary
*.ovr binary
*.pbf binary
*.pdf binary
*.sid binary
*.tpk binary
*.ttf binary
*.wkb binary

20 changes: 10 additions & 10 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
version: 1.0.{build}
branches:
only:
- master
cache:
- C:\Users\appveyor\.m2\ -> geowebcache\pom.xml
build_script:
- cmd: |
cd geowebcache
mvn install -T2 -Dall -fae -U
version: 1.0.{build}
branches:
only:
- master
cache:
- C:\Users\appveyor\.m2\ -> geowebcache\pom.xml
build_script:
- cmd: |
cd geowebcache
mvn install -T2 -Dall -fae -U
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. _configuration.layers.selectivezoomlevel:
.. _configuration.layers.selectivezoomlevel:

Selective zoom level caching
============================
Expand Down
Original file line number Diff line number Diff line change
@@ -1,121 +1,121 @@
/**
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU Lesser General Public License as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
*
* <p>This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* <p>You should have received a copy of the GNU Lesser General Public License along with this
* program. If not, see <http://www.gnu.org/licenses/>.
*
* <p>Copyright 2019
*/
package org.geowebcache.arcgis.compact;

import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.geowebcache.io.Resource;

/**
* Abstract base class for ArcGIS compact caches.
*
* @author Bjoern Saxe
*/
public abstract class ArcGISCompactCache {
private static final Log logger = LogFactory.getLog(ArcGISCompactCache.class);

protected static final String BUNDLX_EXT = ".bundlx";

protected static final String BUNDLE_EXT = ".bundle";

protected static final int BUNDLX_MAXIDX = 128;

protected String pathToCacheRoot = "";

/**
* Get Resource object for tile.
*
* @param zoom Zoom level.
* @param row Row of tile.
* @param col Column of tile.
* @return Resource object associated with tile image data if tile exists; null otherwise.
*/
public abstract Resource getBundleFileResource(int zoom, int row, int col);

/**
* Build path to a bundle from zoom, col, and row without file extension.
*
* @param zoom Zoom levl
* @param row Row
* @param col Column
* @return String containing complete path without file extension in the form of
* .../Lzz/RrrrrCcccc with the number of c and r at least 4.
*/
protected String buildBundleFilePath(int zoom, int row, int col) {
StringBuilder bundlePath = new StringBuilder(pathToCacheRoot);

int baseRow = (row / BUNDLX_MAXIDX) * BUNDLX_MAXIDX;
int baseCol = (col / BUNDLX_MAXIDX) * BUNDLX_MAXIDX;

String zoomStr = Integer.toString(zoom);
if (zoomStr.length() < 2) zoomStr = "0" + zoomStr;

StringBuilder rowStr = new StringBuilder(Integer.toHexString(baseRow));
StringBuilder colStr = new StringBuilder(Integer.toHexString(baseCol));

// column and rows are at least 4 characters long
final int padding = 4;

while (colStr.length() < padding) colStr.insert(0, "0");

while (rowStr.length() < padding) rowStr.insert(0, "0");

bundlePath
.append("L")
.append(zoomStr)
.append(File.separatorChar)
.append("R")
.append(rowStr)
.append("C")
.append(colStr);

return bundlePath.toString();
}

/**
* Read from a file that uses little endian byte order.
*
* @param filePath Path to file
* @param offset Read at offset
* @param length Read length bytes
* @return ByteBuffer that contains read bytes and has byte order set to little endian. The
* length of the byte buffer is multiple of 4, so getInt() and getLong() can be used even
* when fewer bytes are read.
*/
protected ByteBuffer readFromLittleEndianFile(String filePath, long offset, int length) {
ByteBuffer result = null;

try (RandomAccessFile file = new RandomAccessFile(filePath, "r")) {
file.seek(offset);
// pad to multiples of 4 so we can use getInt() and getLong()
int padding = 4 - (length % 4);
byte[] data = new byte[length + padding];

if (file.read(data, 0, length) != length)
throw new IOException("not enough bytes read or reached end of file");

result = ByteBuffer.wrap(data).order(ByteOrder.LITTLE_ENDIAN);
} catch (IOException e) {
logger.warn("Failed to read from little endian file", e);
}

return result;
}
}
/**
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU Lesser General Public License as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
*
* <p>This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* <p>You should have received a copy of the GNU Lesser General Public License along with this
* program. If not, see <http://www.gnu.org/licenses/>.
*
* <p>Copyright 2019
*/
package org.geowebcache.arcgis.compact;

import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.geowebcache.io.Resource;

/**
* Abstract base class for ArcGIS compact caches.
*
* @author Bjoern Saxe
*/
public abstract class ArcGISCompactCache {
private static final Log logger = LogFactory.getLog(ArcGISCompactCache.class);

protected static final String BUNDLX_EXT = ".bundlx";

protected static final String BUNDLE_EXT = ".bundle";

protected static final int BUNDLX_MAXIDX = 128;

protected String pathToCacheRoot = "";

/**
* Get Resource object for tile.
*
* @param zoom Zoom level.
* @param row Row of tile.
* @param col Column of tile.
* @return Resource object associated with tile image data if tile exists; null otherwise.
*/
public abstract Resource getBundleFileResource(int zoom, int row, int col);

/**
* Build path to a bundle from zoom, col, and row without file extension.
*
* @param zoom Zoom levl
* @param row Row
* @param col Column
* @return String containing complete path without file extension in the form of
* .../Lzz/RrrrrCcccc with the number of c and r at least 4.
*/
protected String buildBundleFilePath(int zoom, int row, int col) {
StringBuilder bundlePath = new StringBuilder(pathToCacheRoot);

int baseRow = (row / BUNDLX_MAXIDX) * BUNDLX_MAXIDX;
int baseCol = (col / BUNDLX_MAXIDX) * BUNDLX_MAXIDX;

String zoomStr = Integer.toString(zoom);
if (zoomStr.length() < 2) zoomStr = "0" + zoomStr;

StringBuilder rowStr = new StringBuilder(Integer.toHexString(baseRow));
StringBuilder colStr = new StringBuilder(Integer.toHexString(baseCol));

// column and rows are at least 4 characters long
final int padding = 4;

while (colStr.length() < padding) colStr.insert(0, "0");

while (rowStr.length() < padding) rowStr.insert(0, "0");

bundlePath
.append("L")
.append(zoomStr)
.append(File.separatorChar)
.append("R")
.append(rowStr)
.append("C")
.append(colStr);

return bundlePath.toString();
}

/**
* Read from a file that uses little endian byte order.
*
* @param filePath Path to file
* @param offset Read at offset
* @param length Read length bytes
* @return ByteBuffer that contains read bytes and has byte order set to little endian. The
* length of the byte buffer is multiple of 4, so getInt() and getLong() can be used even
* when fewer bytes are read.
*/
protected ByteBuffer readFromLittleEndianFile(String filePath, long offset, int length) {
ByteBuffer result = null;

try (RandomAccessFile file = new RandomAccessFile(filePath, "r")) {
file.seek(offset);
// pad to multiples of 4 so we can use getInt() and getLong()
int padding = 4 - (length % 4);
byte[] data = new byte[length + padding];

if (file.read(data, 0, length) != length)
throw new IOException("not enough bytes read or reached end of file");

result = ByteBuffer.wrap(data).order(ByteOrder.LITTLE_ENDIAN);
} catch (IOException e) {
logger.warn("Failed to read from little endian file", e);
}

return result;
}
}
Loading

0 comments on commit 5f670f0

Please sign in to comment.