Mapsforge maps v5 support (#429)
This commit is contained in:
parent
dfd3a7dcf6
commit
cd5a62a2ff
@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||||
* Copyright 2017 devemux86
|
* Copyright 2017 devemux86
|
||||||
|
* Copyright 2017 Gustl22
|
||||||
*
|
*
|
||||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||||
*
|
*
|
||||||
@ -24,6 +25,9 @@ import org.oscim.utils.Parameters;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.RandomAccessFile;
|
import java.io.RandomAccessFile;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -50,6 +54,18 @@ public class ReadBuffer {
|
|||||||
return mBufferData[mBufferPosition++];
|
return mBufferData[mBufferPosition++];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts four bytes from the read buffer to a float.
|
||||||
|
*
|
||||||
|
* @return the float value.
|
||||||
|
*/
|
||||||
|
public float readFloat() {
|
||||||
|
byte[] bytes = new byte[4];
|
||||||
|
System.arraycopy(mBufferData, mBufferPosition, bytes, 0, 4);
|
||||||
|
mBufferPosition += 4;
|
||||||
|
return ByteBuffer.wrap(bytes).getFloat();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the given amount of bytes from the file into the read buffer and
|
* Reads the given amount of bytes from the file into the read buffer and
|
||||||
* resets the internal buffer position. If
|
* resets the internal buffer position. If
|
||||||
@ -394,6 +410,7 @@ public class ReadBuffer {
|
|||||||
|
|
||||||
boolean readTags(TagSet tags, Tag[] wayTags, byte numberOfTags) {
|
boolean readTags(TagSet tags, Tag[] wayTags, byte numberOfTags) {
|
||||||
tags.clear();
|
tags.clear();
|
||||||
|
List<Integer> ids = new ArrayList<>();
|
||||||
|
|
||||||
int maxTag = wayTags.length;
|
int maxTag = wayTags.length;
|
||||||
|
|
||||||
@ -401,10 +418,36 @@ public class ReadBuffer {
|
|||||||
int tagId = readUnsignedInt();
|
int tagId = readUnsignedInt();
|
||||||
if (tagId < 0 || tagId >= maxTag) {
|
if (tagId < 0 || tagId >= maxTag) {
|
||||||
LOG.warning("invalid tag ID: " + tagId);
|
LOG.warning("invalid tag ID: " + tagId);
|
||||||
return true;
|
break;
|
||||||
}
|
}
|
||||||
tags.add(wayTags[tagId]);
|
ids.add(tagId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (Integer id : ids) {
|
||||||
|
Tag tag = wayTags[id];
|
||||||
|
// Decode variable values of tags
|
||||||
|
if (tag.value.charAt(0) == '%' && tag.value.length() == 2) {
|
||||||
|
String value = tag.value;
|
||||||
|
if (value.charAt(1) == 'b') {
|
||||||
|
value = String.valueOf(readByte());
|
||||||
|
} else if (value.charAt(1) == 'i') {
|
||||||
|
if (tag.key.contains(":colour")) {
|
||||||
|
value = "#" + Integer.toHexString(readInt());
|
||||||
|
} else {
|
||||||
|
value = String.valueOf(readInt());
|
||||||
|
}
|
||||||
|
} else if (value.charAt(1) == 'f') {
|
||||||
|
value = String.valueOf(readFloat());
|
||||||
|
} else if (value.charAt(1) == 'h') {
|
||||||
|
value = String.valueOf(readShort());
|
||||||
|
} else if (value.charAt(1) == 's') {
|
||||||
|
value = readUTF8EncodedString();
|
||||||
|
}
|
||||||
|
tag = new Tag(tag.key, value);
|
||||||
|
}
|
||||||
|
tags.add(tag);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ final class RequiredFields {
|
|||||||
/**
|
/**
|
||||||
* Highest version of the map file format supported by this implementation.
|
* Highest version of the map file format supported by this implementation.
|
||||||
*/
|
*/
|
||||||
private static final int SUPPORTED_FILE_VERSION_MAX = 4;
|
private static final int SUPPORTED_FILE_VERSION_MAX = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The maximum latitude values in microdegrees.
|
* The maximum latitude values in microdegrees.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user