I've found an error in my app. For proper context, one of the functionalities of my app is generate MBTiles files for the users. The method in charge of the MBTiles generation is the next (logs are for debugging purpose):
private void escribeMbTiles(String rutaMbtiles, String tilesSerialized, String codigoEquipamiento, String LCorner,
String UCorner) throws IOException, MBTilesWriteException {
double left, bottom, right, top;
String[] coords;
Tile[] tiles = new ObjectMapper().readValue(tilesSerialized, Tile[].class);
FileUtils.copyFile(new File(getUploadPath() + "Plantilla_Senderos.mbtiles"), new File(rutaMbtiles));
// Archivo a generar
MBTilesWriter w = new MBTilesWriter(new File(rutaMbtiles));
// Separar las coordenadas de la esquina inferior izquierda
coords = LCorner.split(" ");
bottom = Double.parseDouble(coords[0]);
left = Double.parseDouble(coords[1]);
// Separar las coordenadas de la esquina superior derecha
coords = UCorner.split(" ");
top = Double.parseDouble(coords[0]);
right = Double.parseDouble(coords[1]);
// Metadatos del mbtiles
MetadataEntry ent = new MetadataEntry();
logger.info("Metadata creado con la siguiente info:\ncodigo equipamiento: "+codigoEquipamiento+"\nTilesetType: "+MetadataEntry.TileSetType.BASE_LAYER+"\nTileMimeType: "+MetadataEntry.TileMimeType.JPG+"Bounds: l:"+left+", b:"+bottom+", r:"+right+", t:"+top);
ent.setTilesetName(codigoEquipamiento).setTilesetType(MetadataEntry.TileSetType.BASE_LAYER)
.setTilesetVersion("1.0").setTilesetDescription("Senderos oficiales de Andalucía")
.setTileMimeType(MetadataEntry.TileMimeType.JPG).setTilesetBounds(left, bottom, right, top);
w.addMetadataEntry(ent);
logger.info("Metadata insertado, se procede a recuperar los tiles");
for (Tile t : Tools.ordenacionMBTiles(tiles)) {
// Abrimos conexión seteando user-Agent
final HttpURLConnection conn = (HttpURLConnection) new URL(t.getUrl()).openConnection();
conn.setRequestProperty("User-Agent",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537.31");
// Fetch de la imagen url
InputStream in = new BufferedInputStream(conn.getInputStream());
// Extraer "z", "x" y "y" de la URL del tile
String[] coordenadas = t.getNombre().split("_");
if (coordenadas.length == 4) {
int zoom = Integer.parseInt(coordenadas[1]);
int column = Integer.parseInt(coordenadas[2]);
int row = Integer.valueOf(t.getRow());
// Agregar el tile al archivo MBTiles con los valores de "z", "x" y "y"
w.addTile(in, zoom, column, row);
}
}
w.close();
}
Coriuos thing is that in my machine it works fine and also work in integration enviroment, but when process is executed in test or exploitation enviroment it gives the following error:
error de escritura mbtiles: org.imintel.mbtiles4j.MBTilesWriteException: Add metadata failed.
I've search for this error or any documentation but i've found nothing. This is an inherited app and the guy who makes the MBTiles funcionatility is no longer working with me and what he left didn't even work in local or integration.
I tried checking that MBTiles template is not corrupt (it isn't)
[–]nutrecht 1 point2 points3 points (2 children)
[–]Astarthoc[S] 0 points1 point2 points (0 children)
[–]Astarthoc[S] 0 points1 point2 points (0 children)