Zmiany nazw. Inne porzadki.

This commit is contained in:
2026-01-22 23:22:33 +01:00
parent 1052cde48a
commit 94ec22b5ac
12 changed files with 257 additions and 991 deletions

View File

@@ -4,7 +4,7 @@ package pl.wat.ms4ds.terrain;
import javafx.scene.image.ImageView;
abstract class BigSquare {
abstract Square getKwadrat(int x, int y);
abstract Square getSquare(int x, int y);
protected transient String fileName;
public int idX = 0;

View File

@@ -7,7 +7,7 @@ class EmptyBigSquare extends BigSquare {
private EmptyBigSquare() {
}
Square getKwadrat(int ssX, int ssY) {
Square getSquare(int ssX, int ssY) {
return Square.EMPTY;
}
}

View File

@@ -12,28 +12,27 @@ public final class MapConsts {
private static final Logger LOGGER = LoggerFactory.getLogger(MapConsts.class);
/**
* Umowny uklad odniesienia dla lokalizacji geograficznej: <p>
* Długość geograficzna (wsp. X) przyjmuje wartości: [0, 360) odpowiadające [-180, 180]<p>
* Szerokość geograficzna (wsp. Y) przyjmuje wartości: [0, 180] odpowadające [-90, 90]
* Długość geograficzna referencyjna początku umownego układu współrzędnych w postaci siatki kwadratów. <p>
* Wartości długości geograficznej mapowane są: [-180, 180) -> [0, 360).
*/
public static final int X_REF;
public static final int LON_REF;
/**
* Umowny uklad odniesienia dla lokalizacji geograficznej: <p>
* Długość geograficzna (wsp. X) przyjmuje wartości: [0, 360) odpowiadające [-180, 180]<p>
* Szerokość geograficzna (wsp. Y) przyjmuje wartości: [0, 180] odpowadające [-90, 90]
* Szerokość geograficzna referencyjna początku umownego układu współrzędnych w postaci siatki kwadratów. <p>
* Wartości szerokości geograficznej mapowane są: [-90, 90] -> [0, 180].
*/
public static final int Y_REF;
public static final int DX_REF;
public static final int DY_REF;
public static final int LAT_REF;
public static final String KWADRATY_DIR;
public static final int DELTA_LON_REF;
public static final int DELTA_LAT_REF;
public static final String DATA_DIR;
/**
* Nazwa pliku z konfiguracja mechanizmu odpowiedzialnego za transfer. Plik
* musi znajdowac sie w katalogu glownym aplikacji, ewentualnie musi tu byc
* podana sciezka bezwzgledna do niego.
*/
private static final String PLIK_Z_USTAWIENIAMI = "teren.properties";
private static final String PROPERTIES_FILE = "teren.properties";
/**
* Dlugosc boku duzego kwadratu na osi OX w liczbie malych kwadratow.
@@ -50,15 +49,15 @@ public final class MapConsts {
/**
* Powierzchnia malego kwadratu w metrach.
*/
public static final int POW_MK;
public static final int SS_AREA;
/**
* Szerokość małego kwadratu w stopniach.
*/
public static final double DELTA_X;
public static final double SS_DELTA_LON;
/**
* Wysokość małego kwadratu w stopniach.
*/
public static final double DELTA_Y;
public static final double SS_DELTA_LAT;
/**
* Liczba duzych kwadratow na stopien geograficzny po osi OX (dlugosc geograficzna).
*/
@@ -75,7 +74,6 @@ public final class MapConsts {
* Wysokość duzych kwadratow w stopniach geograficznych po osi OY (szerokosc geograficzna).
*/
public static final double BS_DY;
/**
* Szerokości geograficzne środków kwadratów.
*/
@@ -88,7 +86,7 @@ public final class MapConsts {
static Properties ustawienia;
static {
String propertiesFileName = System.getProperty("user.dir") + "\\" + PLIK_Z_USTAWIENIAMI;
String propertiesFileName = System.getProperty("user.dir") + "\\" + PROPERTIES_FILE;
ustawienia = new Properties();
try {
@@ -101,13 +99,13 @@ public final class MapConsts {
// przesuniecie o 180 stop.
// poludnik zerowy ma wartosc 180, zatem wspolrzedne zachodnie (ujemne) zawierają sie w <0, 180)
// wspolrzedne wschodnie (nieujemne) zawieraja sie w przedziale <180, 360)
X_REF = Integer.parseInt(ustawienia.getProperty("x_ref")) + 180;
LON_REF = Integer.parseInt(ustawienia.getProperty("x_ref")) + 180;
// przesuniecie o 90 stop.
// rownik ma wartosc 90, zatem wspolrzedne poludniowe (ujemne) zawierają sie w <0, 90)
// wspolrzedne polnocne (nieujemne) zawieraja sie w przedziale <90, 180>
Y_REF = Integer.parseInt(ustawienia.getProperty("y_ref")) + 90;
DX_REF = Integer.parseInt(ustawienia.getProperty("dx_ref"));
DY_REF = Integer.parseInt(ustawienia.getProperty("dy_ref"));
LAT_REF = Integer.parseInt(ustawienia.getProperty("y_ref")) + 90;
DELTA_LON_REF = Integer.parseInt(ustawienia.getProperty("dx_ref"));
DELTA_LAT_REF = Integer.parseInt(ustawienia.getProperty("dy_ref"));
String val = ustawienia.getProperty("dl_mk");
switch (val) {
case "20":
@@ -126,50 +124,50 @@ public final class MapConsts {
SS_SIZE = 200;
break;
}
POW_MK = SS_SIZE * SS_SIZE;
SS_AREA = SS_SIZE * SS_SIZE;
if (SS_SIZE == 20) {
SS_PER_BS_X = 83 * 10;
SS_PER_BS_Y = 93 * 10;
DELTA_X = 1.0 / (double) (BS_PER_DEG_X * SS_PER_BS_X);
DELTA_Y = 1.0 / (double) (BS_PER_DEG_Y * SS_PER_BS_Y);
KWADRATY_DIR = ustawienia.getProperty("kwadraty_dir") + "20m/";
SS_DELTA_LON = 1.0 / (double) (BS_PER_DEG_X * SS_PER_BS_X);
SS_DELTA_LAT = 1.0 / (double) (BS_PER_DEG_Y * SS_PER_BS_Y);
DATA_DIR = ustawienia.getProperty("kwadraty_dir") + "20m/";
} else if (SS_SIZE == 25) {
SS_PER_BS_X = 83 * 8;
SS_PER_BS_Y = 93 * 8;
DELTA_X = 1.0 / (double) (BS_PER_DEG_X * SS_PER_BS_X);
DELTA_Y = 1.0 / (double) (BS_PER_DEG_Y * SS_PER_BS_Y);
KWADRATY_DIR = ustawienia.getProperty("kwadraty_dir") + "25m/";
SS_DELTA_LON = 1.0 / (double) (BS_PER_DEG_X * SS_PER_BS_X);
SS_DELTA_LAT = 1.0 / (double) (BS_PER_DEG_Y * SS_PER_BS_Y);
DATA_DIR = ustawienia.getProperty("kwadraty_dir") + "25m/";
} else if (SS_SIZE == 50) {
SS_PER_BS_X = 83 * 4;
SS_PER_BS_Y = 93 * 4;
DELTA_X = 1.0 / (double) (BS_PER_DEG_X * SS_PER_BS_X);
DELTA_Y = 1.0 / (double) (BS_PER_DEG_Y * SS_PER_BS_Y);
KWADRATY_DIR = ustawienia.getProperty("kwadraty_dir") + "50m/";
SS_DELTA_LON = 1.0 / (double) (BS_PER_DEG_X * SS_PER_BS_X);
SS_DELTA_LAT = 1.0 / (double) (BS_PER_DEG_Y * SS_PER_BS_Y);
DATA_DIR = ustawienia.getProperty("kwadraty_dir") + "50m/";
} else if (SS_SIZE == 100) {
SS_PER_BS_X = 83 * 2;
SS_PER_BS_Y = 93 * 2;
DELTA_X = 1.0 / (double) (BS_PER_DEG_X * SS_PER_BS_X);
DELTA_Y = 1.0 / (double) (BS_PER_DEG_Y * SS_PER_BS_Y);
KWADRATY_DIR = ustawienia.getProperty("kwadraty_dir") + "100m/";
SS_DELTA_LON = 1.0 / (double) (BS_PER_DEG_X * SS_PER_BS_X);
SS_DELTA_LAT = 1.0 / (double) (BS_PER_DEG_Y * SS_PER_BS_Y);
DATA_DIR = ustawienia.getProperty("kwadraty_dir") + "100m/";
} else {
// domyslnie dlugosc kwadratu 200m
SS_PER_BS_X = 83;
SS_PER_BS_Y = 93;
DELTA_X = 1.0 / (double) (BS_PER_DEG_X * SS_PER_BS_X);
DELTA_Y = 1.0 / (double) (BS_PER_DEG_Y * SS_PER_BS_Y);
KWADRATY_DIR = ustawienia.getProperty("kwadraty_dir") + "200m/";
SS_DELTA_LON = 1.0 / (double) (BS_PER_DEG_X * SS_PER_BS_X);
SS_DELTA_LAT = 1.0 / (double) (BS_PER_DEG_Y * SS_PER_BS_Y);
DATA_DIR = ustawienia.getProperty("kwadraty_dir") + "200m/";
}
BS_DX = 1.0 / (double) BS_PER_DEG_X;
BS_DY = 1.0 / (double) BS_PER_DEG_Y;
LONS = new double[DX_REF * BS_PER_DEG_X * SS_PER_BS_X];
LONS = new double[DELTA_LON_REF * BS_PER_DEG_X * SS_PER_BS_X];
for (int i = 0; i < LONS.length; i++) {
LONS[i] = X_REF + DELTA_X * (i + 0.5);
LONS[i] = LON_REF + SS_DELTA_LON * (i + 0.5);
}
LATS = new double[DY_REF * BS_PER_DEG_Y * SS_PER_BS_Y];
LATS = new double[DELTA_LAT_REF * BS_PER_DEG_Y * SS_PER_BS_Y];
for (int i = 0; i < LATS.length; i++) {
LATS[i] = Y_REF + DELTA_Y * (i + 0.5);
LATS[i] = LAT_REF + SS_DELTA_LAT * (i + 0.5);
}
LOGGER.debug("Wczytane ustawienia:\n \tLON_REF={}, LAT_REF={}, DX_REF={}, DY_REF{}, SQUARE_SIZE={}, GRID_SIZE={}x{}, DATA_DIR={}", X_REF, Y_REF, DX_REF, DY_REF, SS_SIZE, LONS.length, LATS.length, KWADRATY_DIR);
LOGGER.debug("Wczytane ustawienia:\n \tLON_REF={}, LAT_REF={}, DX_REF={}, DY_REF{}, SQUARE_SIZE={}, GRID_SIZE={}x{}, DATA_DIR={}", LON_REF, LAT_REF, DELTA_LON_REF, DELTA_LAT_REF, SS_SIZE, LONS.length, LATS.length, DATA_DIR);
}
/**
@@ -191,7 +189,7 @@ public final class MapConsts {
* @return
*/
public static int getX_REF() {
return X_REF;
return LON_REF;
}
/**
@@ -200,7 +198,7 @@ public final class MapConsts {
* @return
*/
public static int getY_REF() {
return Y_REF;
return LAT_REF;
}
/**
@@ -209,7 +207,7 @@ public final class MapConsts {
* @return
*/
public static int getDX_REF() {
return DX_REF;
return DELTA_LON_REF;
}
/**
@@ -218,25 +216,25 @@ public final class MapConsts {
* @return
*/
public static int getDY_REF() {
return DY_REF;
return DELTA_LAT_REF;
}
/**
* Dlugosci bokow malego kwadratu w milisekundach geograficznych po osi OX (dlugosc geograficzna).
*/
public static final double SS_DX_MS = DELTA_X * DEG_MS;
public static final double SS_DX_MS = SS_DELTA_LON * DEG_MS;
/**
* Dlugosci bokow malego kwadratu w milisekundach geograficznych po osi OY (szerokosc geograficzna).
*/
public static final double SS_DY_MS = DELTA_Y * DEG_MS;
public static final double SS_DY_MS = SS_DELTA_LAT * DEG_MS;
// wspolrzedne dolnego lewego rogu mapy w ms
// wspolrzedne geograficzne w milisekundach zawieraja sie w zakresie:
// 0 <= x < 360 dlugosc geograficzna
// 0 <= y <= 180 szerokosc geograficzna
public static final int X_REF_MS = X_REF * DEG_MS;
public static final int Y_REF_MS = Y_REF * DEG_MS;
public static final int DX_REF_MS = DEG_MS * DX_REF; // szerokosc pola walki w stopniach
public static final int DY_REF_MS = DEG_MS * DY_REF; // wysokosc polwa walki w stopniach
public static final int X_REF_MS = LON_REF * DEG_MS;
public static final int Y_REF_MS = LAT_REF * DEG_MS;
public static final int DX_REF_MS = DEG_MS * DELTA_LON_REF; // szerokosc pola walki w stopniach
public static final int DY_REF_MS = DEG_MS * DELTA_LAT_REF; // wysokosc polwa walki w stopniach
public static final int BS_DX_MS = (int) (BS_DX * DEG_MS);
public static final int BS_DY_MS = (int) (BS_DY * DEG_MS);

View File

@@ -2,7 +2,7 @@ package pl.wat.ms4ds.terrain;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pl.wat.ms4ds.terrain.konwersja.CoordUtils;
import pl.wat.ms4ds.terrain.nmt.NMTDataReader;
import java.io.*;
@@ -12,42 +12,11 @@ public class RightBigSquare extends BigSquare {
private Square[][] squares;
Square getKwadrat(int ssX, int ssY) {
Square getSquare(int ssX, int ssY) {
return squares[ssX][ssY];
}
static final int NORTH = 0;
static final int NORTH_EAST = 1;
static final int EAST = 2;
static final int SOUTH_EAST = 3;
static final int SOUTH = 4;
static final int SOUTH_WEST = 5;
static final int WEST = 6;
static final int NORTH_WEST = 7;
static final byte NORTH_CODE = 1;
static final byte NORTH_EAST_CODE = 2;
static final byte EAST_CODE = 4;
static final byte SOUTH_EAST_CODE = 8;
static final byte SOUTH_CODE = 16;
static final byte SOUTH_WEST_CODE = 32;
static final byte WEST_CODE = 64;
static final byte NORTH_WEST_CODE = -128;
public void saveToFile(String dir) throws IOException {
// Utworzenie katalogów, gdyby nie istniały.
File directory = new File(dir);
directory.mkdirs();
String path = dir + fileName + ".bin";
Square.RawData ss = new Square.RawData();
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(path));
for (int x = 0; x < squares.length; x++) {
for (int y = 0; y < squares[0].length; y++) {
ss.read(squares[x][y]);
ss.write(out);
}
}
out.close();
logger.debug("Zapisano nowy plik mapy: {}.", path);
public RightBigSquare() {
}
/**
@@ -61,7 +30,7 @@ public class RightBigSquare extends BigSquare {
if (newDir != null) {
fn = newDir + fileName + ".bin";
} else {
fn = MapConsts.KWADRATY_DIR + fileName + ".bin";
fn = MapConsts.DATA_DIR + fileName + ".bin";
}
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(fn));
byte[] buf = new byte[9 * 256];
@@ -83,198 +52,42 @@ public class RightBigSquare extends BigSquare {
logger.debug("Zapisano plik mapy: {}", fn);
}
/**
* Funkcja generuje nowy plik z danymi na podstawie danych z pliku referencyjnego (kwadraty o rozm. 100m).
* <p>Nowy plik moze byc z danymi w innej skali (kwadraty o rozmiarach: 100m lub 50m).
*
* @param dir katalog docelowy dla nowego pliku
* @param dlmk rozmiar kwadratow generownych danych
* @throws IOException generowany wyjątek
*/
public void saveNewFileWithNewScale20m(String dir, int dlmk) throws IOException {
if (MapConsts.SS_SIZE != 100) {
// operacja tylko dla danych terenowych o kwadratach 200m
void readFromFile(String dir) throws IOException {
if (fileName == null) {
return;
}
final int m = 5;
String s = "20m/";
StringBuilder sb = new StringBuilder(100);
sb.append(dir);
sb.append(s);
// Utworzenie katalogów, gdyby nie istniały.
File directory = new File(sb.toString());
directory.mkdirs();
sb.append(fileName);
sb.append(".bin");
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(sb.toString()));
Square.RawData[][][][] ss_all = new Square.RawData[MapConsts.SS_PER_BS_X][MapConsts.SS_PER_BS_Y][][];
try {
String fullPath = dir + fileName + ".bin";
BufferedInputStream in = new BufferedInputStream(new FileInputStream(fullPath), 2 * 8192);
byte[] buffer = new byte[9 * 512];
int offset = 0;
int count = in.read(buffer);
squares = new Square[MapConsts.SS_PER_BS_X][MapConsts.SS_PER_BS_Y];
for (int x = 0; x < MapConsts.SS_PER_BS_X; x++) {
for (int y = 0; y < MapConsts.SS_PER_BS_Y; y++) {
Square.RawData[][] ss = new Square.RawData[m][m];
for (int i = 0; i < m; i++) {
for (int j = 0; j < m; j++) {
ss[i][j] = new Square.RawData();
Square kw = new Square(x, y);
if (offset >= count) {
count = in.read(buffer);
offset = 0;
}
offset = kw.readFromBuffer(buffer, offset);
// if (kw.elevation < NMTDataReader.H_MIN) {
// logger.warn("Elevation: {}, fn= {} ", kw.elevation, fileName);
// }
// if (kw.elevation > NMTDataReader.H_MAX) {
// logger.warn("Elevation: {}, fn= {} ", kw.elevation, fileName);
// }
squares[x][y] = kw;
}
}
ss_all[x][y] = ss;
// jest odcinek drogi na tym kierunku
if (squares[x][y].jestDroga[NORTH]) {
ss[2][2].majorRoads |= NORTH_CODE;
ss[2][3].majorRoads |= NORTH_CODE | SOUTH_CODE;
ss[2][4].majorRoads |= NORTH_CODE | SOUTH_CODE;
in.close();
logger.debug("Doczytano plik mapy: " + fullPath);
} catch (IOException e) {
squares = null;
throw e;
}
if (squares[x][y].jestDroga[NORTH_EAST]) {
ss[2][2].majorRoads |= NORTH_EAST_CODE;
ss[3][3].majorRoads |= NORTH_EAST_CODE | SOUTH_WEST_CODE;
ss[4][4].majorRoads |= NORTH_EAST_CODE | SOUTH_WEST_CODE;
}
if (squares[x][y].jestDroga[EAST]) {
ss[2][2].majorRoads |= EAST_CODE;
ss[3][2].majorRoads |= EAST_CODE | WEST_CODE;
ss[4][2].majorRoads |= EAST_CODE | WEST_CODE;
}
if (squares[x][y].jestDroga[SOUTH_EAST]) {
ss[2][2].majorRoads |= SOUTH_EAST_CODE;
ss[3][1].majorRoads |= SOUTH_EAST_CODE | NORTH_WEST_CODE;
ss[4][0].majorRoads |= SOUTH_EAST_CODE | NORTH_WEST_CODE;
}
if (squares[x][y].jestDroga[SOUTH]) {
ss[2][2].majorRoads |= SOUTH_CODE;
ss[2][1].majorRoads |= SOUTH_CODE | NORTH_CODE;
ss[2][0].majorRoads |= SOUTH_CODE | NORTH_CODE;
}
if (squares[x][y].jestDroga[SOUTH_WEST]) {
ss[2][2].majorRoads |= SOUTH_WEST_CODE;
ss[1][1].majorRoads |= SOUTH_WEST_CODE | NORTH_EAST_CODE;
ss[0][0].majorRoads |= SOUTH_WEST_CODE | NORTH_EAST_CODE;
}
if (squares[x][y].jestDroga[WEST]) {
ss[2][2].majorRoads |= WEST_CODE;
ss[1][2].majorRoads |= WEST_CODE | EAST_CODE;
ss[0][2].majorRoads |= WEST_CODE | EAST_CODE;
}
if (squares[x][y].jestDroga[NORTH_WEST]) {
ss[2][2].majorRoads |= NORTH_WEST_CODE;
ss[1][3].majorRoads |= NORTH_WEST_CODE | SOUTH_EAST_CODE;
ss[0][4].majorRoads |= NORTH_WEST_CODE | SOUTH_EAST_CODE;
}
// jest odcinek rzeki na tym kierunku
if (squares[x][y].jestPrzeszkodaWodna[NORTH]) {
ss[2][2].rivers |= NORTH_CODE;
ss[2][3].rivers |= NORTH_CODE | SOUTH_CODE;
ss[2][4].rivers |= NORTH_CODE | SOUTH_CODE;
}
if (squares[x][y].jestPrzeszkodaWodna[NORTH_EAST]) {
ss[2][2].rivers |= NORTH_EAST_CODE;
ss[3][3].rivers |= NORTH_EAST_CODE | SOUTH_WEST_CODE;
ss[4][4].rivers |= NORTH_EAST_CODE | SOUTH_WEST_CODE;
}
if (squares[x][y].jestPrzeszkodaWodna[EAST]) {
ss[2][2].rivers |= EAST_CODE;
ss[3][2].rivers |= EAST_CODE | WEST_CODE;
ss[4][2].rivers |= EAST_CODE | WEST_CODE;
}
if (squares[x][y].jestPrzeszkodaWodna[SOUTH_EAST]) {
ss[2][2].rivers |= SOUTH_EAST_CODE;
ss[3][1].rivers |= SOUTH_EAST_CODE | NORTH_WEST_CODE;
ss[4][0].rivers |= SOUTH_EAST_CODE | NORTH_WEST_CODE;
}
if (squares[x][y].jestPrzeszkodaWodna[SOUTH]) {
ss[2][2].rivers |= SOUTH_CODE;
ss[2][1].rivers |= SOUTH_CODE | NORTH_CODE;
ss[2][0].rivers |= SOUTH_CODE | NORTH_CODE;
}
if (squares[x][y].jestPrzeszkodaWodna[SOUTH_WEST]) {
ss[2][2].rivers |= SOUTH_WEST_CODE;
ss[1][1].rivers |= SOUTH_WEST_CODE | NORTH_EAST_CODE;
ss[0][0].rivers |= SOUTH_WEST_CODE | NORTH_EAST_CODE;
}
if (squares[x][y].jestPrzeszkodaWodna[WEST]) {
ss[2][2].rivers |= WEST_CODE;
ss[1][2].rivers |= WEST_CODE | EAST_CODE;
ss[0][2].rivers |= WEST_CODE | EAST_CODE;
}
if (squares[x][y].jestPrzeszkodaWodna[NORTH_WEST]) {
ss[2][2].rivers |= NORTH_WEST_CODE;
ss[1][3].rivers |= NORTH_WEST_CODE | SOUTH_EAST_CODE;
ss[0][4].rivers |= NORTH_WEST_CODE | SOUTH_EAST_CODE;
}
// jest odcinek rowu na tym kierunku
if (squares[x][y].jestRow[NORTH]) {
ss[2][2].drains |= NORTH_CODE;
ss[2][3].drains |= NORTH_CODE | SOUTH_CODE;
ss[2][4].drains |= NORTH_CODE | SOUTH_CODE;
}
if (squares[x][y].jestRow[NORTH_EAST]) {
ss[2][2].drains |= NORTH_EAST_CODE;
ss[3][3].drains |= NORTH_EAST_CODE | SOUTH_WEST_CODE;
ss[4][4].drains |= NORTH_EAST_CODE | SOUTH_WEST_CODE;
}
if (squares[x][y].jestRow[EAST]) {
ss[2][2].drains |= EAST_CODE;
ss[3][2].drains |= EAST_CODE | WEST_CODE;
ss[4][2].drains |= EAST_CODE | WEST_CODE;
}
if (squares[x][y].jestRow[SOUTH_EAST]) {
ss[2][2].drains |= SOUTH_EAST_CODE;
ss[3][1].drains |= SOUTH_EAST_CODE | NORTH_WEST_CODE;
ss[4][0].drains |= SOUTH_EAST_CODE | NORTH_WEST_CODE;
}
if (squares[x][y].jestRow[SOUTH]) {
ss[2][2].drains |= SOUTH_CODE;
ss[2][1].drains |= SOUTH_CODE | NORTH_CODE;
ss[2][0].drains |= SOUTH_CODE | NORTH_CODE;
}
if (squares[x][y].jestRow[SOUTH_WEST]) {
ss[2][2].drains |= SOUTH_WEST_CODE;
ss[1][1].drains |= SOUTH_WEST_CODE | NORTH_EAST_CODE;
ss[0][0].drains |= SOUTH_WEST_CODE | NORTH_EAST_CODE;
}
if (squares[x][y].jestRow[WEST]) {
ss[2][2].drains |= WEST_CODE;
ss[1][2].drains |= WEST_CODE | EAST_CODE;
ss[0][2].drains |= WEST_CODE | EAST_CODE;
}
if (squares[x][y].jestRow[NORTH_WEST]) {
ss[2][2].drains |= NORTH_WEST_CODE;
ss[1][3].drains |= NORTH_WEST_CODE | SOUTH_EAST_CODE;
ss[0][4].drains |= NORTH_WEST_CODE | SOUTH_EAST_CODE;
}
for (int i = 0; i < m; i++) {
for (int j = 0; j < m; j++) {
int hex = 0;
if (squares[x][y].stopienZalesienia > 0) {
hex = TerrainType.FOREST.ID;
} else if (squares[x][y].stopienZawodnienia > 0) {
hex = TerrainType.WATER.ID;
} else if (squares[x][y].stopienZabudowy > 0) {
hex = TerrainType.BUILDINGS.ID;
} else if (squares[x][y].stopienZabagnienia > 0) {
hex = TerrainType.SWAMP.ID;
}
ss[i][j].terrainType = (byte) hex;
// Konwersja [m] -> [0.25m]
ss[i][j].elevation = (short) (squares[x][y].wysokoscSrednia * 4);
}
}
}
}
for (int x = 0; x < MapConsts.SS_PER_BS_X; x++) {
for (int i = 0; i < m; i++) {
for (int y = 0; y < MapConsts.SS_PER_BS_Y; y++) {
for (int j = 0; j < m; j++) {
ss_all[x][y][i][j].write(out);
}
}
}
}
out.close();
logger.debug("Zapisano nowy plik mapy: " + sb + " dla rozmiaru MK= " + dlmk);
}
/**
* Generuje nowe, wyzerowane kwadraty w danej skali w nowym formacie.
@@ -283,60 +96,7 @@ public class RightBigSquare extends BigSquare {
* @param dlmk
* @throws IOException
*/
public void saveNewFileWithNewFormatWithElevetion(String dir, int dlmk) throws IOException {
if (MapConsts.SS_SIZE != 100) {
// operacja tylko dla danych terenowych o kwadratach 200m
return;
}
int m;
String s = "";
if (dlmk == 100) {
m = 1;
s = "100m/";
} else if (dlmk == 50) {
m = 2;
s = "50m/";
} else if (dlmk == 25) {
m = 4;
s = "25m/";
} else if (dlmk == 20) {
m = 5;
s = "20m/";
} else {
return;
}
StringBuilder sb = new StringBuilder(100);
sb.append(dir);
sb.append(s);
// Utworzenie katalogów, gdyby nie istniały.
File directory = new File(sb.toString());
directory.mkdirs();
sb.append(fileName);
Square.RawData ss = new Square.RawData();
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(sb.toString()));
for (int x = 0; x < MapConsts.SS_PER_BS_X; x++) {
for (int y = 0; y < MapConsts.SS_PER_BS_Y; y++) {
// Konwersja [m] -> [0.25m]
ss.elevation = (short) (squares[x][y].wysokoscSrednia * 4);
for (int i = 0; i < m; i++) {
for (int j = 0; j < m; j++) {
ss.write(out);
}
}
}
}
out.close();
logger.debug("Zapisano nowy plik mapy: {} dla rozmiaru MK= {}", sb, dlmk);
}
/**
* Generuje nowe, wyzerowane kwadraty w danej skali w nowym formacie.
*
* @param dir
* @param dlmk
* @throws IOException
*/
public void writeToFileOldToNewFormatWithElevetion(String dir, int dlmk) throws IOException {
public void writeToFile_ElevationOnly(String dir, int dlmk) throws IOException {
if (MapConsts.SS_SIZE != 100) {
// operacja tylko dla danych terenowych o kwadratach 200m
return;
@@ -365,19 +125,18 @@ public class RightBigSquare extends BigSquare {
File directory = new File(sb.toString());
directory.mkdirs();
sb.append(fileName + ".bin");
Square.RawData ss = new Square.RawData();
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(sb.toString()));
byte[] buf = new byte[9 * 256];
int offset = 0;
for (int x = 0; x < squares.length; x++) {
for (int i = 0; i < m; i++) {
for (int y = 0; y < squares[0].length; y++) {
Square square = squares[x][y];
square.elevation = square.wysokoscSrednia;
if (square.elevation > 2660) {
if (square.elevation > NMTDataReader.H_MAX) {
logger.warn("Elevation: {}, fn= {}", square.elevation, fileName);
}
for (int i = 0; i < m * m; i++) {
offset = square.writeToBuffer(buf, offset);
for (int j = 0; j < m; j++) {
offset = square.writeToBufferElevationOnly(buf, offset);
if (offset >= buf.length) {
out.write(buf);
offset = 0;
@@ -385,6 +144,7 @@ public class RightBigSquare extends BigSquare {
}
}
}
}
if (offset > 0) {
out.write(buf, 0, offset);
}
@@ -392,7 +152,7 @@ public class RightBigSquare extends BigSquare {
logger.debug("Zapisano plik mapy: {}", fileName);
}
public void saveFileFromNewToOldFormat(String dir) throws IOException {
public void writeToFile_OldFormat(String dir) throws IOException {
StringBuilder sb = new StringBuilder(100);
sb.append(dir);
// Utworzenie katalogów, gdyby nie istniały.
@@ -402,17 +162,15 @@ public class RightBigSquare extends BigSquare {
if (fileName.indexOf('.') < 0) {
sb.append(".bin");
}
Square.RawData ss = new Square.RawData();
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(sb.toString()));
for (int x = 0; x < squares.length; x++) {
for (int y = 0; y < squares[0].length; y++) {
float f;
int hex = 0;
Square square = squares[x][y];
int hex_s = 0;
int hex_w = 0;
int hex_b = 0;
int hex_f = 0;
switch (squares[x][y].terrainType) {
switch (square.terrainType) {
// case 0, 1, 4:
// hex = 0;
// break;
@@ -434,14 +192,15 @@ public class RightBigSquare extends BigSquare {
out.writeByte(hex_w);
out.writeByte(hex_b);
out.writeByte(hex_s);
int elevation = (int) squares[x][y].elevation;
int elevation = (int) square.elevation;
out.writeInt(elevation);
out.writeInt(squares[x][y].roznicaWzniesien);
// Różnica wzniesień.
out.writeInt(0);
int bit_1;
hex = 0;
int hex = 0;
bit_1 = 1;
byte[] roads = squares[x][y].roads;
for (int i = 0; i < roads.length; i++) {
byte[] roads = square.roads;
for (int i = 0; i < 8; i++) {
// jest odcinek drogi na tym kierunku
if (roads[i] > 0) {
hex |= bit_1;
@@ -451,8 +210,8 @@ public class RightBigSquare extends BigSquare {
out.writeByte(hex);
hex = 0;
bit_1 = 1;
byte[] watercourses = squares[x][y].watercourses;
for (int i = 0; i < watercourses.length; i++) {
byte[] watercourses = square.watercourses;
for (int i = 0; i < 8; i++) {
// jest odcinek przeszkody wodnej na tym kierunku
if (watercourses[i] > 1) {
hex |= bit_1;
@@ -462,7 +221,7 @@ public class RightBigSquare extends BigSquare {
out.writeByte(hex);
hex = 0;
bit_1 = 1;
for (int i = 0; i < watercourses.length; i++) {
for (int i = 0; i < 8; i++) {
// jest odcinek rowu na tym kierunku
if (watercourses[i] == 1) {
hex |= bit_1;
@@ -476,322 +235,94 @@ public class RightBigSquare extends BigSquare {
logger.debug("Zapisano nowy plik mapy: {}", sb);
}
void readFromFileNew(String dir) throws IOException {
/**
* Konstruktor ladujacy duzy kwadrat z pliku binarnego w starym formacie.
*
* @param dir opcjonalny katalog z danymi
*
*/
void readFromFile_OldFormat(String dir) throws IOException {
if (fileName == null) {
return;
}
try {
String fullPath = dir + fileName + ".bin";
BufferedInputStream in = new BufferedInputStream(new FileInputStream(fullPath), 2 * 8192);
byte[] buffer = new byte[9 * 512];
int offset = 0;
int count = in.read(buffer);
squares = new Square[MapConsts.SS_PER_BS_X][MapConsts.SS_PER_BS_Y];
for (int x = 0; x < MapConsts.SS_PER_BS_X; x++) {
for (int y = 0; y < MapConsts.SS_PER_BS_Y; y++) {
Square kw = new Square(x, y);
if (offset >= count) {
count = in.read(buffer);
offset = 0;
}
offset = kw.readFromBuffer(buffer, offset);
if (kw.elevation < -3) {
logger.warn("Elevation: {}, fn= {} ", kw.elevation, fileName);
}
if (kw.elevation > 2660) {
logger.warn("Elevation: {}, fn= {} ", kw.elevation, fileName);
}
squares[x][y] = kw;
}
}
in.close();
logger.debug("Doczytano plik mapy: " + fullPath);
} catch (IOException e) {
squares = null;
throw e;
}
}
void readFromFile(String dir) throws IOException {
try {
String fullPath = dir + fileName + ".bin";
Square.RawData ss = new Square.RawData();
// DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(fullPath)));
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(new FileInputStream(fullPath)));
squares = new Square[MapConsts.SS_PER_BS_X][MapConsts.SS_PER_BS_Y];
for (int x = 0; x < MapConsts.SS_PER_BS_X; x++) {
for (int y = 0; y < MapConsts.SS_PER_BS_Y; y++) {
ss.read(in);
Square kw = new Square(x, y, ss);
squares[x][y] = kw;
if (kw.elevation > 2660) {
logger.warn("Elevation: {}, fn={} ", kw.elevation, fileName);
}
if (kw.elevation < -3) {
logger.warn("Elevation: {}, fn= {} ", kw.elevation, fileName);
}
}
}
in.close();
logger.debug("Doczytano plik mapy: " + fullPath);
} catch (IOException e) {
squares = null;
throw e;
}
}
/**
* Funkcja generuje nowy plik z danymi na podstawie danych z pliku referencyjnego (kwadraty o rozm. 200m).
* <p>Nowy plik moze byc z danymi w innej skali (kwadraty o rozmiarach: 100m lub 50m) i/lub innym formacie (binarny, tekstowy).
*
* @param dir katalog docelowy dla nowego pliku
* @param dlmk rozmiar kwadratow generownych danych
* @throws IOException generowany wyjątek
*/
public void saveNewFileWithNewScale_old_format(String dir, int dlmk,
boolean zalesienie, boolean zawodnienie, boolean zabudowa, boolean zabagnienie,
boolean wysokosc, boolean roznicaWzniesien, boolean drogi,
boolean rzeki, boolean rowy) throws IOException {
if (MapConsts.SS_SIZE != 200) {
// operacja tylko dla danych terenowych o kwadratach 200m
return;
}
int m = 1;
String s = "";
if (dlmk == 200) {
m = 1;
s = "200m/";
} else if (dlmk == 100) {
m = 2;
s = "100m/";
} else if (dlmk == 50) {
m = 4;
s = "50m/";
} else if (dlmk == 25) {
m = 8;
s = "25m/";
} else {
return;
}
StringBuilder sb = new StringBuilder(100);
sb.append(dir);
sb.append(s);
// Utworzenie katalogów, gdyby nie istniały.
File directory = new File(sb.toString());
directory.mkdirs();
sb.append(fileName);
sb.append(".bin");
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(sb.toString()));
for (int x = 0; x < MapConsts.SS_PER_BS_X; x++) {
for (int y = 0; y < MapConsts.SS_PER_BS_Y; y++) {
for (int k = 0; k < m * m; k++) {
float f;
int hex = 0;
if (zalesienie) {
f = squares[x][y].stopienZalesienia * 100.0f;
hex = (int) f;
hex = (hex > 100) ? 100 : hex;
hex = (hex < 0) ? 0 : hex;
}
out.writeByte(hex);
hex = 0;
if (zawodnienie) {
f = squares[x][y].stopienZawodnienia * 100.0f;
hex = (int) f;
hex = (hex > 100) ? 100 : hex;
hex = (hex < 0) ? 0 : hex;
}
out.writeByte(hex);
hex = 0;
if (zabudowa) {
f = squares[x][y].stopienZabudowy * 100.0f;
hex = (int) f;
hex = (hex > 100) ? 100 : hex;
hex = (hex < 0) ? 0 : hex;
}
out.writeByte(hex);
hex = 0;
if (zabagnienie) {
f = squares[x][y].stopienZabagnienia * 100.0f;
hex = (int) f;
hex = (hex > 100) ? 100 : hex;
hex = (hex < 0) ? 0 : hex;
}
out.writeByte(hex);
if (wysokosc) {
out.writeInt(squares[x][y].wysokoscSrednia);
} else {
out.writeInt(0);
}
if (roznicaWzniesien) {
out.writeInt(squares[x][y].roznicaWzniesien);
} else {
out.writeInt(0);
}
int bit_1;
hex = 0;
if (drogi) {
bit_1 = 1;
for (int i = 0; i < squares[x][y].jestDroga.length; i++) {
// jest odcinek drogi na tym kierunku
if (squares[x][y].jestDroga[i]) {
hex |= bit_1;
}
bit_1 <<= 1;
}
}
out.writeByte(hex);
hex = 0;
if (rzeki) {
bit_1 = 1;
for (int i = 0; i < squares[x][y].jestPrzeszkodaWodna.length; i++) {
// jest odcinek przeszkody wodnej na tym kierunku
if (squares[x][y].jestPrzeszkodaWodna[i]) {
hex |= bit_1;
}
bit_1 <<= 1;
}
}
out.writeByte(hex);
hex = 0;
if (rowy) {
bit_1 = 1;
for (int i = 0; i < squares[x][y].jestRow.length; i++) {
// jest odcinek rowu na tym kierunku
if (squares[x][y].jestRow[i]) {
hex |= bit_1;
}
bit_1 <<= 1;
}
}
out.writeByte(hex);
}
}
}
out.close();
logger.debug("Zapisano nowy plik mapy: " + sb.toString() + " dla rozmiaru MK= " + dlmk);
}
public RightBigSquare() {
}
/**
* konstruktor ladujacy duzy kwadrat z pliku binarnego w starym formacie
*
* @param fname nazwa pliku z danymi
*/
RightBigSquare(String fname, String dir) throws IOException {
try {
File f = new File(fname);
fileName = f.getName();
fileName = fileName.substring(0, fileName.lastIndexOf('.'));
StringBuilder sb = new StringBuilder(100);
if (dir == null) {
sb.append(MapConsts.KWADRATY_DIR);
sb.append(MapConsts.DATA_DIR);
} else {
sb.append(dir);
}
sb.append(fileName + ".bin");
sb.append(fileName).append(".bin");
try {
ObjectInputStream in = new ObjectInputStream(new FileInputStream(sb.toString()));
squares = new Square[MapConsts.SS_PER_BS_X][MapConsts.SS_PER_BS_Y];
for (int x = 0; x < MapConsts.SS_PER_BS_X; x++) {
for (int y = 0; y < MapConsts.SS_PER_BS_Y; y++) {
Square kw = new Square(x, y);
squares[x][y] = kw;
kw.terrainType = (short) TerrainType.BARE_GROUND.ID;
int hex = in.readByte();
kw.stopienZalesienia = (float) hex * (1.0f / 100.f);
hex = in.readByte();
kw.stopienZawodnienia = (float) hex * (1.0f / 100.f);
hex = in.readByte();
kw.stopienZabudowy = (float) hex * (1.0f / 100.f);
hex = in.readByte();
kw.stopienZabagnienia = (float) hex * (1.0f / 100.f);
kw.wysokoscSrednia = in.readInt();
if (kw.wysokoscSrednia < -3) {
logger.warn("Elevation: {}, fn= {} ", kw.wysokoscSrednia, fileName);
if (hex > 30) {
kw.terrainType = (short) TerrainType.FOREST.ID;
}
if (kw.wysokoscSrednia > 2660) {
logger.warn("Elevation: {}, fn= {} ", kw.wysokoscSrednia, fileName);
hex = in.readByte();
if (hex > 30) {
kw.terrainType = (short) TerrainType.WATER.ID;
}
hex = in.readByte();
if (hex > 30) {
kw.terrainType = (short) TerrainType.BUILDINGS.ID;
}
hex = in.readByte();
if (hex > 30) {
kw.terrainType = (short) TerrainType.SWAMP.ID;
}
kw.elevation = in.readInt();
if (kw.elevation < NMTDataReader.H_MIN) {
logger.warn("Elevation: {}, fn= {}", kw.elevation, fileName);
}
if (kw.elevation > NMTDataReader.H_MAX) {
logger.warn("Elevation: {}, fn= {}", kw.elevation, fileName);
}
kw.roznicaWzniesien = in.readInt();
int bit_1 = 1;
hex = in.readByte();
if (kw.jestDroga == null) {
kw.jestDroga = new boolean[8];
}
for (int i = 0; i < kw.jestDroga.length; i++) {
for (int i = 0; i < 8; i++) {
// jest odcinek rowu na tym kierunku
if ((hex & bit_1) != 0) {
kw.jestDroga[i] = true;
kw.roads[i] = 2;
}
bit_1 <<= 1;
}
bit_1 = 1;
hex = in.readByte();
if (kw.jestPrzeszkodaWodna == null) {
kw.jestPrzeszkodaWodna = new boolean[8];
}
for (int i = 0; i < kw.jestPrzeszkodaWodna.length; i++) {
// jest odcinek rowu na tym kierunku
for (int i = 0; i < 8; i++) {
// jest odcinek rzeki na tym kierunku
if ((hex & bit_1) != 0) {
kw.jestPrzeszkodaWodna[i] = true;
kw.watercourses[i] = 3;
}
bit_1 <<= 1;
}
bit_1 = 1;
hex = in.readByte();
if (kw.jestRow == null) {
kw.jestRow = new boolean[8];
}
for (int i = 0; i < kw.jestRow.length; i++) {
for (int i = 0; i < 8; i++) {
// jest odcinek rowu na tym kierunku
if ((hex & bit_1) != 0) {
kw.jestRow[i] = true;
kw.watercourses[i] = 1;
}
bit_1 <<= 1;
}
}
}
in.close();
logger.debug("Doczytano plik mapy: " + sb.toString());
logger.debug("Doczytano plik mapy: {}", sb);
} catch (IOException e) {
squares = null;
throw e;
}
}
void resetSquares(boolean zalesienie, boolean zawodnienie, boolean zabudowa, boolean zabagnienie,
boolean wysokosc, boolean roznicaWzniesien, boolean drogi, boolean rzeki, boolean rowy) {
for (int x = 0; x < MapConsts.SS_PER_BS_X; x++) {
for (int y = 0; y < MapConsts.SS_PER_BS_Y; y++) {
squares[x][y].stopienZalesienia = (zalesienie) ? 0 : squares[x][y].stopienZalesienia;
squares[x][y].stopienZawodnienia = (zawodnienie) ? 0 : squares[x][y].stopienZawodnienia;
squares[x][y].stopienZabudowy = (zabudowa) ? 0 : squares[x][y].stopienZabudowy;
squares[x][y].stopienZabagnienia = (zabagnienie) ? 0 : squares[x][y].stopienZabagnienia;
squares[x][y].wysokoscSrednia = (wysokosc) ? 0 : squares[x][y].wysokoscSrednia;
squares[x][y].roznicaWzniesien = (roznicaWzniesien) ? 0 : squares[x][y].roznicaWzniesien;
if (drogi) {
for (int i = 0; i < squares[x][y].jestDroga.length; i++) {
squares[x][y].jestDroga[i] = false;
}
}
if (rzeki) {
for (int i = 0; i < squares[x][y].jestPrzeszkodaWodna.length; i++) {
squares[x][y].jestPrzeszkodaWodna[i] = false;
}
}
if (rowy) {
for (int i = 0; i < squares[x][y].jestRow.length; i++) {
squares[x][y].jestRow[i] = false;
}
}
}
}
}
@Override
public String toString() {
return "RightBigSquare{" + this.fileName + '}';
return "RightBigSquare{" + fileName + '}';
}
}

View File

@@ -1,10 +1,7 @@
package pl.wat.ms4ds.terrain;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import pl.wat.ms4ds.terrain.nmt.NMTDataReader;
public class Square {
@@ -49,170 +46,6 @@ public class Square {
public int roznicaWzniesien;
public int wysokoscSrednia;
/// /////////////////////////////////////
public static class RawData {
/**
* The height above the level of the sea. Unit of measure [0.25m].
*/
short elevation;
/**
* Terrain type. <p></p>Possible values:
* 0 - BARE_GROUND
* 1 - GRASS
* 2 - SWAMP
* 3 - WATER
* 4 - SCRUB, BUSHES
* 5 - BUILDINGS
* 6 - FOREST
*/
byte terrainType;
/**
* Small road in a given direction. Each bit corresponds to a given direction.
*/
byte smallRoads;
/**
* Minor road in a given direction. Each bit corresponds to a given direction.
*/
byte minorRoads;
/**
* Major road in a given direction. Each bit corresponds to a given direction.
*/
byte majorRoads;
/**
* The existence of a drain in a given direction. Each bit corresponds to a given direction.
*/
byte drains;
/**
* The existence of a stream in a given direction. Each bit corresponds to a given direction.
*/
byte streams;
/**
* The existence of a river in a given direction. Each bit corresponds to a given direction.
*/
byte rivers;
public void reset() {
elevation = 0;
terrainType = 0;
smallRoads = 0;
minorRoads = 0;
majorRoads = 0;
drains = 0;
streams = 0;
rivers = 0;
}
public void write(ObjectOutputStream out) throws IOException {
out.writeShort(elevation);
out.writeByte(terrainType);
out.writeByte(smallRoads);
out.writeByte(minorRoads);
out.writeByte(majorRoads);
out.writeByte(drains);
out.writeByte(streams);
out.writeByte(rivers);
}
public void read(ObjectInputStream in) throws IOException {
elevation = in.readShort();
terrainType = in.readByte();
smallRoads = in.readByte();
minorRoads = in.readByte();
majorRoads = in.readByte();
drains = in.readByte();
streams = in.readByte();
rivers = in.readByte();
}
public RawData(short elevation, byte terrainType) {
this.elevation = elevation;
this.terrainType = terrainType;
}
public RawData() {
}
public RawData(Square kw) {
terrainType = (byte) kw.terrainType;
// Konwersja na decymetry.
elevation = (short) (kw.elevation * 4);
byte bit = 1;
for (int i = 0; i < kw.watercourses.length; i++) {
switch (kw.watercourses[i]) {
case 1:
drains |= bit;
break;
case 2:
streams |= bit;
break;
case 3:
rivers |= bit;
break;
default:
break;
}
switch (kw.roads[i]) {
case 1:
smallRoads |= bit;
break;
case 2:
minorRoads |= bit;
break;
case 3:
majorRoads |= bit;
break;
default:
break;
}
bit <<= 1;
}
}
public void read(Square kw) {
terrainType = (byte) kw.terrainType;
// Konwersja na decymetry.
elevation = (short) (kw.elevation * 4);
byte bit = 1;
for (int i = 0; i < kw.watercourses.length; i++) {
switch (kw.watercourses[i]) {
case 1:
drains |= bit;
break;
case 2:
streams |= bit;
break;
case 3:
rivers |= bit;
break;
default:
break;
}
switch (kw.roads[i]) {
case 1:
smallRoads |= bit;
break;
case 2:
minorRoads |= bit;
break;
case 3:
majorRoads |= bit;
break;
default:
break;
}
bit <<= 1;
}
}
}
public static final Square EMPTY = new Square(-1, -1);
public Square() {
@@ -226,28 +59,49 @@ public class Square {
watercourses = new byte[8];
}
public Square(int x, int y, RawData rawData) {
public Square(int x, int y, short elevation, byte terrainType, byte majorRoads, byte minorRoads, byte smallRoads, byte rivers, byte streams, byte drains) {
this.x = x;
this.y = y;
roads = new byte[8];
watercourses = new byte[8];
// Konwersja na metry a[0.25m] -> b[m]
elevation = (float) (rawData.elevation) / 4;
terrainType = rawData.terrainType;
this.elevation = (float) (elevation) / 4;
this.terrainType = terrainType;
int bit = 1;
for (int i = 0; i < 8; i++) {
int b1 = ((rawData.majorRoads & bit) > 0) ? 3 : 0;
int b2 = ((rawData.minorRoads & bit) > 0) ? 2 : 0;
int b3 = ((rawData.smallRoads & bit) > 0) ? 1 : 0;
int b1 = ((majorRoads & bit) > 0) ? 3 : 0;
int b2 = ((minorRoads & bit) > 0) ? 2 : 0;
int b3 = ((smallRoads & bit) > 0) ? 1 : 0;
roads[i] = (byte) (b1 + b2 + b3);
b1 = ((rawData.rivers & bit) > 0) ? 3 : 0;
b2 = ((rawData.streams & bit) > 0) ? 2 : 0;
b3 = ((rawData.drains & bit) > 0) ? 1 : 0;
b1 = ((rivers & bit) > 0) ? 3 : 0;
b2 = ((streams & bit) > 0) ? 2 : 0;
b3 = ((drains & bit) > 0) ? 1 : 0;
watercourses[i] = (byte) (b1 + b2 + b3);
bit <<= 1;
}
}
public int writeToBufferElevationOnly(byte[] buffer, int offset) {
// Konwersja [m] -> [0.25m].
int elev = (short) (elevation * 4);
byte b1 = (byte) (elev & 0xFF);
elev >>= 8;
byte b0 = (byte) (elev & 0xFF);
if (b0 == -1 && b1 == -4) {
System.out.println("a");
}
buffer[offset] = b0;
buffer[offset + 1] = b1;
buffer[offset + 2] = 0;
buffer[offset + 3] = 0;
buffer[offset + 4] = 0;
buffer[offset + 5] = 0;
buffer[offset + 6] = 0;
buffer[offset + 7] = 0;
buffer[offset + 8] = 0;
return offset + 9;
}
public int writeToBuffer(byte[] buffer, int offset) {
// Konwersja [m] -> [0.25m].
int elev = (short) (elevation * 4);
@@ -307,11 +161,16 @@ public class Square {
public int readFromBuffer(byte[] buffer, int offset) {
int elev = buffer[offset] & 0xFF;
elev = (elev << 8) + (buffer[offset + 1] & 0xFF);
// elev = (elev << 8) + (buffer[offset + 1] & 0xFF);
elev = (elev << 8) | (buffer[offset + 1] & 0xFF);
// Rzutowanie "elev" na short zachowuje znak liczby.
short v = (short) elev;
// Konwersja na metry a[0.25m] -> b[m]
elevation = (float) (v) / 4;
if (elevation > 2660) {
// Konwersja na metry a[0.25m] -> b[m]
// elevation = (float) ((short) elev) / 4;
if (elevation > NMTDataReader.H_MAX) {
System.out.println("h=" + elevation);
}
terrainType = buffer[offset + 2];
@@ -337,28 +196,9 @@ public class Square {
return offset + 9;
}
void read(RawData rawData) {
// Konwersja na metry a[0.25m] -> b[m]
elevation = (float) (rawData.elevation) / 4;
terrainType = rawData.terrainType;
int bit = 1;
for (int i = 0; i < 8; i++) {
int b1 = ((rawData.majorRoads & bit) > 0) ? 3 : 0;
int b2 = ((rawData.minorRoads & bit) > 0) ? 2 : 0;
int b3 = ((rawData.smallRoads & bit) > 0) ? 1 : 0;
roads[i] = (byte) (b1 + b2 + b3);
b1 = ((rawData.rivers & bit) > 0) ? 3 : 0;
b2 = ((rawData.streams & bit) > 0) ? 2 : 0;
b3 = ((rawData.drains & bit) > 0) ? 1 : 0;
watercourses[i] = (byte) (b1 + b2 + b3);
bit <<= 1;
}
}
public final int x;
public final int y;
@Override
public final boolean equals(Object o) {
if (!(o instanceof Square SQUARE)) return false;
@@ -374,6 +214,7 @@ public class Square {
return result;
}
@Override
public String toString() {
StringBuilder linia = new StringBuilder(100);
linia.append("[");

View File

@@ -1,6 +1,7 @@
package pl.wat.ms4ds.terrain;
import java.io.*;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.locks.ReentrantLock;
@@ -88,14 +89,14 @@ public class Teren {
}
private static String getFileName(int bsX, int bsY) {
int x_stop = MapConsts.X_REF + bsX / MapConsts.BS_PER_DEG_X - 180;
int x_stop = MapConsts.LON_REF + bsX / MapConsts.BS_PER_DEG_X - 180;
char cLon = (x_stop < 0) ? 'W' : 'E';
if (x_stop < 0) {
x_stop = -x_stop;
}
int dx = bsX % MapConsts.BS_PER_DEG_X;
char cx = LITERALS.charAt(dx);
int y_stop = MapConsts.Y_REF + bsY / MapConsts.BS_PER_DEG_Y - 90;
int y_stop = MapConsts.LAT_REF + bsY / MapConsts.BS_PER_DEG_Y - 90;
char cLat = (y_stop < 0) ? 'S' : 'N';
if (y_stop < 0) {
y_stop = -y_stop;
@@ -123,12 +124,15 @@ public class Teren {
return sb.toString();
}
private static BigSquare loadAreaOld(int bsX, int bsY) {
String fName = getFileName(bsX, bsY) + ".bin";
private static BigSquare loadAreaOldFormat(int bsX, int bsY) {
String fName = getFileName(bsX, bsY);
try {
return new RightBigSquare(fName, null);
RightBigSquare bs = new RightBigSquare();
bs.fileName = fName;
bs.readFromFile_OldFormat(MapConsts.DATA_DIR);
return bs;
} catch (IOException e) {
LOGGER.warn("Brak pliku mapy: {}{}{}", MapConsts.KWADRATY_DIR, fName, ".bin");
LOGGER.warn("Brak pliku mapy: {}{}{}", MapConsts.DATA_DIR, fName, ".bin");
return EmptyBigSquare.EMPTY_BIG_SQUARE;
}
}
@@ -138,10 +142,10 @@ public class Teren {
try {
RightBigSquare bs = new RightBigSquare();
bs.fileName = fName;
bs.readFromFile(MapConsts.KWADRATY_DIR);
bs.readFromFile(MapConsts.DATA_DIR);
return bs;
} catch (IOException e) {
LOGGER.warn("Brak pliku mapy: {}{}{}", MapConsts.KWADRATY_DIR, fName, ".bin");
LOGGER.warn("Brak pliku mapy: {}{}{}", MapConsts.DATA_DIR, fName, ".bin");
return EmptyBigSquare.EMPTY_BIG_SQUARE;
}
}
@@ -151,13 +155,13 @@ public class Teren {
public static Square getKwadratPUWG(double northing, double easting) {
Coord.Geo geoCoord = new Coord.Geo();
Coord.convertPUWG1992ToWGS84(northing, easting, geoCoord);
return getKwadrat(geoCoord.lat, geoCoord.lon);
return getSquare(geoCoord.lat, geoCoord.lon);
}
public static Square getKwadrat(double lat, double lon) {
public static Square getSquare(double lat, double lon) {
int idX = Coord.zamienDlugoscGeoNaIdKwadratuX(lon);
int idY = Coord.zamienSzerokoscGeoNaIdKwadratuY(lat);
return getKwadrat(idX, idY);
return getSquare(idX, idY);
}
/**
@@ -167,7 +171,7 @@ public class Teren {
* @param y współrzędna pionowa (indeks wiersza)
* @return obiekt reprezentujący charakterystyki fragmentu terenu
*/
public static Square getKwadrat(int x, int y) {
public static Square getSquare(int x, int y) {
if (x < 0 || y < 0) {
return EMPTY;
}
@@ -175,7 +179,7 @@ public class Teren {
int bsX = x / MapConsts.SS_PER_BS_X;
// wspolrzędna y dużego kwadratu
int bsY = y / MapConsts.SS_PER_BS_Y;
if (bsX < 0 || bsX >= BIG_X_MAX || bsY < 0 || bsY >= BIG_Y_MAX) {
if (bsX >= BIG_X_MAX || bsY >= BIG_Y_MAX) {
return EMPTY;
}
// wspolrzędna x małego kwadratu w ramach dużego kwadratu
@@ -188,7 +192,7 @@ public class Teren {
bigSquares[bsX][bsY] = loadArea(bsX, bsY);
}
}
return bigSquares[bsX][bsY].getKwadrat(ssX, ssY);
return bigSquares[bsX][bsY].getSquare(ssX, ssY);
}
private static Coord.Grid[] history = new Coord.Grid[MapConsts.MAX_BIG_SQUARES_IN_MEMORY];
@@ -395,22 +399,26 @@ public class Teren {
// Teren.normalizujDanePokrycia();
String newDir = "D:/work/kwadraty_nmt/temp/25/";
String dir1 = "D:/work/nowe/25m/";
String dir1 = "D:/work/terrain/";
String inDir = "D:/work/kwadraty_nmt/withElevation/25m/";
String dir2 = "C:/Workspace/_data/swdt/ms4ds/teren/kwadraty/100m/";
Set<String> fileNames = NMTDataProvider.listFiles(dir2);
Set<String> fileNames2 = new HashSet<>();
fileNames2.add(dir2 + "E014C_N53D.bin");
Teren.generateDataFromOldFormat(fileNames, dir1, 25);
// Square kw = getKwadrat(1500, 2100);
// System.out.println(kw);
// kw = getKwadrat(2100, 1500);
// System.out.println(kw);
Set<String> fileNames = NMTDataProvider.listFiles(dir1);
// String fn = "E017B_N54E";
// RightBigSquare rbs = new RightBigSquare(dir2 + fn + ".bin", null);
// rbs.writeToFileOldToNewFormatWithElevetion(dir1, 25);
RightBigSquare rbs = new RightBigSquare();
rbs.fileName = "E017B_N54E";
rbs.readFromFileNew(dir1);
// RightBigSquare rbs = new RightBigSquare();
// rbs.fileName = "E017B_N54E";
// rbs.readFromFile(dir1);
// Teren.generateData(fileNames, dir1, newDir);
// Teren.generateDataOldToNewFormat(fileNames, dir2, dir1, 25);
@@ -431,129 +439,20 @@ public class Teren {
}
public static void wyzerujDane() {
// WYGENEROWANIE CZYSTYCH PLIKÓW DANYCH
for (int x = 0; x < bigSquares.length; x++) {
for (int y = 0; y < bigSquares[x].length; y++) {
try {
BigSquare bs = loadArea(x, y);
if (bs != null && bs instanceof RightBigSquare) {
RightBigSquare rbs = (RightBigSquare) bs;
// wyzerowanie wszystkiego poza wysokością i różnicą wzniesień
rbs.resetSquares(true, true, true, true, true, true, true, true, true);
rbs.liczbaZmian = 1;
rbs.writeToFile(null);
}
} catch (IOException e) {
// e.printStackTrace();
}
}
}
}
/**
* Funkcja uzupełnia brakujące dane wysokosciowe jako średnia kwadratów sąsiednich o niezerowych wysokosciach.
* Funkcja powinna być wywoływana dla danych zawierających informacje o wodach morskich.
*/
public static void poprawDaneWysokosciowe() {
int maxX = MapConsts.SS_PER_BS_X * MapConsts.BS_PER_DEG_X * MapConsts.DX_REF;
int maxY = MapConsts.SS_PER_BS_Y * MapConsts.BS_PER_DEG_Y * MapConsts.DY_REF;
for (int x = 0; x < maxX; x++) {
for (int y = 0; y < maxY; y++) {
Square kw = getKwadrat(x, y);
if (kw == EMPTY) {
continue;
}
if (kw.stopienZawodnienia == 0 && kw.wysokoscSrednia == 0) {
// operacja dla kwadratów lądowych
int licz = 0;
int suma = 0;
for (int i = -1; i < 1; i++) {
for (int j = -1; j < 1; j++) {
if (i == 0 && j == 0) {
// pomijam dane bieżącego kwadratu
continue;
}
int xx = x + i;
int yy = y + j;
Square kwSasiad = getKwadrat(xx, yy);
if (kwSasiad == EMPTY) {
// pomijam kwadraty poza mapą
continue;
}
if (kwSasiad.wysokoscSrednia > 0) {
// uśredniam tylko po kwadratach o niezerowej wysokości
suma += kwSasiad.wysokoscSrednia;
licz++;
}
}
}
float wys = (float) suma / (float) licz;
kw.wysokoscSrednia = (int) wys;
}
}
}
for (int x = 0; x < bigSquares.length; x++) {
for (int y = 0; y < bigSquares[x].length; y++) {
try {
BigSquare bs = bigSquares[x][y];
if (bs instanceof RightBigSquare rbs) {
rbs.liczbaZmian = 1;
rbs.writeToFile(null);
}
} catch (IOException e) {
// e.printStackTrace();
}
}
}
}
/**
* Funkcja poprawia dane o pokryciu, aby dane sumowały się do jedynki.
*/
static void normalizujDanePokrycia() {
int maxX = MapConsts.SS_PER_BS_X * MapConsts.BS_PER_DEG_X * MapConsts.DX_REF;
int maxY = MapConsts.SS_PER_BS_Y * MapConsts.BS_PER_DEG_Y * MapConsts.DY_REF;
for (int x = 0; x < maxX; x++) {
for (int y = 0; y < maxY; y++) {
Square kw = getKwadrat(x, y);
if (kw == EMPTY) {
continue;
}
float suma = kw.stopienZalesienia + kw.stopienZawodnienia + kw.stopienZabudowy + kw.stopienZabagnienia;
if (suma > 1.0f) {
kw.stopienZalesienia /= suma;
kw.stopienZawodnienia /= suma;
kw.stopienZabudowy /= suma;
kw.stopienZabagnienia = 1.0f - kw.stopienZalesienia - kw.stopienZawodnienia - kw.stopienZabudowy;
}
}
}
for (int x = 0; x < bigSquares.length; x++) {
for (int y = 0; y < bigSquares[x].length; y++) {
try {
BigSquare bs = bigSquares[x][y];
if (bs instanceof RightBigSquare rbs) {
rbs.liczbaZmian = 1;
rbs.writeToFile(null);
}
} catch (IOException e) {
// e.printStackTrace();
}
}
}
}
/**
* Generuje pliki z danymi w nowym formacie na podstawie danych w satrym formacie.
*
* @param outDir katalog z danymi terenowymi np. "d:/Workspace2/kwadraty/czyste-wysokosc/"
* @param dlmk docelowy rozmiar generowanych kwadratów terenu
*/
public static void generateDataOldToNewFormat(Set<String> fileNames, String inDir, String outDir, int dlmk) throws IOException {
public static void generateDataFromOldFormat(Set<String> fileNames, String outDir, int dlmk) throws IOException {
for (String fileName : fileNames) {
RightBigSquare rbs = new RightBigSquare(fileName, null);
rbs.writeToFileOldToNewFormatWithElevetion(outDir, dlmk);
File file = new File(fileName);
String fn = file.getName();
RightBigSquare rbs = new RightBigSquare();
rbs.fileName = fn.substring(0, fn.length() - 4);
rbs.readFromFile_OldFormat(null);
rbs.writeToFile_ElevationOnly(outDir, dlmk);
}
}
@@ -563,14 +462,14 @@ public class Teren {
*
* @param outDir katalog z danymi terenowymi np. "d:/Workspace2/kwadraty/czyste-wysokosc/"
*/
public static void generateData(Set<String> fileNames, String inDir, String outDir) throws IOException {
public static void generateDataToOldFormat(Set<String> fileNames, String inDir, String outDir) throws IOException {
for (String fileName : fileNames) {
File file = new File(fileName);
String fn = file.getName().substring(0, file.getName().lastIndexOf('.'));
RightBigSquare rbs = new RightBigSquare();
rbs.fileName = fn;
rbs.readFromFileNew(inDir);
// rbs.writeToFile(outDir);
rbs.readFromFile(inDir);
rbs.writeToFile_OldFormat(outDir);
}
}

View File

@@ -22,8 +22,8 @@ public class TerrainUtils {
if ((x1 == x2) && (y1 == y2)) {
return 1.0f;
}
Square kwDo = Teren.getKwadrat(x1, y1);
Square kwOd = Teren.getKwadrat(x2, y2);
Square kwDo = Teren.getSquare(x1, y1);
Square kwOd = Teren.getSquare(x2, y2);
if (kwDo == Square.EMPTY || kwOd == Square.EMPTY) {
return 0.0f;
}
@@ -52,7 +52,7 @@ public class TerrainUtils {
// badanie wewnetrznych kwadratow nalezacych do odcinka,
// czy nie sa powyzej linii widocznosci dla kwadratow skrajnych
float wysokoscPrzeszkody = 0.0f;
Square kwAkt = Teren.getKwadrat(kwadratyNaOdcinku[i].x, kwadratyNaOdcinku[i].y);
Square kwAkt = Teren.getSquare(kwadratyNaOdcinku[i].x, kwadratyNaOdcinku[i].y);
if (kwAkt.stopienZalesienia > 0.5f) {
wysokoscPrzeszkody = 10.0f;
}
@@ -82,7 +82,7 @@ public class TerrainUtils {
}
public static float widocznoscOptyczna(int x, int y) {
Square kw = Teren.getKwadrat(x, y);
Square kw = Teren.getSquare(x, y);
if (kw.stopienZabudowy > 0.25f || kw.stopienZalesienia > 0.25f) {
return 0.3f;
}

View File

@@ -43,9 +43,6 @@ public class CoordUtils {
logger.debug("Koniec zapisu danych dla regionu " + nmt_fn + " >> " + i + "/" + (args.length - 1));
Teren.reset();
}
logger.debug("Start: poprawy danych wysokosciowych");
Teren.poprawDaneWysokosciowe();
logger.debug("Koniec: poprawy danych wysokosciowych");
}

View File

@@ -88,15 +88,15 @@ public class EsriFileReader {
nodeId++;
currNode.lon = points[j].getX() + 180;
currNode.lat = points[j].getY() + 90;
if (currNode.lon >= MapConsts.X_REF && currNode.lon <= MapConsts.X_REF + MapConsts.DX_REF
&& currNode.lat >= MapConsts.Y_REF && currNode.lat <= MapConsts.Y_REF + MapConsts.DY_REF) {
if (currNode.lon >= MapConsts.LON_REF && currNode.lon <= MapConsts.LON_REF + MapConsts.DELTA_LON_REF
&& currNode.lat >= MapConsts.LAT_REF && currNode.lat <= MapConsts.LAT_REF + MapConsts.DELTA_LAT_REF) {
jest_wezel_z_obszaru = true;
}
currNode.lon = Math.max(currNode.lon, MapConsts.X_REF);
currNode.lon = Math.min(currNode.lon, MapConsts.X_REF + MapConsts.DX_REF);
currNode.lon = Math.max(currNode.lon, MapConsts.LON_REF);
currNode.lon = Math.min(currNode.lon, MapConsts.LON_REF + MapConsts.DELTA_LON_REF);
currNode.lon -= 180;
currNode.lat = Math.max(currNode.lat, MapConsts.Y_REF);
currNode.lat = Math.min(currNode.lat, MapConsts.Y_REF + MapConsts.DY_REF);
currNode.lat = Math.max(currNode.lat, MapConsts.LAT_REF);
currNode.lat = Math.min(currNode.lat, MapConsts.LAT_REF + MapConsts.DELTA_LAT_REF);
currNode.lat -= 90;
currNode.idX = Coord.zamienDlugoscGeoNaIdKwadratuX(currNode.lon);

View File

@@ -69,10 +69,10 @@ public class Node {
public void writeAreaFeatureIntoSquare(EAreaFeature type) {
if (buildingsCount >= BUILDINGS_COUNT) {
Square kw = Teren.getKwadrat(idX, idY);
Square kw = Teren.getSquare(idX, idY);
kw.stopienZabudowy = 1.0f;
} else if (buildingsCount > 0) {
Square kw = Teren.getKwadrat(idX, idY);
Square kw = Teren.getSquare(idX, idY);
kw.stopienZabudowy = 0.5f;
}
}

View File

@@ -258,9 +258,9 @@ public class Way {
for (int i = 0; i < kwadraty.length - 1; i++) {
try {
id0 = kwadraty[i];
kw0 = Teren.getKwadrat(id0.x, id0.y);
kw0 = Teren.getSquare(id0.x, id0.y);
id1 = kwadraty[i + 1];
kw1 = Teren.getKwadrat(id1.x, id1.y);
kw1 = Teren.getSquare(id1.x, id1.y);
kier = GeomUtils.kierunekDlaSasiada(id0, id1);
switch (type) {
case ROAD:
@@ -353,7 +353,7 @@ public class Way {
for (int i = minX; i <= maxX; i++) {
idTest.x = i;
idTest.y = j;
Square kw = Teren.getKwadrat(idTest.x, idTest.y);
Square kw = Teren.getSquare(idTest.x, idTest.y);
if (kw == Square.EMPTY) {
continue;
}
@@ -388,7 +388,7 @@ public class Way {
for (int j = minY; j <= maxY; j++) {
idTest.x = i;
idTest.y = j;
Square kw = Teren.getKwadrat(idTest.x, idTest.y);
Square kw = Teren.getSquare(idTest.x, idTest.y);
if (kw == Square.EMPTY) {
continue;
}
@@ -421,7 +421,7 @@ public class Way {
Square kw;
float val = (clearFeature) ? 0.0f : 1.0f;
if (nodes.size() == 1) {
kw = Teren.getKwadrat(nodes.get(0).idX, nodes.get(0).idY);
kw = Teren.getSquare(nodes.get(0).idX, nodes.get(0).idY);
switch (type) {
case FOREST:
kw.stopienZalesienia = val;
@@ -443,7 +443,7 @@ public class Way {
Coord.Grid[] kwadraty = GeomUtils.kwadratyOdcinka(nodes.get(0).idX, nodes.get(0).idY,
nodes.get(1).idX, nodes.get(1).idY);
for (int i = 0; i < kwadraty.length; i++) {
kw = Teren.getKwadrat(kwadraty[i].x, kwadraty[i].y);
kw = Teren.getSquare(kwadraty[i].x, kwadraty[i].y);
switch (type) {
case FOREST:
kw.stopienZalesienia = val;
@@ -476,7 +476,7 @@ public class Way {
Square kw;
float val = (clearFeature) ? 0.0f : 1.0f;
if (nodes.size() == 1) {
kw = Teren.getKwadrat(nodes.get(0).idX, nodes.get(0).idY);
kw = Teren.getSquare(nodes.get(0).idX, nodes.get(0).idY);
switch (type) {
case FOREST:
kw.stopienZalesienia = val;
@@ -498,7 +498,7 @@ public class Way {
Coord.Grid[] kwadraty = GeomUtils.kwadratyOdcinka(nodes.get(0).idX, nodes.get(0).idY,
nodes.get(1).idX, nodes.get(1).idY);
for (int i = 0; i < kwadraty.length; i++) {
kw = Teren.getKwadrat(kwadraty[i].x, kwadraty[i].y);
kw = Teren.getSquare(kwadraty[i].x, kwadraty[i].y);
switch (type) {
case FOREST:
kw.stopienZalesienia = val;
@@ -555,7 +555,7 @@ public class Way {
idTest.y = j;
// char c = ' ';
// liczKw++;
kw = Teren.getKwadrat(idTest.x, idTest.y);
kw = Teren.getSquare(idTest.x, idTest.y);
if (kw == Square.EMPTY) {
continue;
}

View File

@@ -110,7 +110,7 @@ public class NMTDataReader {
}
for (Coord.Grid gridCoord : nmtDataHashMap.keySet()) {
NMTData nmtData = nmtDataHashMap.get(gridCoord);
Square square = Teren.getKwadrat(gridCoord.x, gridCoord.y);
Square square = Teren.getSquare(gridCoord.x, gridCoord.y);
if (square == Square.EMPTY) {
continue;
}
@@ -196,7 +196,7 @@ public class NMTDataReader {
logger.debug("File processed: {}, duration= {}[ms], status: {}/{}", fn, System.currentTimeMillis() - start, i, endPos - 1);
for (Coord.Grid gridCoord : nmtDataHashMap.keySet()) {
NMTData nmtData = nmtDataHashMap.get(gridCoord);
Square square = Teren.getKwadrat(gridCoord.x, gridCoord.y);
Square square = Teren.getSquare(gridCoord.x, gridCoord.y);
if (square == Square.EMPTY) {
continue;
}
@@ -314,8 +314,8 @@ public class NMTDataReader {
}
}
static final int H_MIN = -70;
static final int H_MAX = 2660;
public static final int H_MIN = 0;
public static final int H_MAX = 2660;
private static void readASC(BufferedReader br, String firstLine, HashMap<Coord.Grid, NMTData> nmtDataHashMap) throws IOException {
String line = firstLine;
@@ -393,11 +393,11 @@ public class NMTDataReader {
geoCoord.lon = Coord.zamienIdKwadratuXNaDlugoscGeo(x);
geoCoord.lat = Coord.zamienIdKwadratuYNaSzerokoscGeo(y);
// Wyznacz współrzędne PUWG lewego dolnego rogu kwadratu.
Coord.convertWGS84ToPUWG1992(geoCoord.lat - MapConsts.DELTA_Y / 2, geoCoord.lon - MapConsts.DELTA_X / 2, puwgCoord);
Coord.convertWGS84ToPUWG1992(geoCoord.lat - MapConsts.SS_DELTA_LAT / 2, geoCoord.lon - MapConsts.SS_DELTA_LON / 2, puwgCoord);
nmtData.ell = (int) puwgCoord.easting;
nmtData.nll = (int) puwgCoord.northing;
// Wyznacz współrzędne PUWG prawego górnego rogu kwadratu.
Coord.convertWGS84ToPUWG1992(geoCoord.lat + MapConsts.DELTA_Y / 2, geoCoord.lon + MapConsts.DELTA_X / 2, puwgCoord);
Coord.convertWGS84ToPUWG1992(geoCoord.lat + MapConsts.SS_DELTA_LAT / 2, geoCoord.lon + MapConsts.SS_DELTA_LON / 2, puwgCoord);
nmtData.eur = (int) puwgCoord.easting;
nmtData.nur = (int) puwgCoord.northing;
}
@@ -477,11 +477,11 @@ public class NMTDataReader {
geo.lon = Coord.zamienIdKwadratuXNaDlugoscGeo(x);
geo.lat = Coord.zamienIdKwadratuYNaSzerokoscGeo(y);
// Wyznacz współrzędne PUWG lewego dolnego rogu kwadratu.
Coord.convertWGS84ToPUWG1992(geo.lat - MapConsts.DELTA_Y / 2, geo.lon - MapConsts.DELTA_X / 2, puwgCoord);
Coord.convertWGS84ToPUWG1992(geo.lat - MapConsts.SS_DELTA_LAT / 2, geo.lon - MapConsts.SS_DELTA_LON / 2, puwgCoord);
nmtData.ell = (int) puwgCoord.easting;
nmtData.nll = (int) puwgCoord.northing;
// Wyznacz współrzędne PUWG prawego górnego rogu kwadratu.
Coord.convertWGS84ToPUWG1992(geo.lat + MapConsts.DELTA_Y / 2, geo.lon + MapConsts.DELTA_X / 2, puwgCoord);
Coord.convertWGS84ToPUWG1992(geo.lat + MapConsts.SS_DELTA_LAT / 2, geo.lon + MapConsts.SS_DELTA_LON / 2, puwgCoord);
nmtData.eur = (int) puwgCoord.easting;
nmtData.nur = (int) puwgCoord.northing;
}