Działa konwersja nmt dla asc i xyz.
This commit is contained in:
2
.idea/compiler.xml
generated
2
.idea/compiler.xml
generated
@@ -6,7 +6,7 @@
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="teren-funkcje" />
|
||||
<module name="terrain-utilities" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<logger name="pl.wat.ms4ds.terenfunkcje" level="trace">
|
||||
<logger name="pl.wat.ms4ds.terrain" level="trace">
|
||||
<appender-ref ref="FILE"/>
|
||||
</logger>
|
||||
|
||||
|
||||
4
pom.xml
4
pom.xml
@@ -5,7 +5,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>ms4ds</groupId>
|
||||
<artifactId>teren-funkcje</artifactId>
|
||||
<artifactId>teren-utils</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<repositories>
|
||||
@@ -96,7 +96,7 @@
|
||||
<archive>
|
||||
<manifest>
|
||||
<addClasspath>true</addClasspath>
|
||||
<mainClass>pl.wat.ms4ds.terenfunkcje.nmt.NMTDataProvider</mainClass>
|
||||
<mainClass>pl.wat.ms4ds.terrain.nmt.NMTDataProvider</mainClass>
|
||||
</manifest>
|
||||
<manifestEntries>
|
||||
<Class-Path>teren-funkcje-1.0.2-SNAPSHOT.jar</Class-Path>
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
package pl.wat.ms4ds.terenfunkcje.konwersja;
|
||||
|
||||
/**
|
||||
* Współrzędne punktu odwzorowania kartograficznego PUWG 1992.
|
||||
* <p>
|
||||
* Wartośći współrzędnych [metry].
|
||||
*
|
||||
*/
|
||||
public class PUWGCoord {
|
||||
/**
|
||||
* Współrzędna X (oś odcietych) odwzorowania kartograficznego [metry].
|
||||
*/
|
||||
public double easting;
|
||||
/**
|
||||
* Współrzędna Y (oś rzędnych) odwzorowania kartograficznego [metry].
|
||||
*/
|
||||
public double northing;
|
||||
|
||||
public PUWGCoord() {
|
||||
this.easting = 0;
|
||||
this.northing = 0;
|
||||
}
|
||||
|
||||
public PUWGCoord(double easting, double northing) {
|
||||
this.easting = easting;
|
||||
this.northing = northing;
|
||||
}
|
||||
}
|
||||
@@ -1,305 +0,0 @@
|
||||
package pl.wat.ms4ds.terenfunkcje.nmt;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import pl.wat.ms4ds.terenfunkcje.*;
|
||||
import pl.wat.ms4ds.terenfunkcje.konwersja.CoordUtils;
|
||||
import pl.wat.ms4ds.terenfunkcje.konwersja.PUWGCoord;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.file.FileSystemException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
public class NMTDataReader {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(NMTDataReader.class);
|
||||
|
||||
|
||||
static void main(String[] args) {
|
||||
// File dir = new File(System.getProperty("user.home") + "/nmt/gugik_SkorowidzNMT2018.gml");
|
||||
|
||||
HashMap<Coord.Grid, NMTData> nmtDataHashMap = new HashMap<>();
|
||||
|
||||
String inDir = "C:/Workspace/nmt/gugik_1m/asc/";
|
||||
String outDir = "C:/Workspace/nmt/unzipped/";
|
||||
// String testFn = "D:\\Work\\73771_1025306_NMT-M348Dc41.xyz\\";
|
||||
String testFn = "D:\\Work\\M-33-7-A-c-3-2.asc";
|
||||
|
||||
try {
|
||||
readFromFileASC(testFn, nmtDataHashMap);
|
||||
// readFromFileXYZ(testFn, nmtDataHashMap);
|
||||
} catch (IOException e) {
|
||||
return;
|
||||
}
|
||||
// renameFiles(inDir, inDir);
|
||||
|
||||
|
||||
Set<String> files = NMTDataProvider.listFiles(inDir);
|
||||
for (String file : files) {
|
||||
try {
|
||||
String unzipfn = unzipFile(inDir + file, outDir);
|
||||
if (unzipfn.endsWith(".asc")) {
|
||||
readFromFileASC(outDir + unzipfn, nmtDataHashMap);
|
||||
} else if (unzipfn.endsWith(".xyz")) {
|
||||
readFromFileXYZ(outDir + unzipfn, nmtDataHashMap);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void renameFiles(String inDir, String outDir) {
|
||||
try {
|
||||
Set<String> fileNames = NMTDataProvider.listFiles(inDir);
|
||||
for (String fn : fileNames) {
|
||||
String fn1 = fn.substring(0, fn.lastIndexOf("-") + 1);
|
||||
String fn2 = fn.substring(fn.lastIndexOf("-") + 1, fn.indexOf("."));
|
||||
String ext = fn.substring(fn.indexOf("."));
|
||||
int pos;
|
||||
if (fn2.length() == 5) {
|
||||
pos = 1;
|
||||
} else if (fn2.length() == 6) {
|
||||
pos = 2;
|
||||
} else {
|
||||
//if (fn2.length() == 7)
|
||||
pos = 3;
|
||||
}
|
||||
String fn3 = fn2.substring(0, pos);
|
||||
String fn4 = fn2.substring(pos, pos + 1);
|
||||
String fn5 = fn2.substring(pos + 1, pos + 2);
|
||||
String fn6 = fn2.substring(pos + 2, pos + 3);
|
||||
String fn7 = fn2.substring(pos + 3, pos + 4);
|
||||
String nfn = fn1 + fn3 + '-' + fn4 + '-' + fn5 + '-' + fn6 + '-' + fn7;
|
||||
File fileToMove = new File(inDir + fn);
|
||||
boolean isMoved = fileToMove.renameTo(new File(outDir + nfn + ext));
|
||||
if (!isMoved) {
|
||||
throw new FileSystemException(outDir + fileToMove);
|
||||
}
|
||||
System.out.println(nfn);
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static void readFromFileASC(String fn, HashMap<Coord.Grid, NMTData> nmtDataHashMap) throws IOException {
|
||||
long start = System.currentTimeMillis();
|
||||
File file = new File(fn);
|
||||
InputStream inputStream = new FileInputStream(file);
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(inputStream))) {
|
||||
String line = br.readLine();
|
||||
String[] split = line.split(" ");
|
||||
int ncols = Integer.parseInt(split[1]);
|
||||
line = br.readLine();
|
||||
split = line.split(" ");
|
||||
int nrows = Integer.parseInt(split[1]);
|
||||
line = br.readLine();
|
||||
split = line.split(" ");
|
||||
double xll_puwg = Double.parseDouble(split[1]);
|
||||
line = br.readLine();
|
||||
split = line.split(" ");
|
||||
double yll_puwg = Double.parseDouble(split[1]);
|
||||
line = br.readLine();
|
||||
split = line.split(" ");
|
||||
double cellsize = Double.parseDouble(split[1]);
|
||||
line = br.readLine();
|
||||
split = line.split(" ");
|
||||
double nodata = Double.parseDouble(split[1]);
|
||||
double[][] data = new double[nrows][ncols];
|
||||
for (int i = nrows - 1; i >= 0; i--) {
|
||||
line = br.readLine();
|
||||
split = line.split(" ");
|
||||
for (int j = 0; j < ncols; j++) {
|
||||
data[i][j] = Double.parseDouble(split[j]);
|
||||
}
|
||||
}
|
||||
Coord.Geo geo_ll = new Coord.Geo();
|
||||
Coord.convertPUWG1992ToWGS84(yll_puwg, xll_puwg, geo_ll);
|
||||
Coord.Geo geo_ur = new Coord.Geo();
|
||||
Coord.convertPUWG1992ToWGS84(yll_puwg + nrows + cellsize, xll_puwg + ncols * cellsize, geo_ur);
|
||||
int d_x = (int) ((geo_ur.lon - geo_ll.lon) / MapConsts.DELTA_X) + 3;
|
||||
int d_y = (int) ((geo_ur.lat - geo_ll.lat) / MapConsts.DELTA_Y) + 3;
|
||||
final int x0 = Coord.zamienDlugoscGeoNaIdKwadratuX(geo_ll.lon);
|
||||
final int y0 = Coord.zamienSzerokoscGeoNaIdKwadratuY(geo_ll.lat);
|
||||
NMTData nmtData = nmtDataHashMap.computeIfAbsent(new Coord.Grid(x0, y0), k -> new NMTData(x0, y0, 0, 0));
|
||||
// Wyznacz współrzędne geo środka kwadratu.
|
||||
Coord.Geo geoCoord = new Coord.Geo();
|
||||
geoCoord.lon = Coord.zamienIdKwadratuXNaDlugoscGeo(x0);
|
||||
geoCoord.lat = Coord.zamienIdKwadratuYNaSzerokoscGeo(y0);
|
||||
PUWGCoord puwgCoord = new PUWGCoord();
|
||||
// Wyznacz współrzędne PUWG lewego dolnego rogu kwadratu.
|
||||
Coord.convertWGS84ToPUWG1992(geoCoord.lat - MapConsts.DELTA_Y / 2, geoCoord.lon - MapConsts.DELTA_X / 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);
|
||||
nmtData.eur = (int) puwgCoord.easting;
|
||||
nmtData.nur = (int) puwgCoord.northing;
|
||||
double dy_puwg = 0;
|
||||
double h;
|
||||
int x = x0;
|
||||
int y = y0;
|
||||
for (int i = 0; i < nrows; i++) {
|
||||
double y_puwg = yll_puwg + dy_puwg;
|
||||
dy_puwg += cellsize;
|
||||
// Reset współrzędnej X na gridzie (siatce).
|
||||
x = x0;
|
||||
final int x3 = x;
|
||||
final int y3 = y;
|
||||
nmtData = nmtDataHashMap.computeIfAbsent(new Coord.Grid(x, y), k -> new NMTData(x3, y3, 0, 0));
|
||||
if (y_puwg >= nmtData.nur) {
|
||||
// Przekracza zakres współrzędnych pionowych, zatem kolejny/sąsiedni kwadrat po osi OY.
|
||||
y++;
|
||||
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) {
|
||||
// Świeży kwadrat.
|
||||
// Wyznacz współrzędne geo środka kwadratu.
|
||||
geoCoord.lon = Coord.zamienIdKwadratuXNaDlugoscGeo(x);
|
||||
geoCoord.lat = Coord.zamienIdKwadratuYNaSzerokoscGeo(y);
|
||||
// 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);
|
||||
nmtData.eur = (int) puwgCoord.easting;
|
||||
nmtData.nur = (int) puwgCoord.northing;
|
||||
}
|
||||
}
|
||||
double dx_puwg = 0;
|
||||
for (int j = 0; j < ncols; j++) {
|
||||
double x_puwg = xll_puwg + dx_puwg;
|
||||
dx_puwg += cellsize;
|
||||
h = data[i][j];
|
||||
if (x_puwg >= nmtData.eur) {
|
||||
// Przekracza zakres współrzędnych poziomych, zatem kolejny/sąsiedni kwadrat po osi OX.
|
||||
x++;
|
||||
final int x2 = x;
|
||||
final int y2 = y;
|
||||
nmtData = nmtDataHashMap.computeIfAbsent(new Coord.Grid(x, y), k -> new NMTData(x2, y2, 0, 0));
|
||||
if (nmtData.eur == 0) {
|
||||
// Świeży kwadrat.
|
||||
// Wyznacz współrzędne geo środka kwadratu.
|
||||
geoCoord.lon = Coord.zamienIdKwadratuXNaDlugoscGeo(x);
|
||||
geoCoord.lat = Coord.zamienIdKwadratuYNaSzerokoscGeo(y);
|
||||
// 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);
|
||||
nmtData.eur = (int) puwgCoord.easting;
|
||||
nmtData.nur = (int) puwgCoord.northing;
|
||||
}
|
||||
}
|
||||
if (h > nodata) {
|
||||
nmtData.sum += h;
|
||||
nmtData.count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
logger.debug("Time= {}[ms]", System.currentTimeMillis() - start);
|
||||
}
|
||||
}
|
||||
|
||||
private static void readFromFileXYZ(String fn, HashMap<Coord.Grid, NMTData> nmtDataHashMap) throws IOException {
|
||||
File file = new File(fn);
|
||||
InputStream inputStream = new FileInputStream(file);
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(inputStream))) {
|
||||
PUWGCoord puwgCoord = new PUWGCoord();
|
||||
Coord.Geo geo = new Coord.Geo();
|
||||
String line = br.readLine();
|
||||
if (line == null) {
|
||||
return;
|
||||
}
|
||||
String[] split = line.split(" ");
|
||||
if (split.length != 3) {
|
||||
return;
|
||||
}
|
||||
double x_puwg = Double.parseDouble(split[0]);
|
||||
double y_puwg = Double.parseDouble(split[1]);
|
||||
double h = Double.parseDouble(split[2]);
|
||||
Coord.convertPUWG1992ToWGS84(y_puwg, x_puwg, geo);
|
||||
int x = Coord.zamienDlugoscGeoNaIdKwadratuX(geo.lon);
|
||||
int y = Coord.zamienSzerokoscGeoNaIdKwadratuY(geo.lat);
|
||||
final int xx1 = x;
|
||||
final int yy1 = y;
|
||||
Coord.Grid coordGrid = new Coord.Grid(x, y);
|
||||
NMTData nmtData = nmtDataHashMap.computeIfAbsent(coordGrid, k -> new NMTData(xx1, yy1, 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);
|
||||
// Wyznacz współrzędne PUWG lewego dolnego rogu kwadratu.
|
||||
Coord.convertWGS84ToPUWG1992(geo.lat - MapConsts.DELTA_Y / 2, geo.lon - MapConsts.DELTA_X / 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);
|
||||
nmtData.eur = (int) puwgCoord.easting;
|
||||
nmtData.nur = (int) puwgCoord.northing;
|
||||
}
|
||||
nmtData.sum += h;
|
||||
nmtData.count++;
|
||||
while ((line = br.readLine()) != null) {
|
||||
split = line.split(" ");
|
||||
if (split.length != 3) {
|
||||
continue;
|
||||
}
|
||||
x_puwg = Double.parseDouble(split[0]);
|
||||
y_puwg = Double.parseDouble(split[1]);
|
||||
h = Double.parseDouble(split[2]);
|
||||
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);
|
||||
coordGrid.set(x, y);
|
||||
final int xx2 = x;
|
||||
final int yy2 = y;
|
||||
nmtData = nmtDataHashMap.computeIfAbsent(coordGrid, k -> new NMTData(xx2, yy2, 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);
|
||||
// Wyznacz współrzędne PUWG lewego dolnego rogu kwadratu.
|
||||
Coord.convertWGS84ToPUWG1992(geo.lat - MapConsts.DELTA_Y / 2, geo.lon - MapConsts.DELTA_X / 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);
|
||||
nmtData.eur = (int) puwgCoord.easting;
|
||||
nmtData.nur = (int) puwgCoord.northing;
|
||||
}
|
||||
}
|
||||
nmtData.sum += h;
|
||||
nmtData.count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String unzipFile(String zipFileName, String destDir) throws IOException {
|
||||
byte[] buffer = new byte[1024];
|
||||
String unzipFileName = "";
|
||||
try (ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFileName))) {
|
||||
ZipEntry zipEntry = zis.getNextEntry();
|
||||
while (zipEntry != null) {
|
||||
unzipFileName = zipEntry.getName();
|
||||
File newFile = new File(destDir + unzipFileName);
|
||||
// File newFile = new File(destDir + File.separator + unzipFileName);
|
||||
int len;
|
||||
// write file content
|
||||
FileOutputStream fos = new FileOutputStream(newFile);
|
||||
while ((len = zis.read(buffer)) > 0) {
|
||||
fos.write(buffer, 0, len);
|
||||
}
|
||||
fos.close();
|
||||
zipEntry = zis.getNextEntry();
|
||||
}
|
||||
zis.closeEntry();
|
||||
}
|
||||
return unzipFileName;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje;
|
||||
package pl.wat.ms4ds.terrain;
|
||||
|
||||
import pl.wat.ms4ds.common.EGeoDirection;
|
||||
import pl.wat.ms4ds.common.ERodzajDzialania;
|
||||
@@ -1,4 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje;
|
||||
package pl.wat.ms4ds.terrain;
|
||||
|
||||
abstract class BigSquare {
|
||||
abstract Square getKwadrat(int x, int y);
|
||||
@@ -1,4 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje;
|
||||
package pl.wat.ms4ds.terrain;
|
||||
|
||||
/**
|
||||
* Klasa algorytmiczna do wyznaczania kwadratów odcinka (dyskretyzacja odcinka kwadratami/pikselami).
|
||||
@@ -1,8 +1,7 @@
|
||||
package pl.wat.ms4ds.terenfunkcje;
|
||||
package pl.wat.ms4ds.terrain;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import pl.wat.ms4ds.terenfunkcje.konwersja.PUWGCoord;
|
||||
|
||||
public class Coord {
|
||||
|
||||
@@ -341,7 +340,7 @@ public class Coord {
|
||||
* @param lat szerokość geograficzna WSG-84 [stopnie dziesiętnie]
|
||||
* @param lon długość geograficzna WSG-84 [stopnie dziesiętnie]
|
||||
*/
|
||||
public static void convertWGS84ToPUWG1992(double lat, double lon, PUWGCoord puwgCoord) {
|
||||
public static void convertWGS84ToPUWG1992(double lat, double lon, Coord.Puwg puwgCoord) {
|
||||
if (lon < 13.5 || lon > 25.5) {
|
||||
//Błędna wartość długości geograficznej (zwracana wartość 999999999999999)
|
||||
puwgCoord.easting = 999999999999999.0;
|
||||
@@ -1,4 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje;
|
||||
package pl.wat.ms4ds.terrain;
|
||||
|
||||
public class CoordConversion {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje;
|
||||
package pl.wat.ms4ds.terrain;
|
||||
|
||||
class EmptyBigSquare extends BigSquare {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje;
|
||||
package pl.wat.ms4ds.terrain;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -1,4 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje;
|
||||
package pl.wat.ms4ds.terrain;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -1,10 +1,9 @@
|
||||
package pl.wat.ms4ds.terenfunkcje;
|
||||
package pl.wat.ms4ds.terrain;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje;
|
||||
package pl.wat.ms4ds.terrain;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -1,8 +1,6 @@
|
||||
package pl.wat.ms4ds.terenfunkcje;
|
||||
package pl.wat.ms4ds.terrain;
|
||||
|
||||
|
||||
import pl.wat.ms4ds.common.EGeoDirection;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
@@ -1,4 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje;
|
||||
package pl.wat.ms4ds.terrain;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Set;
|
||||
@@ -6,13 +6,11 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import pl.wat.ms4ds.common.EGeoDirection;
|
||||
import pl.wat.ms4ds.common.ERodzajPodwozia;
|
||||
import pl.wat.ms4ds.common.ERodzajTerenuPokrycie;
|
||||
import pl.wat.ms4ds.terenfunkcje.konwersja.CoordUtils;
|
||||
import pl.wat.ms4ds.terenfunkcje.nmt.NMTDataProvider;
|
||||
import pl.wat.ms4ds.terrain.nmt.NMTDataProvider;
|
||||
|
||||
import static pl.wat.ms4ds.terenfunkcje.Square.EMPTY;
|
||||
import static pl.wat.ms4ds.terrain.Square.EMPTY;
|
||||
|
||||
public class Teren {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje;
|
||||
package pl.wat.ms4ds.terrain;
|
||||
|
||||
public enum TerrainType {
|
||||
BARE_GROUND(0),
|
||||
@@ -1,9 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje;
|
||||
|
||||
import pl.wat.ms4ds.common.EGeoDirection;
|
||||
import pl.wat.ms4ds.common.ERodzajPodwozia;
|
||||
|
||||
import java.util.ArrayList;
|
||||
package pl.wat.ms4ds.terrain;
|
||||
|
||||
|
||||
public class TerrainUtils {
|
||||
@@ -1,9 +1,8 @@
|
||||
package pl.wat.ms4ds.terenfunkcje.konwersja;
|
||||
package pl.wat.ms4ds.terrain.konwersja;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import pl.wat.ms4ds.terenfunkcje.Coord;
|
||||
import pl.wat.ms4ds.terenfunkcje.GeoCoord;
|
||||
import pl.wat.ms4ds.terrain.Coord;
|
||||
|
||||
public class CoordTest {
|
||||
static Logger logger = LoggerFactory.getLogger(CoordTest.class);
|
||||
@@ -14,7 +13,7 @@ public class CoordTest {
|
||||
|
||||
logger.debug(" ");
|
||||
|
||||
PUWGCoord puwgCoord = new PUWGCoord();
|
||||
Coord.Puwg puwgCoord = new Coord.Puwg();
|
||||
Coord.Geo geoCoord = new Coord.Geo();
|
||||
geoCoord.lon = 19;
|
||||
geoCoord.lat = 50;
|
||||
@@ -1,10 +1,10 @@
|
||||
package pl.wat.ms4ds.terenfunkcje.konwersja;
|
||||
package pl.wat.ms4ds.terrain.konwersja;
|
||||
|
||||
import pl.wat.ms4ds.terenfunkcje.Coord;
|
||||
import pl.wat.ms4ds.terenfunkcje.Teren;
|
||||
import pl.wat.ms4ds.terrain.Coord;
|
||||
import pl.wat.ms4ds.terrain.Teren;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import pl.wat.ms4ds.terenfunkcje.nmt.NMTData;
|
||||
import pl.wat.ms4ds.terrain.nmt.NMTData;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
@@ -48,19 +48,6 @@ public class CoordUtils {
|
||||
logger.debug("Koniec: poprawy danych wysokosciowych");
|
||||
|
||||
|
||||
// GeoCoord latLon = new GeoCoord();
|
||||
// PUWGCoord puwgCoord = new PUWGCoord();
|
||||
// puwgCoord.easting = 542800.0;
|
||||
// puwgCoord.northing = 732200.0;
|
||||
// puwgCoord.proj = 1;
|
||||
//
|
||||
// convertPuwgToLatLon(puwgCoord, latLon);
|
||||
// logger.debug("latLon= (" + latLon.lat + ", " + latLon.lon + ")");
|
||||
// puwgCoord.easting = 718500.0;
|
||||
// puwgCoord.northing = 663500.0;
|
||||
// convertPuwgToLatLon(puwgCoord, latLon);
|
||||
// logger.debug("latLon= (" + latLon.lat + ", " + latLon.lon + ")");
|
||||
|
||||
}
|
||||
|
||||
private static void readData(String fileName, HashMap<Coord.Grid, NMTData> daneWysokHashMap) throws IOException {
|
||||
@@ -71,7 +58,7 @@ public class CoordUtils {
|
||||
sb.append(".txt");
|
||||
FileReader fis = new FileReader(sb.toString());
|
||||
// PUWG 1992
|
||||
PUWGCoord puwgCoord = new PUWGCoord();
|
||||
Coord.Puwg puwgCoord = new Coord.Puwg();
|
||||
Coord.Geo latLon = new Coord.Geo();
|
||||
double wysokosc = 0.0;
|
||||
StringTokenizer st = null;
|
||||
@@ -1,4 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje.konwersja;
|
||||
package pl.wat.ms4ds.terrain.konwersja;
|
||||
|
||||
public enum EAreaFeature {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje.konwersja;
|
||||
package pl.wat.ms4ds.terrain.konwersja;
|
||||
|
||||
public enum ELinearFeature {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje.konwersja;
|
||||
package pl.wat.ms4ds.terrain.konwersja;
|
||||
|
||||
public enum EOSMAmenity {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje.konwersja;
|
||||
package pl.wat.ms4ds.terrain.konwersja;
|
||||
|
||||
public enum EOSMBridge {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje.konwersja;
|
||||
package pl.wat.ms4ds.terrain.konwersja;
|
||||
|
||||
public enum EOSMBuilding {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje.konwersja;
|
||||
package pl.wat.ms4ds.terrain.konwersja;
|
||||
|
||||
public enum EOSMHighway {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje.konwersja;
|
||||
package pl.wat.ms4ds.terrain.konwersja;
|
||||
|
||||
public enum EOSMLandcover {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje.konwersja;
|
||||
package pl.wat.ms4ds.terrain.konwersja;
|
||||
|
||||
public enum EOSMLanduse {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje.konwersja;
|
||||
package pl.wat.ms4ds.terrain.konwersja;
|
||||
|
||||
public enum EOSMNatural {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje.konwersja;
|
||||
package pl.wat.ms4ds.terrain.konwersja;
|
||||
|
||||
public enum EOSMWater {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje.konwersja;
|
||||
package pl.wat.ms4ds.terrain.konwersja;
|
||||
|
||||
public enum EOSMWaterway {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje.konwersja;
|
||||
package pl.wat.ms4ds.terrain.konwersja;
|
||||
|
||||
import org.nocrala.tools.gis.data.esri.shapefile.ShapeFileReader;
|
||||
import org.nocrala.tools.gis.data.esri.shapefile.ValidationPreferences;
|
||||
@@ -10,9 +10,9 @@ import org.nocrala.tools.gis.data.esri.shapefile.shape.shapes.MultiPointZShape;
|
||||
import org.nocrala.tools.gis.data.esri.shapefile.shape.shapes.PointShape;
|
||||
import org.nocrala.tools.gis.data.esri.shapefile.shape.shapes.PolygonShape;
|
||||
import org.nocrala.tools.gis.data.esri.shapefile.shape.shapes.PolylineShape;
|
||||
import pl.wat.ms4ds.terenfunkcje.Coord;
|
||||
import pl.wat.ms4ds.terenfunkcje.MapConsts;
|
||||
import pl.wat.ms4ds.terenfunkcje.Teren;
|
||||
import pl.wat.ms4ds.terrain.Coord;
|
||||
import pl.wat.ms4ds.terrain.MapConsts;
|
||||
import pl.wat.ms4ds.terrain.Teren;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import java.io.FileInputStream;
|
||||
@@ -1,4 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje.konwersja;
|
||||
package pl.wat.ms4ds.terrain.konwersja;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -1,8 +1,8 @@
|
||||
package pl.wat.ms4ds.terenfunkcje.konwersja;
|
||||
package pl.wat.ms4ds.terrain.konwersja;
|
||||
|
||||
import pl.wat.ms4ds.terenfunkcje.Square;
|
||||
import pl.wat.ms4ds.terenfunkcje.MapConsts;
|
||||
import pl.wat.ms4ds.terenfunkcje.Teren;
|
||||
import pl.wat.ms4ds.terrain.Square;
|
||||
import pl.wat.ms4ds.terrain.MapConsts;
|
||||
import pl.wat.ms4ds.terrain.Teren;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -1,7 +1,7 @@
|
||||
package pl.wat.ms4ds.terenfunkcje.konwersja;
|
||||
package pl.wat.ms4ds.terrain.konwersja;
|
||||
|
||||
import pl.wat.ms4ds.terenfunkcje.Coord;
|
||||
import pl.wat.ms4ds.terenfunkcje.Teren;
|
||||
import pl.wat.ms4ds.terrain.Coord;
|
||||
import pl.wat.ms4ds.terrain.Teren;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import java.io.FileInputStream;
|
||||
@@ -1,4 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje.konwersja;
|
||||
package pl.wat.ms4ds.terrain.konwersja;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -1,7 +1,7 @@
|
||||
package pl.wat.ms4ds.terenfunkcje.konwersja;
|
||||
package pl.wat.ms4ds.terrain.konwersja;
|
||||
|
||||
import pl.wat.ms4ds.common.EGeoDirection;
|
||||
import pl.wat.ms4ds.terenfunkcje.*;
|
||||
import pl.wat.ms4ds.terrain.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package pl.wat.ms4ds.terenfunkcje.konwersja;
|
||||
package pl.wat.ms4ds.terrain.konwersja;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import pl.wat.ms4ds.terenfunkcje.Coord;
|
||||
import pl.wat.ms4ds.terrain.Coord;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje.nmt;
|
||||
package pl.wat.ms4ds.terrain.nmt;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -1,4 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje.nmt;
|
||||
package pl.wat.ms4ds.terrain.nmt;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -8,20 +8,14 @@ import javax.xml.stream.XMLStreamConstants;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import java.io.*;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
public class NMTDataProvider {
|
||||
269
src/main/java/pl/wat/ms4ds/terrain/nmt/NMTDataReader.java
Normal file
269
src/main/java/pl/wat/ms4ds/terrain/nmt/NMTDataReader.java
Normal file
@@ -0,0 +1,269 @@
|
||||
package pl.wat.ms4ds.terrain.nmt;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import pl.wat.ms4ds.terrain.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.file.FileSystemException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
public class NMTDataReader {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(NMTDataReader.class);
|
||||
|
||||
static void main(String[] args) {
|
||||
// File dir = new File(System.getProperty("user.home") + "/nmt/gugik_SkorowidzNMT2018.gml");
|
||||
|
||||
HashMap<Coord.Grid, NMTData> nmtDataHashMap = new HashMap<>();
|
||||
|
||||
String inDir = "C:/Workspace/nmt/gugik_1m/asc/m-34/";
|
||||
String outDir = "D:/work/unzipped/";
|
||||
// String testFn = "D:\\Work\\73771_1025306_NMT-M348Dc41.xyz";
|
||||
// String testFn = "D:\\Work\\M-33-7-A-c-3-2.asc";
|
||||
String testFn = "D:\\Work\\N-34-139-A-b-2-4.asc";
|
||||
|
||||
// N-34-139-A-b-2-4.asc
|
||||
|
||||
// try {
|
||||
//// readFromFileASC(testFn, nmtDataHashMap);
|
||||
// readFromFile(testFn, nmtDataHashMap);
|
||||
// } catch (IOException e) {
|
||||
// return;
|
||||
// }
|
||||
// renameFiles(inDir, inDir);
|
||||
|
||||
|
||||
Set<String> files = NMTDataProvider.listFiles(inDir);
|
||||
for (String file : files) {
|
||||
try {
|
||||
String unzipfn = unzipFile(inDir + file, outDir);
|
||||
String fpath = outDir + unzipfn;
|
||||
readFromFile(fpath, nmtDataHashMap);
|
||||
File f = new File(fpath);
|
||||
f.delete();
|
||||
} catch (IOException _) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void renameFiles(String inDir, String outDir) {
|
||||
try {
|
||||
Set<String> fileNames = NMTDataProvider.listFiles(inDir);
|
||||
for (String fn : fileNames) {
|
||||
String fn1 = fn.substring(0, fn.lastIndexOf("-") + 1);
|
||||
String fn2 = fn.substring(fn.lastIndexOf("-") + 1, fn.indexOf("."));
|
||||
String ext = fn.substring(fn.indexOf("."));
|
||||
int pos;
|
||||
if (fn2.length() == 5) {
|
||||
pos = 1;
|
||||
} else if (fn2.length() == 6) {
|
||||
pos = 2;
|
||||
} else {
|
||||
//if (fn2.length() == 7)
|
||||
pos = 3;
|
||||
}
|
||||
String fn3 = fn2.substring(0, pos);
|
||||
String fn4 = fn2.substring(pos, pos + 1);
|
||||
String fn5 = fn2.substring(pos + 1, pos + 2);
|
||||
String fn6 = fn2.substring(pos + 2, pos + 3);
|
||||
String fn7 = fn2.substring(pos + 3, pos + 4);
|
||||
String nfn = fn1 + fn3 + '-' + fn4 + '-' + fn5 + '-' + fn6 + '-' + fn7;
|
||||
File fileToMove = new File(inDir + fn);
|
||||
boolean isMoved = fileToMove.renameTo(new File(outDir + nfn + ext));
|
||||
if (!isMoved) {
|
||||
throw new FileSystemException(outDir + fileToMove);
|
||||
}
|
||||
System.out.println(nfn);
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void readFromFile(String fn, HashMap<Coord.Grid, NMTData> nmtDataHashMap) throws IOException {
|
||||
long start = System.currentTimeMillis();
|
||||
File file = new File(fn);
|
||||
InputStream inputStream = new FileInputStream(file);
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(inputStream))) {
|
||||
String line = br.readLine();
|
||||
String[] split = line.split(" ");
|
||||
if (split.length == 2) {
|
||||
// ASC GRID format
|
||||
readASC(br, line, nmtDataHashMap);
|
||||
} else {
|
||||
// split.length ==3
|
||||
// XYZ format
|
||||
readXYZ(br, line, nmtDataHashMap);
|
||||
}
|
||||
}
|
||||
logger.debug("Time= {}[ms]", System.currentTimeMillis() - start);
|
||||
}
|
||||
|
||||
private static void readASC(BufferedReader br, String firstLine, HashMap<Coord.Grid, NMTData> nmtDataHashMap) throws IOException {
|
||||
String line = firstLine;
|
||||
String[] split = line.split(" ");
|
||||
int ncols = Integer.parseInt(split[1]);
|
||||
line = br.readLine();
|
||||
split = line.split(" ");
|
||||
int nrows = Integer.parseInt(split[1]);
|
||||
line = br.readLine();
|
||||
split = line.split(" ");
|
||||
double xll_puwg = Double.parseDouble(split[1]);
|
||||
line = br.readLine();
|
||||
split = line.split(" ");
|
||||
double yll_puwg = Double.parseDouble(split[1]);
|
||||
line = br.readLine();
|
||||
split = line.split(" ");
|
||||
double cellsize = Double.parseDouble(split[1]);
|
||||
line = br.readLine();
|
||||
split = line.split(" ");
|
||||
double nodata = Double.parseDouble(split[1]);
|
||||
double[][] data = new double[nrows][ncols];
|
||||
String s;
|
||||
for (int i = nrows - 1; i >= 0; i--) {
|
||||
line = br.readLine();
|
||||
// start od 1, gdyż wiersz zaczyna się od spacji
|
||||
int start = 1;
|
||||
int end;
|
||||
for (int j = 0; j < ncols - 1; j++) {
|
||||
end = line.indexOf(' ', start);
|
||||
s = line.substring(start, end);
|
||||
data[i][j] = Double.parseDouble(s);
|
||||
start = end + 1;
|
||||
}
|
||||
s = line.substring(start);
|
||||
data[i][ncols - 1] = Double.parseDouble(s);
|
||||
}
|
||||
NMTData nmtData = new NMTData(-1, -1, 0, 0);
|
||||
Coord.Geo geoCoord = new Coord.Geo();
|
||||
Coord.Puwg puwgCoord = new Coord.Puwg();
|
||||
double h;
|
||||
int x;
|
||||
int y;
|
||||
double y_puwg = yll_puwg;
|
||||
for (int i = 0; i < nrows; i++) {
|
||||
double x_puwg = xll_puwg;
|
||||
for (int j = 0; j < ncols; j++) {
|
||||
h = data[i][j];
|
||||
if (h <= nodata) {
|
||||
x_puwg += cellsize;
|
||||
continue;
|
||||
}
|
||||
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);
|
||||
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);
|
||||
// Wyznacz współrzędne PUWG lewego dolnego rogu kwadratu.
|
||||
Coord.convertWGS84ToPUWG1992(geoCoord.lat - MapConsts.DELTA_Y / 2, geoCoord.lon - MapConsts.DELTA_X / 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);
|
||||
nmtData.eur = (int) puwgCoord.easting;
|
||||
nmtData.nur = (int) puwgCoord.northing;
|
||||
}
|
||||
}
|
||||
if (h > nodata) {
|
||||
nmtData.sum += h;
|
||||
nmtData.count++;
|
||||
}
|
||||
x_puwg += cellsize;
|
||||
}
|
||||
y_puwg += cellsize;
|
||||
}
|
||||
}
|
||||
|
||||
private static void readXYZ(BufferedReader br, String firstLine, HashMap<Coord.Grid, NMTData> nmtDataHashMap) throws IOException {
|
||||
Coord.Puwg puwgCoord = new Coord.Puwg();
|
||||
Coord.Geo geo = new Coord.Geo();
|
||||
String line = firstLine;
|
||||
String[] split;
|
||||
double x_puwg;
|
||||
double y_puwg;
|
||||
double h;
|
||||
int x;
|
||||
int y;
|
||||
NMTData nmtData = new NMTData(-1, -1, 0, 0);
|
||||
while (line != null) {
|
||||
// start od 0, gdyż nie ma spacji na początku
|
||||
int start = 0;
|
||||
int end;
|
||||
end = line.indexOf(' ', start);
|
||||
String s = line.substring(start, end);
|
||||
x_puwg = Double.parseDouble(s);
|
||||
start = end + 1;
|
||||
end = line.indexOf(' ', start);
|
||||
s = line.substring(start, end);
|
||||
y_puwg = Double.parseDouble(s);
|
||||
start = end + 1;
|
||||
s = line.substring(start);
|
||||
h = Double.parseDouble(s);
|
||||
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);
|
||||
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.
|
||||
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);
|
||||
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);
|
||||
nmtData.eur = (int) puwgCoord.easting;
|
||||
nmtData.nur = (int) puwgCoord.northing;
|
||||
}
|
||||
}
|
||||
nmtData.sum += h;
|
||||
nmtData.count++;
|
||||
line = br.readLine();
|
||||
}
|
||||
}
|
||||
|
||||
public static String unzipFile(String zipFileName, String destDir) throws IOException {
|
||||
byte[] buffer = new byte[1024];
|
||||
String unzipFileName = "";
|
||||
try (ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFileName))) {
|
||||
ZipEntry zipEntry = zis.getNextEntry();
|
||||
while (zipEntry != null) {
|
||||
unzipFileName = zipEntry.getName();
|
||||
File newFile = new File(destDir + unzipFileName);
|
||||
// File newFile = new File(destDir + File.separator + unzipFileName);
|
||||
int len;
|
||||
// write file content
|
||||
FileOutputStream fos = new FileOutputStream(newFile);
|
||||
while ((len = zis.read(buffer)) > 0) {
|
||||
fos.write(buffer, 0, len);
|
||||
}
|
||||
fos.close();
|
||||
zipEntry = zis.getNextEntry();
|
||||
}
|
||||
zis.closeEntry();
|
||||
}
|
||||
return unzipFileName;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje.osm.shapefile;
|
||||
package pl.wat.ms4ds.terrain.osm.shapefile;
|
||||
|
||||
public class DbfField {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje.osm.shapefile;
|
||||
package pl.wat.ms4ds.terrain.osm.shapefile;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
@@ -1,4 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje.osm.shapefile;
|
||||
package pl.wat.ms4ds.terrain.osm.shapefile;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@@ -1,4 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje.osm.shapefile;
|
||||
package pl.wat.ms4ds.terrain.osm.shapefile;
|
||||
|
||||
|
||||
public class Main {
|
||||
@@ -1,4 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje.osm.shapefile;
|
||||
package pl.wat.ms4ds.terrain.osm.shapefile;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
@@ -1,4 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje.osm.shapefile;
|
||||
package pl.wat.ms4ds.terrain.osm.shapefile;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.ByteBuffer;
|
||||
@@ -1,4 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje.osm.shapefile;
|
||||
package pl.wat.ms4ds.terrain.osm.shapefile;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje.osm.shapefile;
|
||||
package pl.wat.ms4ds.terrain.osm.shapefile;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje.osm.shapefile;
|
||||
package pl.wat.ms4ds.terrain.osm.shapefile;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje.osm.shapefile;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Locale;
|
||||
package pl.wat.ms4ds.terrain.osm.shapefile;
|
||||
|
||||
/**
|
||||
* Shape: PolyLine.<br>
|
||||
@@ -1,4 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje.osm.shapefile;
|
||||
package pl.wat.ms4ds.terrain.osm.shapefile;
|
||||
|
||||
|
||||
/**
|
||||
@@ -1,4 +1,4 @@
|
||||
package pl.wat.ms4ds.terenfunkcje.osm.shapefile;
|
||||
package pl.wat.ms4ds.terrain.osm.shapefile;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
@@ -4,21 +4,12 @@ x_ref=14
|
||||
y_ref=49
|
||||
dx_ref=11
|
||||
dy_ref=7
|
||||
#kwadraty_dir=c:/Workspace/git/teren-funkcje/au2data/new_teren/Polska/kwadraty/
|
||||
kwadraty_dir=C:/Workspace/_data/swdt/ms4ds/teren/kwadraty/
|
||||
kwadraty_dir=C:/Workspace/_data/new/
|
||||
#kwadraty_dir=C:/Workspace/_data/swdt/ms4ds/teren/kwadraty/
|
||||
drogi_dir=au2data/new_teren/Polska/drogi/
|
||||
|
||||
#Afganistan
|
||||
#Wspolrzedne referencyjne i wielkosc obszaru
|
||||
#x_ref=60
|
||||
#y_ref=29
|
||||
#dx_ref=15
|
||||
#dy_ref=10
|
||||
#kwadraty_dir=/au2data/new_teren/Afganistan/kwadraty/
|
||||
#drogi_dir=/au2data/new_teren/Afganistan/drogi/
|
||||
|
||||
#Rozdzielczosc terenu dl_mk=200 | 100 | 50 | 25 | 20
|
||||
dl_mk=100
|
||||
dl_mk=20
|
||||
|
||||
#W celu wymuszenia (mimo jej braku) przejezdności terenu nalezy ustawić na: on
|
||||
przejezdnosc_zawsze=off
|
||||
|
||||
Reference in New Issue
Block a user