read elevation type from rd5

This commit is contained in:
afischerdev 2023-11-28 15:14:13 +01:00
parent 477c675d46
commit 16d019c1d0
3 changed files with 26 additions and 0 deletions

View file

@ -385,4 +385,20 @@ public final class NodesCache {
} }
} }
} }
public int getElevationType(int ilon, int ilat) {
int lonDegree = ilon / 1000000;
int latDegree = ilat / 1000000;
OsmFile[] fileRow = fileRows[latDegree];
int ndegrees = fileRow == null ? 0 : fileRow.length;
for (int i = 0; i < ndegrees; i++) {
if (fileRow[i].lonDegree == lonDegree) {
OsmFile osmf = fileRow[i];
if (osmf != null) return osmf.elevationType;
break;
}
}
return 3;
}
} }

View file

@ -33,6 +33,7 @@ final class OsmFile {
private int cellsize; private int cellsize;
private int ncaches; private int ncaches;
private int indexsize; private int indexsize;
protected byte elevationType = 3;
public OsmFile(PhysicalFile rafile, int lonDegree, int latDegree, DataBuffers dataBuffers) throws IOException { public OsmFile(PhysicalFile rafile, int lonDegree, int latDegree, DataBuffers dataBuffers) throws IOException {
this.lonDegree = lonDegree; this.lonDegree = lonDegree;
@ -43,6 +44,7 @@ final class OsmFile {
if (rafile != null) { if (rafile != null) {
divisor = rafile.divisor; divisor = rafile.divisor;
elevationType = rafile.elevationType;
cellsize = 1000000 / divisor; cellsize = 1000000 / divisor;
ncaches = divisor * divisor; ncaches = divisor * divisor;

View file

@ -24,6 +24,7 @@ final public class PhysicalFile {
String fileName; String fileName;
public int divisor = 80; public int divisor = 80;
public byte elevationType = 3;
public static void main(String[] args) { public static void main(String[] args) {
MicroCache.debug = true; MicroCache.debug = true;
@ -113,6 +114,10 @@ final public class PhysicalFile {
if (len == pos) return; // old format o.k. if (len == pos) return; // old format o.k.
if ((len-pos) > extraLen) {
extraLen++;
}
if (len < pos + extraLen) { // > is o.k. for future extensions! if (len < pos + extraLen) { // > is o.k. for future extensions!
throw new IOException("file of size " + len + " too short, should be " + (pos + extraLen)); throw new IOException("file of size " + len + " too short, should be " + (pos + extraLen));
} }
@ -134,5 +139,8 @@ final public class PhysicalFile {
for (int i = 0; i < 25; i++) { for (int i = 0; i < 25; i++) {
fileHeaderCrcs[i] = dis.readInt(); fileHeaderCrcs[i] = dis.readInt();
} }
try {
elevationType = dis.readByte();
} catch (Exception e) {}
} }
} }