formatting
This commit is contained in:
@@ -25,6 +25,7 @@ public interface IMapDatabase {
|
||||
|
||||
/**
|
||||
* Starts a database query with the given parameters.
|
||||
*
|
||||
* @param tile
|
||||
* the tile to read.
|
||||
* @param mapDatabaseCallback
|
||||
@@ -48,6 +49,7 @@ public interface IMapDatabase {
|
||||
|
||||
/**
|
||||
* Opens MapDatabase
|
||||
*
|
||||
* @param options
|
||||
* the options.
|
||||
* @return a OpenResult containing an error message in case of a failure.
|
||||
|
||||
@@ -19,11 +19,14 @@ import org.oscim.database.mapfile.MapDatabase;
|
||||
|
||||
/**
|
||||
* Callback methods which can be triggered from the {@link MapDatabase}.
|
||||
* ____
|
||||
* NOTE: All parameters passed belong to the caller! i.e. dont hold
|
||||
* references to any arrays after callback function returns.
|
||||
*/
|
||||
public interface IMapDatabaseCallback {
|
||||
/**
|
||||
* Renders a single point of interest node (POI).
|
||||
*
|
||||
*
|
||||
* @param layer
|
||||
* the layer of the node.
|
||||
* @param tags
|
||||
@@ -42,17 +45,18 @@ public interface IMapDatabaseCallback {
|
||||
|
||||
/**
|
||||
* Renders a single way or area (closed way).
|
||||
*
|
||||
*
|
||||
* @param layer
|
||||
* the layer of the way.
|
||||
* the osm layer of the way.
|
||||
* @param tags
|
||||
* the tags of the way.
|
||||
* @param wayNodes
|
||||
* the geographical coordinates of the way nodes in the order longitude/latitude.
|
||||
* the geographical coordinates of the way nodes in the order
|
||||
* longitude/latitude or x/y depending on the projection.
|
||||
* @param wayLength
|
||||
* length of way data in wayNodes
|
||||
* @param closed
|
||||
* way is closed (means need to add endpoint == startpoint)
|
||||
* wheter the way is an polygon.
|
||||
* @param prio TODO
|
||||
*/
|
||||
void renderWay(byte layer, Tag[] tags, float[] wayNodes, short[] wayLength,
|
||||
@@ -60,12 +64,13 @@ public interface IMapDatabaseCallback {
|
||||
|
||||
/**
|
||||
* TBD: check if way will be rendered before decoding
|
||||
*
|
||||
*
|
||||
* @param tags
|
||||
* ...
|
||||
* @param closed
|
||||
* ...
|
||||
* @return true if the way will be rendered (i.e. found match in RenderTheme)
|
||||
* @return true if the way will be rendered (i.e. found match in
|
||||
* RenderTheme)
|
||||
*/
|
||||
boolean checkWay(Tag[] tags, boolean closed);
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ package org.oscim.database;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public final class MapDatabaseFactory {
|
||||
@@ -25,7 +25,8 @@ public final class MapDatabaseFactory {
|
||||
|
||||
/**
|
||||
* @param attributeSet
|
||||
* A collection of attributes which includes the desired MapDatabase.
|
||||
* A collection of attributes which includes the desired
|
||||
* MapDatabase.
|
||||
* @return a new MapDatabase instance.
|
||||
*/
|
||||
public static IMapDatabase createMapDatabase(AttributeSet attributeSet) {
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.oscim.database.mapfile.MapDatabase;
|
||||
|
||||
/**
|
||||
* Contains the immutable metadata of a map file.
|
||||
*
|
||||
*
|
||||
* @see MapDatabase#getMapInfo()
|
||||
*/
|
||||
public class MapInfo {
|
||||
@@ -80,7 +80,8 @@ public class MapInfo {
|
||||
public final Byte startZoomLevel;
|
||||
|
||||
/**
|
||||
* Zoomlevels provided by this Database, if null then any zoomlevel can be queried.
|
||||
* Zoomlevels provided by this Database, if null then any zoomlevel can be
|
||||
* queried.
|
||||
*/
|
||||
public final int[] zoomLevel;
|
||||
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
*/
|
||||
package org.oscim.database;
|
||||
|
||||
|
||||
/**
|
||||
* A FileOpenResult is a simple DTO which is returned by IMapDatabase#openFile(File).
|
||||
* A FileOpenResult is a simple DTO which is returned by
|
||||
* IMapDatabase#openFile(File).
|
||||
*/
|
||||
public class OpenResult {
|
||||
/**
|
||||
@@ -41,7 +41,7 @@ public class OpenResult {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public OpenResult() {
|
||||
this.success = true;
|
||||
|
||||
@@ -22,7 +22,7 @@ final class Deserializer {
|
||||
* Converts five bytes of a byte array to an unsigned long.
|
||||
* <p>
|
||||
* The byte order is big-endian.
|
||||
*
|
||||
*
|
||||
* @param buffer
|
||||
* the byte array.
|
||||
* @param offset
|
||||
@@ -30,7 +30,8 @@ final class Deserializer {
|
||||
* @return the long value.
|
||||
*/
|
||||
static long getFiveBytesLong(byte[] buffer, int offset) {
|
||||
return (buffer[offset] & 0xffL) << 32 | (buffer[offset + 1] & 0xffL) << 24 | (buffer[offset + 2] & 0xffL) << 16
|
||||
return (buffer[offset] & 0xffL) << 32 | (buffer[offset + 1] & 0xffL) << 24
|
||||
| (buffer[offset + 2] & 0xffL) << 16
|
||||
| (buffer[offset + 3] & 0xffL) << 8 | (buffer[offset + 4] & 0xffL);
|
||||
}
|
||||
|
||||
@@ -38,7 +39,7 @@ final class Deserializer {
|
||||
* Converts four bytes of a byte array to a signed int.
|
||||
* <p>
|
||||
* The byte order is big-endian.
|
||||
*
|
||||
*
|
||||
* @param buffer
|
||||
* the byte array.
|
||||
* @param offset
|
||||
@@ -46,7 +47,8 @@ final class Deserializer {
|
||||
* @return the int value.
|
||||
*/
|
||||
static int getInt(byte[] buffer, int offset) {
|
||||
return buffer[offset] << 24 | (buffer[offset + 1] & 0xff) << 16 | (buffer[offset + 2] & 0xff) << 8
|
||||
return buffer[offset] << 24 | (buffer[offset + 1] & 0xff) << 16
|
||||
| (buffer[offset + 2] & 0xff) << 8
|
||||
| (buffer[offset + 3] & 0xff);
|
||||
}
|
||||
|
||||
@@ -54,7 +56,7 @@ final class Deserializer {
|
||||
* Converts eight bytes of a byte array to a signed long.
|
||||
* <p>
|
||||
* The byte order is big-endian.
|
||||
*
|
||||
*
|
||||
* @param buffer
|
||||
* the byte array.
|
||||
* @param offset
|
||||
@@ -62,16 +64,18 @@ final class Deserializer {
|
||||
* @return the long value.
|
||||
*/
|
||||
static long getLong(byte[] buffer, int offset) {
|
||||
return (buffer[offset] & 0xffL) << 56 | (buffer[offset + 1] & 0xffL) << 48 | (buffer[offset + 2] & 0xffL) << 40
|
||||
return (buffer[offset] & 0xffL) << 56 | (buffer[offset + 1] & 0xffL) << 48
|
||||
| (buffer[offset + 2] & 0xffL) << 40
|
||||
| (buffer[offset + 3] & 0xffL) << 32 | (buffer[offset + 4] & 0xffL) << 24
|
||||
| (buffer[offset + 5] & 0xffL) << 16 | (buffer[offset + 6] & 0xffL) << 8 | (buffer[offset + 7] & 0xffL);
|
||||
| (buffer[offset + 5] & 0xffL) << 16 | (buffer[offset + 6] & 0xffL) << 8
|
||||
| (buffer[offset + 7] & 0xffL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts two bytes of a byte array to a signed int.
|
||||
* <p>
|
||||
* The byte order is big-endian.
|
||||
*
|
||||
*
|
||||
* @param buffer
|
||||
* the byte array.
|
||||
* @param offset
|
||||
|
||||
@@ -37,7 +37,8 @@ class IndexCache {
|
||||
/**
|
||||
* Maximum size in bytes of one index block.
|
||||
*/
|
||||
private static final int SIZE_OF_INDEX_BLOCK = INDEX_ENTRIES_PER_BLOCK * SubFileParameter.BYTES_PER_INDEX_ENTRY;
|
||||
private static final int SIZE_OF_INDEX_BLOCK = INDEX_ENTRIES_PER_BLOCK
|
||||
* SubFileParameter.BYTES_PER_INDEX_ENTRY;
|
||||
|
||||
private final Map<IndexCacheEntryKey, byte[]> map;
|
||||
private final RandomAccessFile randomAccessFile;
|
||||
@@ -63,11 +64,13 @@ class IndexCache {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index entry of a block in the given map file. If the required index entry is not cached, it will be
|
||||
* Returns the index entry of a block in the given map file. If the required
|
||||
* index entry is not cached, it will be
|
||||
* read from the map file index and put in the cache.
|
||||
*
|
||||
*
|
||||
* @param subFileParameter
|
||||
* the parameters of the map file for which the index entry is needed.
|
||||
* the parameters of the map file for which the index entry is
|
||||
* needed.
|
||||
* @param blockNumber
|
||||
* the number of the block in the map file.
|
||||
* @return the index entry or -1 if the block number is invalid.
|
||||
@@ -83,13 +86,15 @@ class IndexCache {
|
||||
long indexBlockNumber = blockNumber / INDEX_ENTRIES_PER_BLOCK;
|
||||
|
||||
// create the cache entry key for this request
|
||||
IndexCacheEntryKey indexCacheEntryKey = new IndexCacheEntryKey(subFileParameter, indexBlockNumber);
|
||||
IndexCacheEntryKey indexCacheEntryKey = new IndexCacheEntryKey(subFileParameter,
|
||||
indexBlockNumber);
|
||||
|
||||
// check for cached index block
|
||||
byte[] indexBlock = this.map.get(indexCacheEntryKey);
|
||||
if (indexBlock == null) {
|
||||
// cache miss, seek to the correct index block in the file and read it
|
||||
long indexBlockPosition = subFileParameter.indexStartAddress + indexBlockNumber * SIZE_OF_INDEX_BLOCK;
|
||||
long indexBlockPosition = subFileParameter.indexStartAddress + indexBlockNumber
|
||||
* SIZE_OF_INDEX_BLOCK;
|
||||
|
||||
int remainingIndexSize = (int) (subFileParameter.indexEndAddress - indexBlockPosition);
|
||||
int indexBlockSize = Math.min(SIZE_OF_INDEX_BLOCK, remainingIndexSize);
|
||||
|
||||
@@ -26,7 +26,7 @@ class IndexCacheEntryKey {
|
||||
|
||||
/**
|
||||
* Creates an immutable key to be stored in a map.
|
||||
*
|
||||
*
|
||||
* @param subFileParameter
|
||||
* the parameters of the map file.
|
||||
* @param indexBlockNumber
|
||||
@@ -48,7 +48,8 @@ class IndexCacheEntryKey {
|
||||
IndexCacheEntryKey other = (IndexCacheEntryKey) obj;
|
||||
if (this.subFileParameter == null && other.subFileParameter != null) {
|
||||
return false;
|
||||
} else if (this.subFileParameter != null && !this.subFileParameter.equals(other.subFileParameter)) {
|
||||
} else if (this.subFileParameter != null
|
||||
&& !this.subFileParameter.equals(other.subFileParameter)) {
|
||||
return false;
|
||||
} else if (this.indexBlockNumber != other.indexBlockNumber) {
|
||||
return false;
|
||||
@@ -66,7 +67,8 @@ class IndexCacheEntryKey {
|
||||
*/
|
||||
private int calculateHashCode() {
|
||||
int result = 7;
|
||||
result = 31 * result + ((this.subFileParameter == null) ? 0 : this.subFileParameter.hashCode());
|
||||
result = 31 * result
|
||||
+ ((this.subFileParameter == null) ? 0 : this.subFileParameter.hashCode());
|
||||
result = 31 * result + (int) (this.indexBlockNumber ^ (this.indexBlockNumber >>> 32));
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ import android.os.Environment;
|
||||
* A class for reading binary map files.
|
||||
* <p>
|
||||
* This class is not thread-safe. Each thread should use its own instance.
|
||||
*
|
||||
*
|
||||
* @see <a
|
||||
* href="http://code.google.com/p/mapsforge/wiki/SpecificationBinaryMapFile">Specification</a>
|
||||
*/
|
||||
@@ -387,7 +387,7 @@ public class MapDatabase implements IMapDatabase {
|
||||
/**
|
||||
* Processes a single block and executes the callback functions on all map
|
||||
* elements.
|
||||
*
|
||||
*
|
||||
* @param queryParameters
|
||||
* the parameters of the current query.
|
||||
* @param subFileParameter
|
||||
@@ -567,7 +567,7 @@ public class MapDatabase implements IMapDatabase {
|
||||
|
||||
/**
|
||||
* Processes the block signature, if present.
|
||||
*
|
||||
*
|
||||
* @return true if the block signature could be processed successfully,
|
||||
* false otherwise.
|
||||
*/
|
||||
@@ -585,7 +585,7 @@ public class MapDatabase implements IMapDatabase {
|
||||
|
||||
/**
|
||||
* Processes the given number of POIs.
|
||||
*
|
||||
*
|
||||
* @param mapDatabaseCallback
|
||||
* the callback which handles the extracted POIs.
|
||||
* @param numberOfPois
|
||||
@@ -801,7 +801,7 @@ public class MapDatabase implements IMapDatabase {
|
||||
|
||||
/**
|
||||
* Processes the given number of ways.
|
||||
*
|
||||
*
|
||||
* @param queryParameters
|
||||
* the parameters of the current query.
|
||||
* @param mapDatabaseCallback
|
||||
|
||||
@@ -43,7 +43,7 @@ public class ReadBuffer {
|
||||
|
||||
/**
|
||||
* Returns one signed byte from the read buffer.
|
||||
*
|
||||
*
|
||||
* @return the byte value.
|
||||
*/
|
||||
public byte readByte() {
|
||||
@@ -51,9 +51,11 @@ public class ReadBuffer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the given amount of bytes from the file into the read buffer and resets the internal buffer position. If
|
||||
* the capacity of the read buffer is too small, a larger one is created automatically.
|
||||
*
|
||||
* Reads the given amount of bytes from the file into the read buffer and
|
||||
* resets the internal buffer position. If
|
||||
* the capacity of the read buffer is too small, a larger one is created
|
||||
* automatically.
|
||||
*
|
||||
* @param length
|
||||
* the amount of bytes to read from the file.
|
||||
* @return true if the whole data was read successfully, false otherwise.
|
||||
@@ -82,7 +84,7 @@ public class ReadBuffer {
|
||||
* Converts four bytes from the read buffer to a signed int.
|
||||
* <p>
|
||||
* The byte order is big-endian.
|
||||
*
|
||||
*
|
||||
* @return the int value.
|
||||
*/
|
||||
public int readInt() {
|
||||
@@ -100,7 +102,7 @@ public class ReadBuffer {
|
||||
* Converts eight bytes from the read buffer to a signed long.
|
||||
* <p>
|
||||
* The byte order is big-endian.
|
||||
*
|
||||
*
|
||||
* @return the long value.
|
||||
*/
|
||||
public long readLong() {
|
||||
@@ -123,7 +125,7 @@ public class ReadBuffer {
|
||||
* Converts two bytes from the read buffer to a signed int.
|
||||
* <p>
|
||||
* The byte order is big-endian.
|
||||
*
|
||||
*
|
||||
* @return the int value.
|
||||
*/
|
||||
public int readShort() {
|
||||
@@ -134,9 +136,10 @@ public class ReadBuffer {
|
||||
/**
|
||||
* Converts a variable amount of bytes from the read buffer to a signed int.
|
||||
* <p>
|
||||
* The first bit is for continuation info, the other six (last byte) or seven (all other bytes) bits are for data.
|
||||
* The second bit in the last byte indicates the sign of the number.
|
||||
*
|
||||
* The first bit is for continuation info, the other six (last byte) or
|
||||
* seven (all other bytes) bits are for data. The second bit in the last
|
||||
* byte indicates the sign of the number.
|
||||
*
|
||||
* @return the value.
|
||||
*/
|
||||
public int readSignedInt() {
|
||||
@@ -192,11 +195,13 @@ public class ReadBuffer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a variable amount of bytes from the read buffer to a signed int array.
|
||||
* Converts a variable amount of bytes from the read buffer to a signed int
|
||||
* array.
|
||||
* <p>
|
||||
* The first bit is for continuation info, the other six (last byte) or seven (all other bytes) bits are for data.
|
||||
* The second bit in the last byte indicates the sign of the number.
|
||||
*
|
||||
* The first bit is for continuation info, the other six (last byte) or
|
||||
* seven (all other bytes) bits are for data. The second bit in the last
|
||||
* byte indicates the sign of the number.
|
||||
*
|
||||
* @param values
|
||||
* result values
|
||||
* @param length
|
||||
@@ -322,10 +327,12 @@ public class ReadBuffer {
|
||||
// }
|
||||
|
||||
/**
|
||||
* Converts a variable amount of bytes from the read buffer to an unsigned int.
|
||||
* Converts a variable amount of bytes from the read buffer to an unsigned
|
||||
* int.
|
||||
* <p>
|
||||
* The first bit is for continuation info, the other seven bits are for data.
|
||||
*
|
||||
* The first bit is for continuation info, the other seven bits are for
|
||||
* data.
|
||||
*
|
||||
* @return the int value.
|
||||
*/
|
||||
public int readUnsignedInt() {
|
||||
@@ -368,7 +375,7 @@ public class ReadBuffer {
|
||||
|
||||
/**
|
||||
* Decodes a variable amount of bytes from the read buffer to a string.
|
||||
*
|
||||
*
|
||||
* @return the UTF-8 decoded string (may be null).
|
||||
*/
|
||||
public String readUTF8EncodedString() {
|
||||
@@ -387,7 +394,7 @@ public class ReadBuffer {
|
||||
|
||||
/**
|
||||
* Decodes the given amount of bytes from the read buffer to a string.
|
||||
*
|
||||
*
|
||||
* @param stringLength
|
||||
* the length of the string in bytes.
|
||||
* @return the UTF-8 decoded string (may be null).
|
||||
@@ -396,7 +403,8 @@ public class ReadBuffer {
|
||||
if (stringLength > 0 && mBufferPosition + stringLength <= mBufferData.length) {
|
||||
mBufferPosition += stringLength;
|
||||
try {
|
||||
return new String(mBufferData, mBufferPosition - stringLength, stringLength, CHARSET_UTF8);
|
||||
return new String(mBufferData, mBufferPosition - stringLength, stringLength,
|
||||
CHARSET_UTF8);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
@@ -407,7 +415,7 @@ public class ReadBuffer {
|
||||
|
||||
/**
|
||||
* Decodes a variable amount of bytes from the read buffer to a string.
|
||||
*
|
||||
*
|
||||
* @param position
|
||||
* buffer offset position of string
|
||||
* @return the UTF-8 decoded string (may be null).
|
||||
@@ -436,7 +444,7 @@ public class ReadBuffer {
|
||||
|
||||
/**
|
||||
* Sets the buffer position to the given offset.
|
||||
*
|
||||
*
|
||||
* @param bufferPosition
|
||||
* the buffer position.
|
||||
*/
|
||||
@@ -446,7 +454,7 @@ public class ReadBuffer {
|
||||
|
||||
/**
|
||||
* Skips the given number of bytes in the read buffer.
|
||||
*
|
||||
*
|
||||
* @param bytes
|
||||
* the number of bytes to skip.
|
||||
*/
|
||||
|
||||
@@ -80,7 +80,7 @@ public class MapFileHeader {
|
||||
|
||||
/**
|
||||
* Reads and validates the header block from the map file.
|
||||
*
|
||||
*
|
||||
* @param readBuffer
|
||||
* the ReadBuffer for the file data.
|
||||
* @param fileSize
|
||||
|
||||
@@ -19,7 +19,7 @@ import org.oscim.database.mapfile.MapDatabase;
|
||||
|
||||
/**
|
||||
* Contains the immutable metadata of a map file.
|
||||
*
|
||||
*
|
||||
* @see MapDatabase#getMapInfo()
|
||||
*/
|
||||
public class MapFileInfo extends org.oscim.database.MapInfo {
|
||||
|
||||
@@ -59,7 +59,8 @@ final class OptionalFields {
|
||||
*/
|
||||
private static final int START_ZOOM_LEVEL_MAX = 22;
|
||||
|
||||
static OpenResult readOptionalFields(ReadBuffer readBuffer, MapFileInfoBuilder mapFileInfoBuilder) {
|
||||
static OpenResult readOptionalFields(ReadBuffer readBuffer,
|
||||
MapFileInfoBuilder mapFileInfoBuilder) {
|
||||
OptionalFields optionalFields = new OptionalFields(readBuffer.readByte());
|
||||
mapFileInfoBuilder.optionalFields = optionalFields;
|
||||
|
||||
@@ -106,13 +107,15 @@ final class OptionalFields {
|
||||
if (this.hasStartPosition) {
|
||||
// get and check the start position latitude (4 byte)
|
||||
int mapStartLatitude = readBuffer.readInt();
|
||||
if (mapStartLatitude < RequiredFields.LATITUDE_MIN || mapStartLatitude > RequiredFields.LATITUDE_MAX) {
|
||||
if (mapStartLatitude < RequiredFields.LATITUDE_MIN
|
||||
|| mapStartLatitude > RequiredFields.LATITUDE_MAX) {
|
||||
return new OpenResult("invalid map start latitude: " + mapStartLatitude);
|
||||
}
|
||||
|
||||
// get and check the start position longitude (4 byte)
|
||||
int mapStartLongitude = readBuffer.readInt();
|
||||
if (mapStartLongitude < RequiredFields.LONGITUDE_MIN || mapStartLongitude > RequiredFields.LONGITUDE_MAX) {
|
||||
if (mapStartLongitude < RequiredFields.LONGITUDE_MIN
|
||||
|| mapStartLongitude > RequiredFields.LONGITUDE_MAX) {
|
||||
return new OpenResult("invalid map start longitude: " + mapStartLongitude);
|
||||
}
|
||||
|
||||
|
||||
@@ -104,11 +104,13 @@ final class RequiredFields {
|
||||
return new OpenResult("invalid longitude range: " + minLongitude + SPACE + maxLongitude);
|
||||
}
|
||||
|
||||
mapFileInfoBuilder.boundingBox = new BoundingBox(minLatitude, minLongitude, maxLatitude, maxLongitude);
|
||||
mapFileInfoBuilder.boundingBox = new BoundingBox(minLatitude, minLongitude, maxLatitude,
|
||||
maxLongitude);
|
||||
return OpenResult.SUCCESS;
|
||||
}
|
||||
|
||||
static OpenResult readFileSize(ReadBuffer readBuffer, long fileSize, MapFileInfoBuilder mapFileInfoBuilder) {
|
||||
static OpenResult readFileSize(ReadBuffer readBuffer, long fileSize,
|
||||
MapFileInfoBuilder mapFileInfoBuilder) {
|
||||
// get and check the file size (8 bytes)
|
||||
long headerFileSize = readBuffer.readLong();
|
||||
if (headerFileSize != fileSize) {
|
||||
@@ -174,7 +176,8 @@ final class RequiredFields {
|
||||
return OpenResult.SUCCESS;
|
||||
}
|
||||
|
||||
static OpenResult readProjectionName(ReadBuffer readBuffer, MapFileInfoBuilder mapFileInfoBuilder) {
|
||||
static OpenResult readProjectionName(ReadBuffer readBuffer,
|
||||
MapFileInfoBuilder mapFileInfoBuilder) {
|
||||
// get and check the projection name
|
||||
String projectionName = readBuffer.readUTF8EncodedString();
|
||||
if (!MERCATOR.equals(projectionName)) {
|
||||
|
||||
@@ -120,14 +120,18 @@ public class SubFileParameter {
|
||||
this.hashCodeValue = calculateHashCode();
|
||||
|
||||
// calculate the XY numbers of the boundary tiles in this sub-file
|
||||
this.boundaryTileBottom = MercatorProjection.latitudeToTileY(subFileParameterBuilder.boundingBox.minLatitudeE6
|
||||
/ COORDINATES_DIVISOR, this.baseZoomLevel);
|
||||
this.boundaryTileLeft = MercatorProjection.longitudeToTileX(subFileParameterBuilder.boundingBox.minLongitudeE6
|
||||
/ COORDINATES_DIVISOR, this.baseZoomLevel);
|
||||
this.boundaryTileTop = MercatorProjection.latitudeToTileY(subFileParameterBuilder.boundingBox.maxLatitudeE6
|
||||
/ COORDINATES_DIVISOR, this.baseZoomLevel);
|
||||
this.boundaryTileRight = MercatorProjection.longitudeToTileX(subFileParameterBuilder.boundingBox.maxLongitudeE6
|
||||
/ COORDINATES_DIVISOR, this.baseZoomLevel);
|
||||
this.boundaryTileBottom = MercatorProjection.latitudeToTileY(
|
||||
subFileParameterBuilder.boundingBox.minLatitudeE6
|
||||
/ COORDINATES_DIVISOR, this.baseZoomLevel);
|
||||
this.boundaryTileLeft = MercatorProjection.longitudeToTileX(
|
||||
subFileParameterBuilder.boundingBox.minLongitudeE6
|
||||
/ COORDINATES_DIVISOR, this.baseZoomLevel);
|
||||
this.boundaryTileTop = MercatorProjection.latitudeToTileY(
|
||||
subFileParameterBuilder.boundingBox.maxLatitudeE6
|
||||
/ COORDINATES_DIVISOR, this.baseZoomLevel);
|
||||
this.boundaryTileRight = MercatorProjection.longitudeToTileX(
|
||||
subFileParameterBuilder.boundingBox.maxLongitudeE6
|
||||
/ COORDINATES_DIVISOR, this.baseZoomLevel);
|
||||
|
||||
// calculate the horizontal and vertical amount of blocks in this sub-file
|
||||
this.blocksWidth = this.boundaryTileRight - this.boundaryTileLeft + 1;
|
||||
|
||||
@@ -48,7 +48,7 @@ import android.os.SystemClock;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class MapDatabase implements IMapDatabase {
|
||||
@@ -312,7 +312,7 @@ public class MapDatabase implements IMapDatabase {
|
||||
private Tag[][] mElementTags;
|
||||
|
||||
private void initDecorder() {
|
||||
// reusable tag set
|
||||
// reusable tag set
|
||||
Tag[][] tags = new Tag[10][];
|
||||
for (int i = 0; i < 10; i++)
|
||||
tags[i] = new Tag[i + 1];
|
||||
|
||||
@@ -51,7 +51,7 @@ import android.os.SystemClock;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class MapDatabase implements IMapDatabase {
|
||||
@@ -1239,8 +1239,10 @@ public class MapDatabase implements IMapDatabase {
|
||||
mCacheFile = null;
|
||||
}
|
||||
|
||||
/* All code below is taken from or based on Google's Protocol Buffers
|
||||
* implementation: */
|
||||
/*
|
||||
* All code below is taken from or based on Google's Protocol Buffers
|
||||
* implementation:
|
||||
*/
|
||||
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
/*
|
||||
* Geometry.java
|
||||
*
|
||||
*
|
||||
* PostGIS extension for PostgreSQL JDBC driver - geometry model
|
||||
*
|
||||
*
|
||||
* (C) 2004 Paul Ramsey, pramsey@refractions.net
|
||||
*
|
||||
*
|
||||
* (C) 2005 Markus Schaber, markus.schaber@logix-tt.com
|
||||
*
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Lesser General License as published by the Free
|
||||
* Software Foundation, either version 2.1 of the License.
|
||||
*
|
||||
*
|
||||
* This library 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 Lesser General License for more
|
||||
* details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General License
|
||||
* along with this library; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or visit the web at
|
||||
* http://www.gnu.org.
|
||||
*
|
||||
*
|
||||
* $Id: Geometry.java 9324 2012-02-27 22:08:12Z pramsey $
|
||||
*/
|
||||
|
||||
@@ -82,7 +82,7 @@ abstract class Geometry implements Serializable {
|
||||
|
||||
/**
|
||||
* The Text representations of the geometry types
|
||||
*
|
||||
*
|
||||
* @param type
|
||||
* ...
|
||||
* @return ...
|
||||
@@ -107,7 +107,8 @@ abstract class Geometry implements Serializable {
|
||||
boolean haveMeasure = false;
|
||||
|
||||
/**
|
||||
* The OGIS geometry type of this feature. this is final as it never changes, it is bound to the subclass of the
|
||||
* The OGIS geometry type of this feature. this is final as it never
|
||||
* changes, it is bound to the subclass of the
|
||||
* instance.
|
||||
*/
|
||||
final int type;
|
||||
@@ -124,7 +125,7 @@ abstract class Geometry implements Serializable {
|
||||
|
||||
/**
|
||||
* Parse a SRID value, anything <= 0 is unknown
|
||||
*
|
||||
*
|
||||
* @param srid
|
||||
* ...
|
||||
* @return ...
|
||||
@@ -139,7 +140,7 @@ abstract class Geometry implements Serializable {
|
||||
|
||||
/**
|
||||
* Constructor for subclasses
|
||||
*
|
||||
*
|
||||
* @param type
|
||||
* has to be given by all subclasses.
|
||||
*/
|
||||
@@ -165,8 +166,9 @@ abstract class Geometry implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* geometry specific equals implementation - only defined for non-null values
|
||||
*
|
||||
* geometry specific equals implementation - only defined for non-null
|
||||
* values
|
||||
*
|
||||
* @param other
|
||||
* ...
|
||||
* @return ...
|
||||
@@ -180,9 +182,10 @@ abstract class Geometry implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether test coordinates for geometry - subclass specific code Implementors can assume that dimensin, type, srid
|
||||
* Whether test coordinates for geometry - subclass specific code
|
||||
* Implementors can assume that dimensin, type, srid
|
||||
* and haveMeasure are equal, other != null and other is the same subclass.
|
||||
*
|
||||
*
|
||||
* @param other
|
||||
* ...
|
||||
* @return ...
|
||||
@@ -191,14 +194,14 @@ abstract class Geometry implements Serializable {
|
||||
|
||||
/**
|
||||
* Return the number of Points of the geometry
|
||||
*
|
||||
*
|
||||
* @return ...
|
||||
*/
|
||||
abstract int numPoints();
|
||||
|
||||
/**
|
||||
* Get the nth Point of the geometry
|
||||
*
|
||||
*
|
||||
* @param n
|
||||
* the index of the point, from 0 to numPoints()-1;
|
||||
* @throws ArrayIndexOutOfBoundsException
|
||||
@@ -219,7 +222,7 @@ abstract class Geometry implements Serializable {
|
||||
|
||||
/**
|
||||
* The OGIS geometry type number of this geometry.
|
||||
*
|
||||
*
|
||||
* @return ...
|
||||
*/
|
||||
int getType() {
|
||||
@@ -228,7 +231,7 @@ abstract class Geometry implements Serializable {
|
||||
|
||||
/**
|
||||
* Return the Type as String
|
||||
*
|
||||
*
|
||||
* @return ...
|
||||
*/
|
||||
String getTypeString() {
|
||||
@@ -237,7 +240,7 @@ abstract class Geometry implements Serializable {
|
||||
|
||||
/**
|
||||
* Returns whether we have a measure
|
||||
*
|
||||
*
|
||||
* @return ....
|
||||
*/
|
||||
boolean isMeasured() {
|
||||
@@ -245,9 +248,10 @@ abstract class Geometry implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Queries the number of geometric dimensions of this geometry. This does not include measures, as opposed to the
|
||||
* Queries the number of geometric dimensions of this geometry. This does
|
||||
* not include measures, as opposed to the
|
||||
* server.
|
||||
*
|
||||
*
|
||||
* @return The dimensionality (eg, 2D or 3D) of this geometry.
|
||||
*/
|
||||
int getDimension() {
|
||||
@@ -256,7 +260,7 @@ abstract class Geometry implements Serializable {
|
||||
|
||||
/**
|
||||
* The OGIS geometry type number of this geometry.
|
||||
*
|
||||
*
|
||||
* @return ...
|
||||
*/
|
||||
int getSrid() {
|
||||
@@ -264,8 +268,9 @@ abstract class Geometry implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively sets the srid on this geometry and all contained subgeometries
|
||||
*
|
||||
* Recursively sets the srid on this geometry and all contained
|
||||
* subgeometries
|
||||
*
|
||||
* @param srid
|
||||
* ...
|
||||
*/
|
||||
@@ -286,8 +291,9 @@ abstract class Geometry implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the WKT version of this Geometry (without SRID) into the given StringBuffer.
|
||||
*
|
||||
* Render the WKT version of this Geometry (without SRID) into the given
|
||||
* StringBuffer.
|
||||
*
|
||||
* @param sb
|
||||
* ...
|
||||
* @param putM
|
||||
@@ -306,8 +312,9 @@ abstract class Geometry implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the WKT without the type name, but including the brackets into the StringBuffer
|
||||
*
|
||||
* Render the WKT without the type name, but including the brackets into the
|
||||
* StringBuffer
|
||||
*
|
||||
* @param sb
|
||||
* ...
|
||||
*/
|
||||
@@ -318,8 +325,9 @@ abstract class Geometry implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the "inner" part of the WKT (inside the brackets) into the StringBuffer.
|
||||
*
|
||||
* Render the "inner" part of the WKT (inside the brackets) into the
|
||||
* StringBuffer.
|
||||
*
|
||||
* @param SB
|
||||
* ...
|
||||
*/
|
||||
@@ -327,7 +335,7 @@ abstract class Geometry implements Serializable {
|
||||
|
||||
/**
|
||||
* backwards compatibility method
|
||||
*
|
||||
*
|
||||
* @return ...
|
||||
*/
|
||||
String getValue() {
|
||||
@@ -337,12 +345,16 @@ abstract class Geometry implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Do some internal consistency checks on the geometry. Currently, all Geometries must have a valid dimension (2 or
|
||||
* 3) and a valid type. 2-dimensional Points must have Z=0.0, as well as non-measured Points must have m=0.0.
|
||||
* Composed geometries must have all equal SRID, dimensionality and measures, as well as that they do not contain
|
||||
* NULL or inconsistent subgeometries. BinaryParser and WKTParser should only generate consistent geometries.
|
||||
* Do some internal consistency checks on the geometry. Currently, all
|
||||
* Geometries must have a valid dimension (2 or
|
||||
* 3) and a valid type. 2-dimensional Points must have Z=0.0, as well as
|
||||
* non-measured Points must have m=0.0.
|
||||
* Composed geometries must have all equal SRID, dimensionality and
|
||||
* measures, as well as that they do not contain
|
||||
* NULL or inconsistent subgeometries. BinaryParser and WKTParser should
|
||||
* only generate consistent geometries.
|
||||
* BinaryWriter may produce invalid results on inconsistent geometries.
|
||||
*
|
||||
*
|
||||
* @return true if all checks are passed.
|
||||
*/
|
||||
boolean checkConsistency() {
|
||||
@@ -351,7 +363,7 @@ abstract class Geometry implements Serializable {
|
||||
|
||||
/**
|
||||
* Splits the SRID=4711; part of a EWKT rep if present and sets the srid.
|
||||
*
|
||||
*
|
||||
* @param value
|
||||
* ...
|
||||
* @return value without the SRID=4711; part
|
||||
|
||||
@@ -39,7 +39,7 @@ import org.postgresql.PGConnection;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class MapDatabase implements IMapDatabase {
|
||||
@@ -248,9 +248,10 @@ public class MapDatabase implements IMapDatabase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a binary encoded geometry. Is synchronized to protect offset counter. (Unfortunately, Java does not have
|
||||
* Parse a binary encoded geometry. Is synchronized to protect offset
|
||||
* counter. (Unfortunately, Java does not have
|
||||
* neither call by reference nor multiple return values.)
|
||||
*
|
||||
*
|
||||
* @param value
|
||||
* ...
|
||||
* @return ...
|
||||
@@ -328,7 +329,7 @@ public class MapDatabase implements IMapDatabase {
|
||||
|
||||
/**
|
||||
* Parse an Array of "full" Geometries
|
||||
*
|
||||
*
|
||||
* @param data
|
||||
* ...
|
||||
* @param count
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file has been copied from the following location:
|
||||
* http://archives.postgresql.org/pgsql-jdbc/2009-12/msg00037.php
|
||||
*
|
||||
*
|
||||
* PostgreSQL code is typically under a BSD licence.
|
||||
* http://jdbc.postgresql.org/license.html
|
||||
*/
|
||||
@@ -51,7 +51,7 @@ public class PGHStore extends PGobject implements Map<String, String>
|
||||
|
||||
/**
|
||||
* Initialize a hstore with a given string representation
|
||||
*
|
||||
*
|
||||
* @param value
|
||||
* String representated hstore
|
||||
* @throws SQLException
|
||||
@@ -96,7 +96,7 @@ public class PGHStore extends PGobject implements Map<String, String>
|
||||
|
||||
/**
|
||||
* Returns the stored information as a string
|
||||
*
|
||||
*
|
||||
* @return String represented hstore
|
||||
*/
|
||||
@Override
|
||||
@@ -144,7 +144,7 @@ public class PGHStore extends PGobject implements Map<String, String>
|
||||
|
||||
/**
|
||||
* Returns whether an object is equal to this one or not
|
||||
*
|
||||
*
|
||||
* @param obj
|
||||
* Object to compare with
|
||||
* @return true if the two hstores are identical
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
/*
|
||||
* ValueGetter.java
|
||||
*
|
||||
*
|
||||
* PostGIS extension for PostgreSQL JDBC driver - Binary Parser
|
||||
*
|
||||
*
|
||||
* (C) 2005 Markus Schaber, markus.schaber@logix-tt.com
|
||||
*
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Lesser General License as published by the Free
|
||||
* Software Foundation, either version 2.1 of the License.
|
||||
*
|
||||
*
|
||||
* This library 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 Lesser General License for more
|
||||
* details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General License
|
||||
* along with this library; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or visit the web at
|
||||
* http://www.gnu.org.
|
||||
*
|
||||
*
|
||||
* $Id: ValueGetter.java 9324 2012-02-27 22:08:12Z pramsey $
|
||||
*/
|
||||
|
||||
@@ -37,7 +37,7 @@ abstract class ValueGetter {
|
||||
|
||||
/**
|
||||
* Get a byte, should be equal for all endians
|
||||
*
|
||||
*
|
||||
* @return ...
|
||||
*/
|
||||
byte getByte() {
|
||||
@@ -58,7 +58,7 @@ abstract class ValueGetter {
|
||||
|
||||
/**
|
||||
* Get a 32-Bit integer
|
||||
*
|
||||
*
|
||||
* @param index
|
||||
* ...
|
||||
* @return ...
|
||||
@@ -66,8 +66,9 @@ abstract class ValueGetter {
|
||||
protected abstract int getInt(int index);
|
||||
|
||||
/**
|
||||
* Get a long value. This is not needed directly, but as a nice side-effect from GetDouble.
|
||||
*
|
||||
* Get a long value. This is not needed directly, but as a nice side-effect
|
||||
* from GetDouble.
|
||||
*
|
||||
* @param index
|
||||
* ...
|
||||
* @return ...
|
||||
@@ -76,7 +77,7 @@ abstract class ValueGetter {
|
||||
|
||||
/**
|
||||
* Get a double.
|
||||
*
|
||||
*
|
||||
* @return ...
|
||||
*/
|
||||
double getDouble() {
|
||||
@@ -101,9 +102,12 @@ abstract class ValueGetter {
|
||||
protected long getLong(int index) {
|
||||
|
||||
return ((long) (data[index] & 0xFF) << 56) | ((long) (data[index + 1] & 0xFF) << 48)
|
||||
| ((long) (data[index + 2] & 0xFF) << 40) | ((long) (data[index + 3] & 0xFF) << 32)
|
||||
| ((long) (data[index + 4] & 0xFF) << 24) | ((long) (data[index + 5] & 0xFF) << 16)
|
||||
| ((long) (data[index + 6] & 0xFF) << 8) | ((long) (data[index + 7] & 0xFF) << 0);
|
||||
| ((long) (data[index + 2] & 0xFF) << 40)
|
||||
| ((long) (data[index + 3] & 0xFF) << 32)
|
||||
| ((long) (data[index + 4] & 0xFF) << 24)
|
||||
| ((long) (data[index + 5] & 0xFF) << 16)
|
||||
| ((long) (data[index + 6] & 0xFF) << 8)
|
||||
| ((long) (data[index + 7] & 0xFF) << 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,9 +126,12 @@ abstract class ValueGetter {
|
||||
|
||||
@Override
|
||||
protected long getLong(int index) {
|
||||
return ((long) (data[index + 7] & 0xFF) << 56) | ((long) (data[index + 6] & 0xFF) << 48)
|
||||
| ((long) (data[index + 5] & 0xFF) << 40) | ((long) (data[index + 4] & 0xFF) << 32)
|
||||
| ((long) (data[index + 3] & 0xFF) << 24) | ((long) (data[index + 2] & 0xFF) << 16)
|
||||
return ((long) (data[index + 7] & 0xFF) << 56)
|
||||
| ((long) (data[index + 6] & 0xFF) << 48)
|
||||
| ((long) (data[index + 5] & 0xFF) << 40)
|
||||
| ((long) (data[index + 4] & 0xFF) << 32)
|
||||
| ((long) (data[index + 3] & 0xFF) << 24)
|
||||
| ((long) (data[index + 2] & 0xFF) << 16)
|
||||
| ((long) (data[index + 1] & 0xFF) << 8) | ((long) (data[index] & 0xFF) << 0);
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
*/
|
||||
package org.oscim.database.test;
|
||||
|
||||
|
||||
import org.oscim.core.BoundingBox;
|
||||
import org.oscim.core.Tag;
|
||||
import org.oscim.core.Tile;
|
||||
@@ -27,7 +26,7 @@ import org.oscim.database.QueryResult;
|
||||
import org.oscim.generator.JobTile;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class MapDatabase implements IMapDatabase {
|
||||
|
||||
Reference in New Issue
Block a user