use of org.hortonmachine.dbs.geopackage.TileEntry in project hortonmachine by TheHortonMachine.
the class GeopackageTilesNwwLayer method makeLevels.
private static LevelSet makeLevels(File gpkgFile, GeopackageCommonDb gpkgDb, String tableName) throws Exception {
AVList params = new AVListImpl();
SqlName tName = SqlName.m(tableName);
String cacheRelativePath = "gpkg/" + gpkgFile.getName() + "-" + tName.name + "-tiles";
TileEntry tile = gpkgDb.tile(tName);
int tileSize = tile.getTileMatricies().get(0).getTileWidth();
String urlString = gpkgFile.toURI().toURL().toExternalForm();
params.setValue(AVKey.URL, urlString);
params.setValue(AVKey.TILE_WIDTH, tileSize);
params.setValue(AVKey.TILE_HEIGHT, tileSize);
params.setValue(AVKey.DATA_CACHE_NAME, cacheRelativePath);
params.setValue(AVKey.SERVICE, "*");
params.setValue(AVKey.DATASET_NAME, "*");
final String _imageFormat = "png";
params.setValue(AVKey.FORMAT_SUFFIX, "." + _imageFormat);
params.setValue(AVKey.NUM_LEVELS, 22);
params.setValue(AVKey.NUM_EMPTY_LEVELS, 0);
params.setValue(AVKey.LEVEL_ZERO_TILE_DELTA, new LatLon(Angle.fromDegrees(22.5d), Angle.fromDegrees(45d)));
params.setValue(AVKey.SECTOR, new MercatorSector(-1.0, 1.0, Angle.NEG180, Angle.POS180));
File cacheRoot = CacheUtils.getCacheRoot();
final File cacheFolder = new File(cacheRoot, cacheRelativePath);
if (!cacheFolder.exists()) {
cacheFolder.mkdirs();
}
List<Integer> tileZoomLevelsWithData = gpkgDb.getTileZoomLevelsWithData(tName);
params.setValue(AVKey.TILE_URL_BUILDER, new TileUrlBuilder() {
public URL getURL(Tile tile, String altImageFormat) throws MalformedURLException {
int zoom = tile.getLevelNumber() + 3;
// int x = tile.getColumn();
// int y = tile.getRow();
Sector sector = tile.getSector();
double north = sector.getMaxLatitude().degrees;
double south = sector.getMinLatitude().degrees;
double east = sector.getMaxLongitude().degrees;
double west = sector.getMinLongitude().degrees;
double centerX = west + (east - west) / 2.0;
double centerY = south + (north - south) / 2.0;
int[] zxy = MercatorUtils.getTileNumber(centerY, centerX, zoom);
int x = zxy[1];
int y = zxy[2];
try {
StringBuilder sb = new StringBuilder();
sb.append(zoom);
sb.append(File.separator);
sb.append(x);
File tileImageFolderFile = new File(cacheFolder, sb.toString());
if (!tileImageFolderFile.exists()) {
tileImageFolderFile.mkdirs();
}
sb = new StringBuilder();
sb.append(y);
sb.append(".");
sb.append(_imageFormat);
File imgFile = new File(tileImageFolderFile, sb.toString());
if (!imgFile.exists()) {
BufferedImage bImg = null;
byte[] bytes = gpkgDb.getTile(tName, x, y, zoom);
if (bytes != null) {
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
bImg = ImageIO.read(bais);
} else {
// try downscaling from higher resolutions
// look in the other levels
int from = zoom + 1;
int to = Math.min(zoom + 5, 19);
for (int higherZoom = from; higherZoom < to; higherZoom++) {
if (!tileZoomLevelsWithData.contains(higherZoom)) {
continue;
}
BufferedImage img = TileUtilities.getTileFromDifferentZoomlevel(gpkgDb, tName.name, x, y, zoom, tileSize, higherZoom);
if (img != null) {
bImg = img;
break;
}
}
if (bImg == null) {
// then try upscaling from lower resolution
from = zoom - 1;
int zoomLevelTotry = 5;
to = Math.max(zoom - zoomLevelTotry, 1);
for (int lowerZoom = from; lowerZoom > to; lowerZoom--) {
if (!tileZoomLevelsWithData.contains(lowerZoom)) {
continue;
}
BufferedImage img = TileUtilities.getTileFromDifferentZoomlevel(gpkgDb, tName.name, x, y, zoom, tileSize, lowerZoom);
if (img != null) {
bImg = img;
break;
}
}
}
}
if (DEBUG) {
if (bImg == null && DEBUG_ALSO_WITHOUT_IMAGE) {
bImg = new BufferedImage(tileSize, tileSize, BufferedImage.TYPE_INT_ARGB);
}
if (bImg != null) {
Graphics2D g2d = (Graphics2D) bImg.getGraphics();
g2d.setColor(Color.black);
g2d.drawRect(0, 0, TILESIZE, TILESIZE);
g2d.drawString(zoom + "/" + x + "/" + y, 3, TILESIZE / 2);
g2d.dispose();
}
}
if (bImg != null) {
ImageIO.write(bImg, _imageFormat, imgFile);
} else {
return null;
}
}
return imgFile.toURI().toURL();
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
});
return new LevelSet(params);
}
use of org.hortonmachine.dbs.geopackage.TileEntry in project hortonmachine by TheHortonMachine.
the class TestGeopackage method testTilesGdaltranslate.
@Test
public void testTilesGdaltranslate() throws Exception {
URL dataUrl = TestGeopackage.class.getClassLoader().getResource("test_3857.gpkg");
File gpkgFile = new File(dataUrl.toURI());
try (GeopackageCommonDb db = (GeopackageCommonDb) EDb.GEOPACKAGE.getSpatialDb()) {
db.open(gpkgFile.getAbsolutePath());
db.initSpatialMetadata(null);
HashMap<String, List<String>> tablesMap = db.getTablesMap(false);
List<String> tables = tablesMap.get(GeopackageTableNames.USERDATA);
assertEquals(1, tables.size());
List<Entry> contents = db.contents();
assertEquals(1, contents.size());
SqlName tableName = SqlName.m("gboverviewplus");
TileEntry tileEntry = db.tile(tableName);
assertNotNull(tileEntry);
int srid = tileEntry.getSrid();
assertEquals(3857, srid);
Envelope bounds = tileEntry.getBounds();
double delta = 0.000001;
assertEquals(-1001968.845655086, bounds.getMinX(), delta);
assertEquals(6276897.685170724, bounds.getMinY(), delta);
assertEquals(222246.5993602969, bounds.getMaxX(), delta);
assertEquals(8625654.690317621, bounds.getMaxY(), delta);
Envelope tileMatrixSetBounds = tileEntry.getTileMatrixSetBounds();
assertEquals(-2.003750834278924E7, tileMatrixSetBounds.getMinX(), delta);
assertEquals(-2.003750834278924E7, tileMatrixSetBounds.getMinY(), delta);
assertEquals(2.003750834278924E7, tileMatrixSetBounds.getMaxX(), delta);
assertEquals(2.003750834278924E7, tileMatrixSetBounds.getMaxY(), delta);
List<TileMatrix> tileMatricies = tileEntry.getTileMatricies();
assertEquals(9, tileMatricies.size());
// 8/125/79.png Edinburg
byte[] tile = db.getTile(tableName, 125, 79, 8);
// ByteArrayInputStream bais = new ByteArrayInputStream(tile);
// BufferedImage bufferedImage = ImageIO.read(bais);
// ImageIO.write(bufferedImage, "png", new
// File("test.png"));
String encodeToString = Base64.getEncoder().encodeToString(tile);
String expected = "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAEAAQADASIAAhEBAxEB/8QAHAAAAQUBAQEAAAAAAAAAAAAAAwECBAUGBwAI/8QARxAAAgEDAwIFAQYDBAUKBwAAAQIDAAQRBRIhBjEHEyJBUWEUMnGBkbEjQqEVUsHRFhckYvAIM0NjcnOCkrLhJSc0RFOi8f/EABoBAAMBAQEBAAAAAAAAAAAAAAABAgMEBQb/xAAxEQACAgIBBAADBwMFAQAAAAAAAQIRAyExBBJBUSIyYQUTcYGRodEUQrEjM0Ph8MH/2gAMAwEAAhEDEQA/AOxWtzDH6I4sue7N3Jr0hjyWKFpB2x2FNgglC+ZIdmR396nW0KkAKuV9yfeufkY22h+zWu4LiRzzipVsNud4w3yaJLwgwQD7E0KKAhmaRyzfQ9q0Somt2FV98p44HaldwFbDDNMRcq43EGmCCFCPSWLfJp7ooGt4WJ8uN3C++O9ejuXMnrQqD81IJVNqIAOew9q87ZJGBtHcmp/MAcUm9HbBABOPrQndvQ5IHPaj7gkZKLkH4qM7QDAbduJ+KTAFLGwcvg96kW8uITk7+aeYTNHsLYHyKJDbJAuFpKLu0So0wBCzYVcA/Bpo06IEsc7z71MGwEvgZ+RTJZB/ewBzVdqSG1fJAuIHgjZs8+1At3EcjOQxdh79hUyUTXY2ABUx3Nee3EVthBlh3J7moa3ohxa2h6CQsDhX+vxUpV+QAfeoNrG6oGGe/apMkowCeGHtVLgpS1sLtBPH61EuQ/nKi8ijvIQu4ELx70AFnk3/AB3NN0xSfglBTgKDwKcAB270OGXzM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4e6/qXiWus29uv2PzY23FhnAGD70Voeu5ssfGHo1dZ0sa3YRZvLZf4oUffT/25NcOv9Zu9ThsYrp9/wBkXy42PfbnODX2CyK8fkuAVKbXHzxg1wbqnwc1R+obmTRfKNnI3mKHYAqTyR3pMcX7Og6o5m8LHGP/ALE/+k1zDwZtbK71u9jvYoJE8njzsYHI+a7GdCmboT+yWZRdPamLk8bsGuPweCnVkfMV1bocYJWUD/GlVkxdpnXL/QukRA6XUGniMqdx3AY/Q1wbpKZ7LxOtk0lmMRu2RQOzJzWhk8GOqTgXGoQlWOOZM1v+gvCy06Uul1G7uPtN/jCcYVPwoBUr2Zrx+tn8vSbjaduXQnHA4Fajwp1rTr/o60tWvUWe2yrxM4B7n2Na/qXpqx6p0aTTr9fQ3KsO6H5FcauPA3XbW6Y6bq0YiJwrb2RsfXAp0PTVMtPHXWrCfS7LTYLmOW48wu6owO0DHf8ArV74NWc8HQQkIIErswz7jkVmdK8CL2W9SbW9VV4gcsI2LM30yRXZ7SzttJ06KytYwkESbQB7D5qq8sUqqj5ngC/64mEqhlOoncpGQfUK7R130FpnU+hyfY7eKC+hG+J40C5PwcVnz4TzL1oeohqkbRm58/ytp+Qcdq6qrBV3JzkVKBy3o+a/D3q+96R6h/srU2dbOSTypY5D/wA03bI+K6/4g6EOo+jbi3tz5sygTQEe5/8A5mqbrbwrtOotb/tCO6+yTyj+Kqrncfmtb07pN3o2jQWVxeG6aIbVcqQdvwaX0Jk03aP/2Q==";
assertEquals(expected, encodeToString);
// 56.029/-3.594
byte[] tile2 = db.getTile(tableName, -3.594, 56.029, 8);
encodeToString = Base64.getEncoder().encodeToString(tile2);
assertEquals(expected, encodeToString);
}
}
use of org.hortonmachine.dbs.geopackage.TileEntry in project hortonmachine by TheHortonMachine.
the class ToolsPanelController method loadFile.
private void loadFile(File selectedFile) {
String name = FileUtilities.getNameWithoutExtention(selectedFile);
try {
if (selectedFile.getName().endsWith(".asc") || selectedFile.getName().endsWith(".tiff")) {
GridCoverageNwwLayer coverageNwwLayer = new GridCoverageNwwLayer(selectedFile, null, Color.WHITE);
wwjPanel.getWwd().getModel().getLayers().add(coverageNwwLayer);
layerEventsListener.onLayerAdded(coverageNwwLayer);
} else if (selectedFile.getName().endsWith(".shp")) {
// shp or image mosaic?
File parentFolder = selectedFile.getParentFile();
String fileName = FileUtilities.getNameWithoutExtention(selectedFile);
File imageMosaicPropertiesFile = new File(parentFolder, fileName + ".properties");
try {
if (imageMosaicPropertiesFile.exists()) {
final ParameterValue<Color> inTransp = AbstractGridFormat.INPUT_TRANSPARENT_COLOR.createValue();
inTransp.setValue(Color.white);
final ParameterValue<Boolean> fading = ImageMosaicFormat.FADING.createValue();
fading.setValue(true);
final ParameterValue<Boolean> multiThread = ImageMosaicFormat.ALLOW_MULTITHREADING.createValue();
multiThread.setValue(true);
final ParameterValue<Boolean> usejai = ImageMosaicFormat.USE_JAI_IMAGEREAD.createValue();
usejai.setValue(true);
GeneralParameterValue[] gp = new GeneralParameterValue[] { inTransp, usejai, multiThread };
ImageMosaicNwwLayer imageMosaicNwwLayer = new ImageMosaicNwwLayer(selectedFile, null, gp, true);
wwjPanel.getWwd().getModel().getLayers().add(imageMosaicNwwLayer);
layerEventsListener.onLayerAdded(imageMosaicNwwLayer);
return;
}
} catch (Exception e) {
e.printStackTrace();
// ignore and handle as shapefile
}
HashMap<String, String[]> field2ValuesMap = null;
File codesFile = new File(selectedFile.getParentFile(), fileName + ".codes");
if (codesFile.exists()) {
List<String> linesList = FileUtilities.readFileToLinesList(codesFile);
field2ValuesMap = new HashMap<>();
for (String line : linesList) {
String[] split = line.split("=");
String key = split[0];
String[] values = split[1].split(";");
field2ValuesMap.put(key, values);
}
}
SimpleFeatureSource featureSource = NwwUtilities.readFeatureSource(selectedFile.getAbsolutePath());
SimpleFeatureStore featureStore = null;
if (featureSource instanceof SimpleFeatureStore) {
featureStore = (SimpleFeatureStore) featureSource;
}
SimpleFeatureCollection readFC = NwwUtilities.readAndReproject(featureSource);
loadFeatureCollection(selectedFile, name, featureStore, readFC, field2ValuesMap);
} else if (selectedFile.getName().endsWith(".mbtiles")) {
MBTilesNwwLayer mbTileLayer = new MBTilesNwwLayer(selectedFile);
wwjPanel.getWwd().getModel().getLayers().add(mbTileLayer);
layerEventsListener.onLayerAdded(mbTileLayer);
} else if (selectedFile.getName().endsWith(".gpkg")) {
List<String> tilesTables = new ArrayList<>();
List<String> featureTables = new ArrayList<>();
try (GeopackageCommonDb db = new GeopackageDb()) {
db.open(selectedFile.getAbsolutePath());
List<TileEntry> tiles = db.tiles();
for (TileEntry tileEntry : tiles) {
tilesTables.add(tileEntry.getTableName());
}
List<FeatureEntry> features = db.features();
for (FeatureEntry featureEntry : features) {
featureTables.add(featureEntry.getTableName());
}
}
for (String tableName : tilesTables) {
GeopackageTilesNwwLayer gpkgTilesLayer = new GeopackageTilesNwwLayer(selectedFile, tableName);
wwjPanel.getWwd().getModel().getLayers().add(gpkgTilesLayer);
layerEventsListener.onLayerAdded(gpkgTilesLayer);
}
if (_useRasterizedCheckbox.isSelected()) {
for (String tableName : featureTables) {
SimpleFeatureCollection readFC = OmsVectorReader.readVector(selectedFile.getAbsolutePath() + HMConstants.DB_TABLE_PATH_SEPARATOR + tableName);
String sldString = null;
try (GeopackageCommonDb db = new GeopackageDb()) {
db.open(selectedFile.getAbsolutePath());
sldString = db.getSldString(SqlName.m(tableName));
}
Style style;
if (sldString != null) {
style = SldUtilities.getStyleFromSldString(sldString);
} else {
style = SLD.createSimpleStyle(readFC.getSchema(), Color.BLUE);
}
String n = selectedFile.getName() + HMConstants.DB_TABLE_PATH_SEPARATOR + tableName;
RasterizedFeatureCollectionLayer collectionLayer = new RasterizedFeatureCollectionLayer(n, readFC, style, null, true);
wwjPanel.getWwd().getModel().getLayers().add(collectionLayer);
layerEventsListener.onLayerAdded(collectionLayer);
}
} else {
for (String tableName : featureTables) {
GeopackageVectorLayer gpkgVectorLayer = new GeopackageVectorLayer(selectedFile.getAbsolutePath(), tableName);
wwjPanel.getWwd().getModel().getLayers().add(gpkgVectorLayer);
layerEventsListener.onLayerAdded(gpkgVectorLayer);
}
}
} else if (selectedFile.getName().endsWith(".map")) {
String layerName = FileUtilities.getNameWithoutExtention(selectedFile);
MapsforgeNwwLayer mbTileLayer = new MapsforgeNwwLayer(layerName, new File[] { selectedFile }, null, null);
wwjPanel.getWwd().getModel().getLayers().add(mbTileLayer);
layerEventsListener.onLayerAdded(mbTileLayer);
} else if (selectedFile.getName().endsWith(".rl2")) {
GTSpatialiteThreadsafeDb db = new GTSpatialiteThreadsafeDb();
db.open(selectedFile.getAbsolutePath());
Rasterlite2Db rldb = new Rasterlite2Db(db);
List<Rasterlite2Coverage> rasterCoverages = rldb.getRasterCoverages(false);
if (rasterCoverages.size() > 0) {
Rasterlite2Coverage rasterCoverage = rasterCoverages.get(0);
RL2NwwLayer rl2Layer = new RL2NwwLayer(rasterCoverage, null);
wwjPanel.getWwd().getModel().getLayers().add(rl2Layer);
layerEventsListener.onLayerAdded(rl2Layer);
}
} else if (selectedFile.getName().endsWith(".sqlite")) {
ASpatialDb db = new GTSpatialiteThreadsafeDb();
db.open(selectedFile.getAbsolutePath());
if (RasterizedSpatialiteLasLayer.isLasDb(db)) {
String[] options = { "elevation", "intensity" };
String option = (String) JOptionPane.showInputDialog(this, "Select data to view", "Data selection", JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
boolean doIntensity = false;
if (option.equals(options[1])) {
doIntensity = true;
}
RasterizedSpatialiteLasLayer rasterizedSpatialiteLayer = new RasterizedSpatialiteLasLayer(name, db, null, true, doIntensity);
wwjPanel.getWwd().getModel().getLayers().add(rasterizedSpatialiteLayer);
layerEventsListener.onLayerAdded(rasterizedSpatialiteLayer);
} else {
List<String> tableMaps = db.getTables(false);
String[] tables = tableMaps.toArray(new String[0]);
String tableName = (String) JOptionPane.showInputDialog(this, "Select the table to load", "Table selection", JOptionPane.QUESTION_MESSAGE, null, tables, tables[0]);
if (_useRasterizedCheckbox.isSelected()) {
RasterizedSpatialiteLayer rasterizedSpatialiteLayer = new RasterizedSpatialiteLayer(name, db, tableName, -1, null, null, true);
wwjPanel.getWwd().getModel().getLayers().add(rasterizedSpatialiteLayer);
layerEventsListener.onLayerAdded(rasterizedSpatialiteLayer);
} else {
GeometryColumn geometryColumn = db.getGeometryColumnsForTable(SqlName.m(tableName));
if (geometryColumn != null) {
org.hortonmachine.dbs.datatypes.EGeometryType geomType = geometryColumn.geometryType;
if (geomType.isPolygon()) {
SpatialitePolygonLayer layer = new SpatialitePolygonLayer(db, tableName, 10000);
wwjPanel.getWwd().getModel().getLayers().add(layer);
layerEventsListener.onLayerAdded(layer);
} else if (geomType.isLine()) {
SpatialiteLinesLayer layer = new SpatialiteLinesLayer(db, tableName, 10000);
wwjPanel.getWwd().getModel().getLayers().add(layer);
layerEventsListener.onLayerAdded(layer);
} else if (geomType.isPoint()) {
SpatialitePointsLayer layer = new SpatialitePointsLayer(db, tableName, 10000);
wwjPanel.getWwd().getModel().getLayers().add(layer);
layerEventsListener.onLayerAdded(layer);
}
}
}
}
}
} catch (Exception e1) {
e1.printStackTrace();
}
}
use of org.hortonmachine.dbs.geopackage.TileEntry in project hortonmachine by TheHortonMachine.
the class TestGeopackage method testTilesGeotools.
@Test
public void testTilesGeotools() throws Exception {
URL dataUrl = TestGeopackage.class.getClassLoader().getResource("test_tiles_srid.gpkg");
File gpkgFile = new File(dataUrl.toURI());
try (GeopackageCommonDb db = (GeopackageCommonDb) EDb.GEOPACKAGE.getSpatialDb()) {
db.open(gpkgFile.getAbsolutePath());
db.initSpatialMetadata(null);
HashMap<String, List<String>> tablesMap = db.getTablesMap(false);
List<String> tables = tablesMap.get(GeopackageTableNames.USERDATA);
assertEquals(1, tables.size());
List<Entry> contents = db.contents();
assertEquals(1, contents.size());
TileEntry tileEntry = db.tile(SqlName.m("test"));
assertNotNull(tileEntry);
int srid = tileEntry.getSrid();
assertEquals(3857, srid);
Envelope bounds = tileEntry.getBounds();
double delta = 0.000001;
assertEquals(-1.50672670155739E7, bounds.getMinX(), delta);
assertEquals(8570731.107560242, bounds.getMinY(), delta);
assertEquals(-1.502813125709188E7, bounds.getMaxX(), delta);
assertEquals(8609866.86604225, bounds.getMaxY(), delta);
Envelope tileMatrixSetBounds = tileEntry.getTileMatrixSetBounds();
assertEquals(-1.50672670155739E7, tileMatrixSetBounds.getMinX(), delta);
assertEquals(8548683.634461217, tileMatrixSetBounds.getMinY(), delta);
assertEquals(-1.500608378399286E7, tileMatrixSetBounds.getMaxX(), delta);
assertEquals(8609866.86604225, tileMatrixSetBounds.getMaxY(), delta);
List<TileMatrix> tileMatricies = tileEntry.getTileMatricies();
assertEquals(3, tileMatricies.size());
}
}
Aggregations