use of org.hortonmachine.gears.utils.time.EggClock in project hortonmachine by TheHortonMachine.
the class Mapurl2MbtilesConverter method process.
@Execute
public void process() throws Exception {
checkNull(inFile);
File mapurlFile = new File(inFile);
HashMap<String, String> metadataMap = FileUtilities.readFileToHashMap(inFile, "=", false);
String url = metadataMap.get("url");
if (url == null) {
throw new ModelsIllegalargumentException("The supplied file doesn't seem to be a valid HortonMachine mapurl file.", this, pm);
}
if (url.endsWith("jpg")) {
format = "jpg";
} else {
format = "png";
}
File dbFile = FileUtilities.substituteExtention(mapurlFile, "mbtiles");
String tilesetName = FileUtilities.getNameWithoutExtention(mapurlFile);
File folderFile = new File(mapurlFile.getParentFile(), tilesetName);
mbtilesHelper = new MBTilesHelper();
mbtilesHelper.open(dbFile);
mbtilesHelper.createTables(false);
File[] zFolders = folderFile.listFiles();
List<File> xFolder = new ArrayList<File>();
for (File zFolder : zFolders) {
File[] xFiles = zFolder.listFiles();
for (File xFile : xFiles) {
if (xFile.isDirectory()) {
xFolder.add(xFile);
}
}
}
final GlobalMercator mercator = new GlobalMercator();
int minZ = 1000;
int maxZ = -1000;
EggClock clock = new EggClock("Time check: ", " sec");
clock.startAndPrint(System.out);
for (File xFile : xFolder) {
String zStr = xFile.getParentFile().getName();
final int z = Integer.parseInt(zStr);
minZ = min(minZ, z);
maxZ = max(maxZ, z);
String xStr = xFile.getName();
final int x = Integer.parseInt(xStr);
final File[] yFiles = xFile.listFiles(new FilenameFilter() {
public boolean accept(File arg0, String name) {
boolean endsWithPng = name.endsWith("png");
boolean endsWithJpg = name.endsWith("jpg");
if (endsWithPng || endsWithJpg) {
return true;
}
return false;
}
});
for (File yFile : yFiles) {
String yStr = FileUtilities.getNameWithoutExtention(yFile);
int y = Integer.parseInt(yStr);
Envelope wsen = mercator.TileLatLonBounds(x, y, z);
n = max(n, wsen.getMaxY());
e = max(e, wsen.getMaxX());
s = max(s, wsen.getMinY());
w = max(w, wsen.getMinX());
try {
BufferedImage image = ImageIO.read(yFile);
mbtilesHelper.addTile(x, y, z, image, format);
} catch (Exception e1) {
e1.printStackTrace();
}
if (imageIndex % 1000 == 0) {
pm.message("Images inserted in db: " + imageIndex);
clock.printTimePassedInSeconds(System.out);
}
imageIndex++;
}
}
mbtilesHelper.fillMetadata((float) n, (float) s, (float) w, (float) e, "tilesetName", format, minZ, maxZ);
mbtilesHelper.createIndexes();
mbtilesHelper.close();
}
use of org.hortonmachine.gears.utils.time.EggClock in project hortonmachine by TheHortonMachine.
the class DatabaseLasWriter method main.
public static void main(String[] args) throws Exception {
EggClock egg = new EggClock("DATABASE**************** ", "");
egg.startAndPrint(System.out);
DatabaseLasWriter w = new DatabaseLasWriter();
w = new DatabaseLasWriter();
w.pDbType = EDb.SPATIALITE.name();
w.pLevels = 4;
w.pCellsize = 1;
w.inFolder = "/media/hydrologis/Samsung_T3/UNIBZ/monticolo_tls";
w.inDatabasePath = "/media/hydrologis/Samsung_T3/UNIBZ/monticolo_tls/monticolo2018_point_cloud_02.sqlite";
w.process();
egg.printTimePassedInSeconds(System.out);
}
Aggregations