Integrate access information in RoadInformation.
This commit is contained in:
@@ -148,7 +148,8 @@ public class BinaryGraphReaderInsa2016 extends BinaryReader implements GraphRead
|
||||
float dlon = (dis.readShort()) / 2.0e5f;
|
||||
float dlat = (dis.readShort()) / 2.0e5f;
|
||||
|
||||
points.add(new Point(lastPoint.getLongitude() + dlon, lastPoint.getLatitude() + dlat));
|
||||
points.add(new Point(lastPoint.getLongitude() + dlon,
|
||||
lastPoint.getLatitude() + dlat));
|
||||
}
|
||||
|
||||
points.add(nodes.get(destNode).getPoint());
|
||||
@@ -188,7 +189,8 @@ public class BinaryGraphReaderInsa2016 extends BinaryReader implements GraphRead
|
||||
private RoadInformation readRoadInformation() throws IOException {
|
||||
char type = (char) dis.readUnsignedByte();
|
||||
int x = dis.readUnsignedByte();
|
||||
return new RoadInformation(toRoadType(type), (x & 0x80) > 0, (x & 0x7F) * 5, dis.readUTF());
|
||||
return new RoadInformation(toRoadType(type), 0, (x & 0x80) > 0, (x & 0x7F) * 5,
|
||||
dis.readUTF());
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -154,7 +154,8 @@ public class BinaryGraphReaderInsa2018 extends BinaryReader implements GraphRead
|
||||
float dlon = (dis.readShort()) / 2.0e5f;
|
||||
float dlat = (dis.readShort()) / 2.0e5f;
|
||||
|
||||
points.add(new Point(lastPoint.getLongitude() + dlon, lastPoint.getLatitude() + dlat));
|
||||
points.add(new Point(lastPoint.getLongitude() + dlon,
|
||||
lastPoint.getLatitude() + dlat));
|
||||
}
|
||||
|
||||
points.add(nodes.get(destNode).getPoint());
|
||||
@@ -193,7 +194,12 @@ public class BinaryGraphReaderInsa2018 extends BinaryReader implements GraphRead
|
||||
private RoadInformation readRoadInformation() throws IOException {
|
||||
char type = (char) dis.readUnsignedByte();
|
||||
int x = dis.readUnsignedByte();
|
||||
return new RoadInformation(toRoadType(type), (x & 0x80) > 0, (x & 0x7F) * 5, dis.readUTF());
|
||||
int access = 0xFF00;
|
||||
if (getCurrentVersion() >= 6) {
|
||||
access = dis.readUnsignedShort();
|
||||
}
|
||||
return new RoadInformation(toRoadType(type), access, (x & 0x80) > 0, (x & 0x7F) * 5,
|
||||
dis.readUTF());
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -8,7 +8,8 @@ import java.util.List;
|
||||
public abstract class BinaryReader {
|
||||
|
||||
// Map version and magic number targeted for this reader.
|
||||
private int version;
|
||||
private int minVersion;
|
||||
private int curVersion;
|
||||
private int magicNumber;
|
||||
|
||||
// InputStream
|
||||
@@ -17,9 +18,9 @@ public abstract class BinaryReader {
|
||||
// List of observers
|
||||
protected List<GraphReaderObserver> observers = new ArrayList<>();
|
||||
|
||||
protected BinaryReader(int magicNumber, int version, DataInputStream dis) {
|
||||
protected BinaryReader(int magicNumber, int minVersion, DataInputStream dis) {
|
||||
this.magicNumber = magicNumber;
|
||||
this.version = version;
|
||||
this.minVersion = minVersion;
|
||||
this.dis = dis;
|
||||
}
|
||||
|
||||
@@ -31,20 +32,31 @@ public abstract class BinaryReader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given version is greater than the minimum version, and update
|
||||
* the current version if it is.
|
||||
*
|
||||
* @param version
|
||||
* @throws BadVersionException
|
||||
*/
|
||||
public void checkVersionOrThrow(int version) throws BadVersionException {
|
||||
if (this.version != version) {
|
||||
throw new BadVersionException(version, this.version);
|
||||
protected void checkVersionOrThrow(int version) throws BadVersionException {
|
||||
if (version < this.minVersion) {
|
||||
throw new BadVersionException(version, this.minVersion);
|
||||
}
|
||||
this.curVersion = version;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the current version.
|
||||
*/
|
||||
protected int getCurrentVersion() {
|
||||
return this.curVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param magicNumber
|
||||
* @throws BadMagicNumberException
|
||||
*/
|
||||
public void checkMagicNumberOrThrow(int magicNumber) throws BadMagicNumberException {
|
||||
protected void checkMagicNumberOrThrow(int magicNumber) throws BadMagicNumberException {
|
||||
if (this.magicNumber != magicNumber) {
|
||||
throw new BadMagicNumberException(magicNumber, this.magicNumber);
|
||||
}
|
||||
@@ -58,7 +70,7 @@ public abstract class BinaryReader {
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public void checkByteOrThrow(int i) throws IOException {
|
||||
protected void checkByteOrThrow(int i) throws IOException {
|
||||
if (dis.readUnsignedByte() != i) {
|
||||
throw new BadFormatException();
|
||||
}
|
||||
|
Reference in New Issue
Block a user