Wersja poprawna generowania danych nmt w wersji współbieżnej.
This commit is contained in:
@@ -68,6 +68,10 @@ public class Coord {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Klasa reprezentująca współrzędne/położenie w siatce kwadratów terenu.
|
||||
*
|
||||
*/
|
||||
public static class Grid {
|
||||
|
||||
/**
|
||||
@@ -103,8 +107,8 @@ public class Coord {
|
||||
'}';
|
||||
}
|
||||
|
||||
private static final double ODWROT_SS_DX_MS = 1.0 / MapConsts.SS_DX_MS;
|
||||
private static final double ODWROT_SS_DY_MS = 1.0 / MapConsts.SS_DY_MS;
|
||||
private static final double ODWROT_SS_DX_MS = 1.0 / MapConsts.SS_DELTA_LON_MS;
|
||||
private static final double ODWROT_SS_DY_MS = 1.0 / MapConsts.SS_DELTA_LAT_MS;
|
||||
|
||||
public static double distance(Grid a, Grid b) {
|
||||
int dx = a.x - b.x;
|
||||
@@ -213,7 +217,7 @@ public class Coord {
|
||||
* @param idX współrzęna x GridCoord
|
||||
* @return długość geograficzna
|
||||
*/
|
||||
public static float zamienIdKwadratuXNaDlugoscGeo(int idX) {
|
||||
public static float convertGridXToLon(int idX) {
|
||||
long xms = zamienIdKwadratuXNaWspXms(idX);
|
||||
double lon = (double) xms / (double) MapConsts.DEG_MS - 180;
|
||||
return (float) lon;
|
||||
@@ -225,7 +229,7 @@ public class Coord {
|
||||
* @param idY współrzęna y GridCoord
|
||||
* @return szerokość geograficzna
|
||||
*/
|
||||
public static float zamienIdKwadratuYNaSzerokoscGeo(int idY) {
|
||||
public static float covertGridYToLat(int idY) {
|
||||
long yms = zamienIdKwadratuYNaWspYms(idY);
|
||||
double lat = (double) yms / (double) MapConsts.DEG_MS - 90;
|
||||
return (float) lat;
|
||||
@@ -238,7 +242,7 @@ public class Coord {
|
||||
public static long zamienIdKwadratuXNaWspXms(int idKwX) {
|
||||
// indeksowanie kwadratow pola walki zaczyna sie od (0, 0)
|
||||
// przesuniecie wspolrzednych do srodka kwadratu
|
||||
long xms = MapConsts.X_REF_MS + (long) ((idKwX + 0.5) * MapConsts.SS_DX_MS);
|
||||
long xms = MapConsts.X_REF_MS + (long) ((idKwX + 0.5) * MapConsts.SS_DELTA_LON_MS);
|
||||
xms %= MapConsts.ANGLE_360_MS;
|
||||
return xms;
|
||||
}
|
||||
@@ -250,32 +254,60 @@ public class Coord {
|
||||
public static long zamienIdKwadratuYNaWspYms(int idKwY) {
|
||||
// indeksowanie kwadratow pola walki zaczyna sie od (0, 0)
|
||||
// przesuniecie wspolrzednych do srodka kwadratu
|
||||
long yms = MapConsts.Y_REF_MS + (long) ((idKwY + 0.5) * MapConsts.SS_DY_MS);
|
||||
long yms = MapConsts.Y_REF_MS + (long) ((idKwY + 0.5) * MapConsts.SS_DELTA_LAT_MS);
|
||||
return yms;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zamienia długość geograficzną na współrzędna x GridCoord.
|
||||
* Zamienia długość geograficzną na współrzędna x Coord.Grid.
|
||||
*
|
||||
* @param lon długość geograficzna
|
||||
* @return współrzędna x klasy GridCoord
|
||||
*/
|
||||
public static int zamienDlugoscGeoNaIdKwadratuX(double lon) {
|
||||
public static int convertLonTOGridX(double lon) {
|
||||
double xms_f = (lon + 180) * MapConsts.DEG_MS;
|
||||
return zamienWspXmsNaIdKwadratuX((long) xms_f);
|
||||
}
|
||||
|
||||
/**
|
||||
* Zamienia szerokość geograficzną na współrzędna y GridCoord.
|
||||
* Zamienia szerokość geograficzną na współrzędna y Coord.Grid.
|
||||
*
|
||||
* @param lat szerokość geograficzna
|
||||
* @return współrzędna y klasy GridCoord
|
||||
*/
|
||||
public static int zamienSzerokoscGeoNaIdKwadratuY(double lat) {
|
||||
public static int convertLatToGridY(double lat) {
|
||||
double yms_f = (lat + 90) * MapConsts.DEG_MS;
|
||||
return zamienWspYmsNaIdKwadratuY((long) yms_f);
|
||||
}
|
||||
|
||||
public static final double INVERT_SS_DELTA_LON = 1 / MapConsts.SS_DELTA_LON;
|
||||
public static final double INVERT_SS_DELTA_LAT = 1 / MapConsts.SS_DELTA_LAT;
|
||||
|
||||
private static final double REF_LON_OFFSET = 180 - MapConsts.REF_LON;
|
||||
private static final double REF_LAT_OFFSET = 90 - MapConsts.REF_LAT;
|
||||
|
||||
/**
|
||||
* Zamienia długość geograficzną w systemie WGS-84 na współrzędna x klasy {@link Grid}.
|
||||
*
|
||||
* @param lon długość geograficzna
|
||||
* @return współrzędna x klasy GridCoord
|
||||
*/
|
||||
public static int convertLonToGridX2(double lon) {
|
||||
double xx = (lon + REF_LON_OFFSET) * INVERT_SS_DELTA_LON;
|
||||
return (int) xx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zamienia szerokość geograficzną w systemie WGS-84 na współrzędna y klasy {@link Grid}.
|
||||
*
|
||||
* @param lat szerokość geograficzna
|
||||
* @return współrzędna y klasy GridCoord
|
||||
*/
|
||||
public static int convertLatToGridY2(double lat) {
|
||||
double yy = (lat + REF_LAT_OFFSET) * INVERT_SS_DELTA_LAT;
|
||||
return (int) yy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Funkcja zamienia dlugosc geog. xms w milisekundach na IdKwadrat.x.
|
||||
*
|
||||
@@ -286,7 +318,7 @@ public class Coord {
|
||||
// wspolrzedne geograficzne w milisekundach zawieraja sie w zakresie:
|
||||
// 0 <= x < 360 dlugosc geograficzna
|
||||
// 0 <= y <= 180 szerokosc geograficzna
|
||||
if ((xms < 0) || (xms >= 360 * MapConsts.DEG_MS)) {
|
||||
if (xms >= MapConsts.ANGLE_360_MS) {
|
||||
// poza zakresem
|
||||
return -1;
|
||||
}
|
||||
@@ -304,7 +336,7 @@ public class Coord {
|
||||
// return -1;
|
||||
// }
|
||||
// indeksowanie kwadratow pola walki zaczyna sie od (0, 0)
|
||||
double xx = (x - MapConsts.X_REF_MS) * ODWROT_SS_DX_MS;
|
||||
double xx = (x - MapConsts.X_REF_MS) * INVERT_SS_DELTA_LON_MS;
|
||||
// x = (x - MapConsts.X_REF_MS) / MapConsts.SS_DX_MS;
|
||||
return (int) xx;
|
||||
}
|
||||
@@ -324,13 +356,13 @@ public class Coord {
|
||||
return -1;
|
||||
}
|
||||
// indeksowanie kwadratow pola walki zaczyna sie od (0, 0)
|
||||
double yy = (yms - MapConsts.Y_REF_MS) * ODWROT_SS_DY_MS;
|
||||
double yy = (yms - MapConsts.Y_REF_MS) * INVERT_SS_DELTA_LAT_MS;
|
||||
// long y = (yms - MapConsts.Y_REF_MS) / MapConsts.SS_DY_MS;
|
||||
return (int) yy;
|
||||
}
|
||||
|
||||
private static final double ODWROT_SS_DX_MS = 1.0 / MapConsts.SS_DX_MS;
|
||||
private static final double ODWROT_SS_DY_MS = 1.0 / MapConsts.SS_DY_MS;
|
||||
private static final double INVERT_SS_DELTA_LON_MS = 1.0 / MapConsts.SS_DELTA_LON_MS;
|
||||
private static final double INVERT_SS_DELTA_LAT_MS = 1.0 / MapConsts.SS_DELTA_LAT_MS;
|
||||
|
||||
/**
|
||||
* Funkcja służy do konwersji współrzednych elipsoidalnych WGS84 (lat/lon) na płaskie X-northing, Y-easting
|
||||
|
||||
@@ -15,12 +15,12 @@ public final class MapConsts {
|
||||
* 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 LON_REF;
|
||||
public static final int REF_LON;
|
||||
/**
|
||||
* 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 LAT_REF;
|
||||
public static final int REF_LAT;
|
||||
|
||||
public static final int DELTA_LON_REF;
|
||||
public static final int DELTA_LAT_REF;
|
||||
@@ -99,11 +99,11 @@ 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)
|
||||
LON_REF = Integer.parseInt(properties.getProperty("x_ref")) + 180;
|
||||
REF_LON = Integer.parseInt(properties.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>
|
||||
LAT_REF = Integer.parseInt(properties.getProperty("y_ref")) + 90;
|
||||
REF_LAT = Integer.parseInt(properties.getProperty("y_ref")) + 90;
|
||||
DELTA_LON_REF = Integer.parseInt(properties.getProperty("dx_ref"));
|
||||
DELTA_LAT_REF = Integer.parseInt(properties.getProperty("dy_ref"));
|
||||
double BS_X_NUM = DELTA_LON_REF / BS_PER_DEG_X;
|
||||
@@ -163,13 +163,13 @@ public final class MapConsts {
|
||||
BS_DELTA_LAT = 1.0 / (double) BS_PER_DEG_Y;
|
||||
SS_LONS = new double[DELTA_LON_REF * BS_PER_DEG_X * SS_PER_BS_X];
|
||||
for (int i = 0; i < SS_LONS.length; i++) {
|
||||
SS_LONS[i] = LON_REF + SS_DELTA_LON * (i + 0.5);
|
||||
SS_LONS[i] = REF_LON + SS_DELTA_LON * (i + 0.5);
|
||||
}
|
||||
SS_LATS = new double[DELTA_LAT_REF * BS_PER_DEG_Y * SS_PER_BS_Y];
|
||||
for (int i = 0; i < SS_LATS.length; i++) {
|
||||
SS_LATS[i] = LAT_REF + SS_DELTA_LAT * (i + 0.5);
|
||||
SS_LATS[i] = REF_LAT + 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={}", LON_REF, LAT_REF, DELTA_LON_REF, DELTA_LAT_REF, SS_SIZE, SS_LONS.length, SS_LATS.length, DATA_DIR);
|
||||
LOGGER.debug("Wczytane ustawienia:\n \tLON_REF={}, LAT_REF={}, DX_REF={}, DY_REF{}, SQUARE_SIZE={}, GRID_SIZE={}x{}, DATA_DIR={}", REF_LON, REF_LAT, DELTA_LON_REF, DELTA_LAT_REF, SS_SIZE, SS_LONS.length, SS_LATS.length, DATA_DIR);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -179,7 +179,7 @@ public final class MapConsts {
|
||||
/**
|
||||
* Liczba milisekund na 360 stopni.
|
||||
*/
|
||||
public static final long ANGLE_360_MS = 3600000 * 360;
|
||||
public static final long ANGLE_360_MS = DEG_MS * 360;
|
||||
/**
|
||||
* Wielkosc cache'u pola walki (liczba duzych kwadratow trzymanych w RAM).
|
||||
*/
|
||||
@@ -191,7 +191,7 @@ public final class MapConsts {
|
||||
* @return
|
||||
*/
|
||||
public static int getX_REF() {
|
||||
return LON_REF;
|
||||
return REF_LON;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -200,7 +200,7 @@ public final class MapConsts {
|
||||
* @return
|
||||
*/
|
||||
public static int getY_REF() {
|
||||
return LAT_REF;
|
||||
return REF_LAT;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -224,17 +224,17 @@ public final class MapConsts {
|
||||
/**
|
||||
* Dlugosci bokow malego kwadratu w milisekundach geograficznych po osi OX (dlugosc geograficzna).
|
||||
*/
|
||||
public static final double SS_DX_MS = SS_DELTA_LON * DEG_MS;
|
||||
public static final double SS_DELTA_LON_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 = SS_DELTA_LAT * DEG_MS;
|
||||
public static final double SS_DELTA_LAT_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 = LON_REF * DEG_MS;
|
||||
public static final int Y_REF_MS = LAT_REF * DEG_MS;
|
||||
public static final int X_REF_MS = REF_LON * DEG_MS;
|
||||
public static final int Y_REF_MS = REF_LAT * 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
|
||||
|
||||
|
||||
@@ -81,22 +81,22 @@ public class Teren {
|
||||
* @return Nazwa zwracanego pliku z danymi (null - gdy niepoprawne współrzędne).
|
||||
*/
|
||||
public static String getFileName(double lat, double lon) {
|
||||
int idX = Coord.zamienDlugoscGeoNaIdKwadratuX(lon);
|
||||
int idY = Coord.zamienSzerokoscGeoNaIdKwadratuY(lat);
|
||||
int idX = Coord.convertLonTOGridX(lon);
|
||||
int idY = Coord.convertLatToGridY(lat);
|
||||
int bigX = idX / MapConsts.SS_PER_BS_X;
|
||||
int bigY = idY / MapConsts.SS_PER_BS_Y;
|
||||
return getFileName(bigX, bigY);
|
||||
}
|
||||
|
||||
private static String getFileName(int bsX, int bsY) {
|
||||
int x_stop = MapConsts.LON_REF + bsX / MapConsts.BS_PER_DEG_X - 180;
|
||||
int x_stop = MapConsts.REF_LON + 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.LAT_REF + bsY / MapConsts.BS_PER_DEG_Y - 90;
|
||||
int y_stop = MapConsts.REF_LAT + bsY / MapConsts.BS_PER_DEG_Y - 90;
|
||||
char cLat = (y_stop < 0) ? 'S' : 'N';
|
||||
if (y_stop < 0) {
|
||||
y_stop = -y_stop;
|
||||
@@ -159,8 +159,8 @@ public class Teren {
|
||||
}
|
||||
|
||||
public static Square getSquare(double lat, double lon) {
|
||||
int idX = Coord.zamienDlugoscGeoNaIdKwadratuX(lon);
|
||||
int idY = Coord.zamienSzerokoscGeoNaIdKwadratuY(lat);
|
||||
int idX = Coord.convertLonTOGridX(lon);
|
||||
int idY = Coord.convertLatToGridY(lat);
|
||||
return getSquare(idX, idY);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,9 +6,7 @@ import pl.wat.ms4ds.terrain.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
@@ -18,15 +16,29 @@ public class NMTDataReader {
|
||||
|
||||
static void main(String[] args) {
|
||||
|
||||
String[] splitted = "b a, e, l.d u, n g".split("\\s+|,\\s*|\\.\\s*");
|
||||
// File dir = new File(System.getProperty("user.home") + "/nmt/gugik_SkorowidzNMT2018.gml");
|
||||
// Dzieli na podstringi biorąc jako znak podziału spację i jej wielokrotność
|
||||
String[] splitted2 = "b a e l.d u n g".split("[ ]+");
|
||||
/*
|
||||
* Generowanie danych terenowych odbywa się na podstawie plików z danymi NMT w dwóch formatach:
|
||||
* ASC (siatka/tabela wysokość) TXT (współrzędne geo, wysokość). Pliki są spakowane.
|
||||
* Pliki znajdują się w lokalizacji określonej przez "inDir" w katalogach (odpowiadających skorowidzom).
|
||||
* W katalogu "idDir" znajdują się pliki textowe z listą nazw plików w podkatalogach skorowidzowych.
|
||||
* Dane wysokościowe z plików NMT przetwarzane są współbieżnie przez executora.
|
||||
* W ramach tego etapu/wątku:
|
||||
* 1. pliki są rozpakowywane do katalogu roboczego "workDir",
|
||||
* 2. po czym następuje ich odczyt i zapamiętanie danych szczegółowych w obiektach
|
||||
* NMTData (suma wysokości, licznik, granice kwadratu terenu we współrzędnych PUWG1992),
|
||||
* 3. obiekty NMTData (odpowiadające kwadratom terenu) są cachowane w hashmapie
|
||||
* indywidualnie w ramach wątku executora.
|
||||
* 4. po zakończeniu odczytu plik jest usuwany,
|
||||
* 5. następnie dane zagregowane (średnie wysokości) są zapisywane do kwadratów terenu
|
||||
* (zapis w kwadratach jest synchronizowany).
|
||||
*
|
||||
* Wątki są synchronizowane po tym etapie w celu zrzucenia zaktualizowanych danych na dysk.
|
||||
*
|
||||
*/
|
||||
|
||||
// String fn_list = "D:/work/nmt/m-33_files.txt";
|
||||
String inDir = "D:/work/nmt/";
|
||||
String workDir = "D:/work/temp/";
|
||||
String outDir = "D:/work/kwadraty_nmt/withElevation/25m/";
|
||||
String outDir = "D:/work/kwadraty_nmt/withElevation/50m/";
|
||||
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
list.add("m-33");
|
||||
@@ -36,65 +48,14 @@ public class NMTDataReader {
|
||||
list.add("n-34");
|
||||
ExecutorService executor = Executors.newVirtualThreadPerTaskExecutor();
|
||||
|
||||
Thread t = new Thread(() -> {
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
String fn_list = inDir + list.get(i) + "_files.txt";
|
||||
generateNMTData(executor, fn_list, 0, 24000, inDir + list.get(i) + "/", workDir, outDir);
|
||||
}
|
||||
});
|
||||
// HashMap<Coord.Grid, NMTData> nmtDataHashMap = new HashMap<>();
|
||||
// try {
|
||||
// readFromFile(workDir + "73232_990195_NMT-M3492Ad33.xyz", nmtDataHashMap);
|
||||
// } catch (IOException e) {
|
||||
// return;
|
||||
// }
|
||||
// generateNMTData(workDir, workDir, outDir);
|
||||
t.start();
|
||||
// t2.start();
|
||||
|
||||
Scanner s = new Scanner(System.in);
|
||||
// exit
|
||||
//
|
||||
String s1;
|
||||
while (true) {
|
||||
s1 = s.nextLine();
|
||||
if (s1.equals("exit")) {
|
||||
stop();
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
System.out.println("Czekam");
|
||||
t.join();
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
|
||||
System.out.println("End.");
|
||||
|
||||
// renameFiles2(inDir, inDir);
|
||||
|
||||
// Set<String> files = NMTDataProvider.listFiles(inDir);
|
||||
// Object[] array = files.stream().sorted().toArray();
|
||||
// String[] fnames = new String[files.size()];
|
||||
// for (int i = 0; i < fnames.length; i++) {
|
||||
// fnames[i] = (String) array[i];
|
||||
// }
|
||||
// try {
|
||||
// saveFileList("D:/work/nmt/asc_n-34_files.txt", fnames);
|
||||
// } catch (IOException e) {
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
static volatile boolean stop = false;
|
||||
|
||||
static synchronized boolean isStopped() {
|
||||
return stop;
|
||||
}
|
||||
|
||||
static synchronized void stop() {
|
||||
stop = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,29 +125,34 @@ public class NMTDataReader {
|
||||
} catch (IOException e) {
|
||||
return;
|
||||
}
|
||||
HashMap<Coord.Grid, NMTData> nmtDataHashMap = new HashMap<>();
|
||||
int count = 0;
|
||||
for (int i = startPos; i < endPos; i++) {
|
||||
count++;
|
||||
long start = System.currentTimeMillis();
|
||||
int i = startPos;
|
||||
ArrayList<Future> futures = new ArrayList<>();
|
||||
while (i < endPos) {
|
||||
if (i >= fileNames.size()) {
|
||||
break;
|
||||
}
|
||||
String fn = fileNames.get(i);
|
||||
int j;
|
||||
for (j = 0; j < 8; j++) {
|
||||
if (i >= fileNames.size()) {
|
||||
break;
|
||||
}
|
||||
// asynchroniczne wywołanie zadania
|
||||
int ii = i;
|
||||
i++;
|
||||
Future future = executor.submit(() -> {
|
||||
long start = System.currentTimeMillis();
|
||||
String fn = fileNames.get(ii);
|
||||
File f = null;
|
||||
String[] unzippedFileNames = null;
|
||||
try {
|
||||
unzippedFileNames = unzipFile(inDir + fn, workDir);
|
||||
} catch (IOException e) {
|
||||
logger.warn("IO error while processing zip file: {}", inDir + fn);
|
||||
try (BufferedWriter writer = new BufferedWriter(new FileWriter("D:/Work/nmt/status.txt", true))) {
|
||||
writer.write("Error while processing zip file: " + fileNames.get(i) + " at position: " + i + "\n");
|
||||
} catch (IOException e1) {
|
||||
logger.debug(e1.getMessage());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.warn(e.getMessage());
|
||||
}
|
||||
HashMap<Coord.Grid, NMTData> nmtDataHashMap = new HashMap<>();
|
||||
for (String ufn : unzippedFileNames) {
|
||||
String fpath = workDir + ufn;
|
||||
try {
|
||||
@@ -198,25 +164,20 @@ public class NMTDataReader {
|
||||
readFromFile(fpath, nmtDataHashMap);
|
||||
} catch (Exception e) {
|
||||
logger.warn("Error while reading from file: {}.", ufn);
|
||||
try (BufferedWriter writer = new BufferedWriter(new FileWriter("D:/Work/nmt/status.txt", true))) {
|
||||
writer.write("Error while reading file: " + ufn + " at position: " + i + "\n");
|
||||
} catch (IOException e1) {
|
||||
logger.debug(e1.getMessage());
|
||||
}
|
||||
} finally {
|
||||
if (f != null) {
|
||||
f.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
if (nmtData.count > 0) {
|
||||
Square square = Teren.getSquare(gridCoord.x, gridCoord.y);
|
||||
if (square == Square.EMPTY) {
|
||||
continue;
|
||||
}
|
||||
if (nmtData.count > 0) {
|
||||
synchronized (square) {
|
||||
square.elevation = (float) (nmtData.sum / nmtData.count);
|
||||
// Zaokrąglenie do ćwiartki metra (0.0, 0.25, 0.5, 0.75)
|
||||
//
|
||||
@@ -228,29 +189,25 @@ public class NMTDataReader {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
nmtDataHashMap.clear();
|
||||
logger.debug("File processed: {}, duration= {}[ms], status: {}/{}", fn, System.currentTimeMillis() - start, ii, endPos - 1);
|
||||
});
|
||||
futures.add(future);
|
||||
}
|
||||
count += j;
|
||||
// Punkt synchronizacyjny.
|
||||
for (Future future : futures) {
|
||||
try {
|
||||
future.get();
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
}
|
||||
}
|
||||
if (count % 2000 == 0) {
|
||||
Teren.saveToFiles(outDir);
|
||||
}
|
||||
// Reakcja na wymuszenie zakończenia przetwarzania.
|
||||
if (isStopped()) {
|
||||
Teren.saveToFiles(outDir);
|
||||
try (BufferedWriter writer = new BufferedWriter(new FileWriter("D:/Work/nmt/status.txt", true))) {
|
||||
writer.write("Work interrupted with the file list: " + fn_list + ", last processed file: " + fileNames.get(i) + " at position: " + i + "\n");
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage());
|
||||
}
|
||||
logger.info("Interrupted processing file list: {}", fn_list);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Teren.saveToFiles(outDir);
|
||||
try (BufferedWriter writer = new BufferedWriter(new FileWriter("D:/Work/nmt/status.txt", true))) {
|
||||
int last = Math.min(fileNames.size() - 1, endPos);
|
||||
writer.write("Work finished with the file list: " + fn_list + ", last processed file: " + fileNames.get(last) + " at position: " + last + "\n");
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage());
|
||||
}
|
||||
logger.info("Finished processing file list: {}", fn_list);
|
||||
}
|
||||
|
||||
@@ -330,7 +287,7 @@ public class NMTDataReader {
|
||||
}
|
||||
}
|
||||
|
||||
public static final int H_MIN = 0;
|
||||
public static final int H_MIN = -70;
|
||||
public static final int H_MAX = 2660;
|
||||
|
||||
private static void readASC(BufferedReader br, String firstLine, HashMap<Coord.Grid, NMTData> nmtDataHashMap) throws IOException {
|
||||
@@ -398,16 +355,16 @@ public class NMTDataReader {
|
||||
if (nmtData.ell > x_puwg || nmtData.eur < x_puwg || nmtData.nll > y_puwg || nmtData.nur < y_puwg) {
|
||||
// Punkt poza granicą bieżącego kwadratu.
|
||||
Coord.convertPUWG1992ToWGS84(y_puwg, x_puwg, geoCoord);
|
||||
x = Coord.zamienDlugoscGeoNaIdKwadratuX(geoCoord.lon);
|
||||
y = Coord.zamienSzerokoscGeoNaIdKwadratuY(geoCoord.lat);
|
||||
x = Coord.convertLonTOGridX(geoCoord.lon);
|
||||
y = Coord.convertLatToGridY(geoCoord.lat);
|
||||
final int x1 = x;
|
||||
final int y1 = y;
|
||||
nmtData = nmtDataHashMap.computeIfAbsent(new Coord.Grid(x, y), k -> new NMTData(x1, y1, 0, 0));
|
||||
if (nmtData.nur == 0) {
|
||||
// Kwadrat jeszcze nie był odczytany (czysty).
|
||||
// Współrzędne geo środka kwadratu.
|
||||
geoCoord.lon = Coord.zamienIdKwadratuXNaDlugoscGeo(x);
|
||||
geoCoord.lat = Coord.zamienIdKwadratuYNaSzerokoscGeo(y);
|
||||
geoCoord.lon = Coord.convertGridXToLon(x);
|
||||
geoCoord.lat = Coord.covertGridYToLat(y);
|
||||
// Wyznacz współrzędne PUWG lewego dolnego rogu kwadratu.
|
||||
Coord.convertWGS84ToPUWG1992(geoCoord.lat - MapConsts.SS_DELTA_LAT / 2, geoCoord.lon - MapConsts.SS_DELTA_LON / 2, puwgCoord);
|
||||
nmtData.ell = (int) puwgCoord.easting;
|
||||
@@ -418,13 +375,8 @@ public class NMTDataReader {
|
||||
nmtData.nur = (int) puwgCoord.northing;
|
||||
}
|
||||
}
|
||||
if (H_MIN < h && h < H_MAX) {
|
||||
// Filtracja danych z rozsądnego zakresu dla Polski.
|
||||
nmtData.sum += h;
|
||||
nmtData.count++;
|
||||
} else {
|
||||
logger.trace("!!!Dane poza zakresem: h= {}, [i,j]=[{},{}]", h, i, j);
|
||||
}
|
||||
// Przejdź do następnej kolumny.
|
||||
x_puwg += cellsize;
|
||||
}
|
||||
@@ -482,16 +434,16 @@ public class NMTDataReader {
|
||||
if (nmtData.ell > x_puwg || nmtData.eur < x_puwg || nmtData.nll > y_puwg || nmtData.nur < y_puwg) {
|
||||
// Punkt poza granicą bieżącego kwadratu.
|
||||
Coord.convertPUWG1992ToWGS84(y_puwg, x_puwg, geo);
|
||||
x = Coord.zamienDlugoscGeoNaIdKwadratuX(geo.lon);
|
||||
y = Coord.zamienSzerokoscGeoNaIdKwadratuY(geo.lat);
|
||||
x = Coord.convertLonTOGridX(geo.lon);
|
||||
y = Coord.convertLatToGridY(geo.lat);
|
||||
final int x1 = x;
|
||||
final int y1 = y;
|
||||
nmtData = nmtDataHashMap.computeIfAbsent(new Coord.Grid(x1, y1), k -> new NMTData(x1, y1, 0, 0));
|
||||
if (nmtData.nur == 0) {
|
||||
// Kwadrat jeszcze nie był odczytany (czysty).
|
||||
// Współrzędne geo środka kwadratu.
|
||||
geo.lon = Coord.zamienIdKwadratuXNaDlugoscGeo(x);
|
||||
geo.lat = Coord.zamienIdKwadratuYNaSzerokoscGeo(y);
|
||||
geo.lon = Coord.convertGridXToLon(x);
|
||||
geo.lat = Coord.covertGridYToLat(y);
|
||||
// Wyznacz współrzędne PUWG lewego dolnego rogu kwadratu.
|
||||
Coord.convertWGS84ToPUWG1992(geo.lat - MapConsts.SS_DELTA_LAT / 2, geo.lon - MapConsts.SS_DELTA_LON / 2, puwgCoord);
|
||||
nmtData.ell = (int) puwgCoord.easting;
|
||||
@@ -502,13 +454,8 @@ public class NMTDataReader {
|
||||
nmtData.nur = (int) puwgCoord.northing;
|
||||
}
|
||||
}
|
||||
if (H_MIN < h && h < H_MAX) {
|
||||
// Filtracja danych z rozsądnego zakresu dla Polski.
|
||||
nmtData.sum += h;
|
||||
nmtData.count++;
|
||||
} else {
|
||||
logger.trace("!!!Dane poza zakresem: h= {}, row={}", h, row);
|
||||
}
|
||||
line = br.readLine();
|
||||
row++;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ kwadraty_dir=D:/work/kwadraty_nmt/withElevation/
|
||||
drogi_dir=au2data/new_teren/Polska/drogi/
|
||||
#
|
||||
#Rozdzielczosc terenu dl_mk=200 | 100 | 50 | 25 | 20
|
||||
dl_mk=25
|
||||
dl_mk=50
|
||||
#
|
||||
#W celu wymuszenia (mimo jej braku) przejezdności terenu nalezy ustawić na: on
|
||||
przejezdnosc_zawsze=off
|
||||
|
||||
Reference in New Issue
Block a user