fix bugs
git-svn-id: https://osmand.googlecode.com/svn/trunk@160 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
parent
d3f51f9c0f
commit
de0bae2b38
4 changed files with 55 additions and 39 deletions
|
@ -26,7 +26,7 @@ public class ToDoConstants {
|
||||||
// 32. Introduce POI predefined filters (car filter(other-fuel, transportation-car_wash, show-car) and others)
|
// 32. Introduce POI predefined filters (car filter(other-fuel, transportation-car_wash, show-car) and others)
|
||||||
// ( 1) predefined filters, 2) choose subtype's, 3) filter by name, 4) opening hours (filter))
|
// ( 1) predefined filters, 2) choose subtype's, 3) filter by name, 4) opening hours (filter))
|
||||||
|
|
||||||
// 20. Implement save track/route to gpx
|
|
||||||
// 8. Enable change POI directly on map (requires OSM login)
|
// 8. Enable change POI directly on map (requires OSM login)
|
||||||
// 33. Build transport locations. Create transport index (transport-stops) (investigate) [TODO]
|
// 33. Build transport locations. Create transport index (transport-stops) (investigate) [TODO]
|
||||||
// 44. Introduce settings presets (car/bicycle/pedestrian/default) - show different icons for car (bigger),
|
// 44. Introduce settings presets (car/bicycle/pedestrian/default) - show different icons for car (bigger),
|
||||||
|
@ -40,29 +40,24 @@ public class ToDoConstants {
|
||||||
// 34. Suppport navigation for calculated route (example of get route from internet is in swing app).
|
// 34. Suppport navigation for calculated route (example of get route from internet is in swing app).
|
||||||
// 40. Support simple vector road rendering (require new index file)
|
// 40. Support simple vector road rendering (require new index file)
|
||||||
|
|
||||||
// 43. Enable poi filter by name
|
// 43. Enable poi filter by name (?)
|
||||||
// 26. Show the whole street on map (when it is chosen in search activity). Possibly extend that story to show layer with streets. (?)
|
// 26. Show the whole street on map (when it is chosen in search activity). Possibly extend that story to show layer with streets. (?)
|
||||||
|
|
||||||
|
|
||||||
// BUGS Android
|
// BUGS Android
|
||||||
// 5. Improvement : Implement caching files existing on FS, implement specific method in RM
|
// 5. Improvement : Implement caching files existing on FS, implement specific method in RM
|
||||||
// Introducing cache of file names that are on disk (creating new File() consumes a lot of memory)
|
// Introducing cache of file names that are on disk (creating new File() consumes a lot of memory)
|
||||||
// 6. Bug : loading from internet tile (when internet is not accessible). For rotated map investigate loading tile mechanism.
|
|
||||||
//
|
|
||||||
|
|
||||||
// BUGS Swing
|
|
||||||
// 1. Bug renaming region
|
|
||||||
|
|
||||||
|
|
||||||
// TODO swing
|
// TODO swing
|
||||||
// 4. Fix issues with big files (such as netherlands) - save memory (!)
|
// 4. Fix issues with big files (such as netherlands) - save memory (!)
|
||||||
// Current result : for big file (1 - task 60-80% time, 90% memory)
|
// Current result : for big file (1 - task 60-80% time, 90% memory)
|
||||||
|
|
||||||
// 1. Download tiles without using dir tiles (?)
|
// 1. Download tiles without using dir tiles (?)
|
||||||
|
|
||||||
|
// BUGS Swing
|
||||||
|
|
||||||
// DONE ANDROID :
|
// DONE ANDROID :
|
||||||
|
// 20. Implement save track/route to gpx
|
||||||
|
|
||||||
// DONE SWING
|
// DONE SWING
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,7 @@ public class MapTileDownloader {
|
||||||
public final int xTile;
|
public final int xTile;
|
||||||
public final int yTile;
|
public final int yTile;
|
||||||
public final String url;
|
public final String url;
|
||||||
|
public boolean error;
|
||||||
|
|
||||||
public DownloadRequest(String url, File fileToSave, int xTile, int yTile, int zoom) {
|
public DownloadRequest(String url, File fileToSave, int xTile, int yTile, int zoom) {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
|
@ -89,6 +90,10 @@ public class MapTileDownloader {
|
||||||
yTile = -1;
|
yTile = -1;
|
||||||
zoom = -1;
|
zoom = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setError(boolean error){
|
||||||
|
this.error = error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -163,12 +168,16 @@ public class MapTileDownloader {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
if (request != null && request.fileToSave != null && request.url != null) {
|
||||||
|
if(currentlyDownloaded.contains(request.fileToSave)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
currentlyDownloaded.add(request.fileToSave);
|
||||||
if(log.isDebugEnabled()){
|
if(log.isDebugEnabled()){
|
||||||
log.debug("Start downloading tile : " + request.url);
|
log.debug("Start downloading tile : " + request.url);
|
||||||
}
|
}
|
||||||
if (request != null && request.fileToSave != null && request.url != null) {
|
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
currentlyDownloaded.add(request.fileToSave);
|
|
||||||
try {
|
try {
|
||||||
request.fileToSave.getParentFile().mkdirs();
|
request.fileToSave.getParentFile().mkdirs();
|
||||||
URL url = new URL(request.url);
|
URL url = new URL(request.url);
|
||||||
|
@ -189,9 +198,11 @@ public class MapTileDownloader {
|
||||||
}
|
}
|
||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException e) {
|
||||||
currentErrors++;
|
currentErrors++;
|
||||||
|
request.setError(true);
|
||||||
log.error("UnknownHostException, cannot download tile " + request.url + " " + e.getMessage());
|
log.error("UnknownHostException, cannot download tile " + request.url + " " + e.getMessage());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
currentErrors++;
|
currentErrors++;
|
||||||
|
request.setError(true);
|
||||||
log.warn("Cannot download tile : " + request.url, e);
|
log.warn("Cannot download tile : " + request.url, e);
|
||||||
} finally {
|
} finally {
|
||||||
currentlyDownloaded.remove(request.fileToSave);
|
currentlyDownloaded.remove(request.fileToSave);
|
||||||
|
|
|
@ -105,7 +105,7 @@ public class OsmExtractionUI implements IMapLocationListener {
|
||||||
@Override
|
@Override
|
||||||
public void uncaughtException(Thread t, Throwable e) {
|
public void uncaughtException(Thread t, Throwable e) {
|
||||||
if(!(e instanceof ThreadDeath)){
|
if(!(e instanceof ThreadDeath)){
|
||||||
log.error("Error in thread " + t.getName(), e);
|
ExceptionHandler.handle("Error in thread " + t.getName(), e);
|
||||||
}
|
}
|
||||||
defaultHandler.uncaughtException(t, e);
|
defaultHandler.uncaughtException(t, e);
|
||||||
}
|
}
|
||||||
|
@ -299,13 +299,16 @@ public class OsmExtractionUI implements IMapLocationListener {
|
||||||
|
|
||||||
treeModelListener = new TreeModelListener() {
|
treeModelListener = new TreeModelListener() {
|
||||||
public void treeNodesChanged(TreeModelEvent e) {
|
public void treeNodesChanged(TreeModelEvent e) {
|
||||||
for (Object node : e.getChildren()) {
|
Object node = e.getTreePath().getLastPathComponent();
|
||||||
|
if(e.getChildren() != null && e.getChildren().length > 0){
|
||||||
|
node =e.getChildren()[0];
|
||||||
|
}
|
||||||
if (node instanceof DataExtractionTreeNode) {
|
if (node instanceof DataExtractionTreeNode) {
|
||||||
DataExtractionTreeNode n = ((DataExtractionTreeNode) node);
|
DataExtractionTreeNode n = ((DataExtractionTreeNode) node);
|
||||||
if (n.getModelObject() instanceof MapObject) {
|
if (n.getModelObject() instanceof MapObject) {
|
||||||
MapObject r = (MapObject) n.getModelObject();
|
MapObject r = (MapObject) n.getModelObject();
|
||||||
String newName = n.getUserObject().toString();
|
String newName = n.getUserObject().toString();
|
||||||
if(!r.getName().equals(newName)){
|
if (!r.getName().equals(newName)) {
|
||||||
r.setName(n.getUserObject().toString());
|
r.setName(n.getUserObject().toString());
|
||||||
}
|
}
|
||||||
if (r instanceof Street && !((Street) r).isRegisteredInCity()) {
|
if (r instanceof Street && !((Street) r).isRegisteredInCity()) {
|
||||||
|
@ -316,7 +319,6 @@ public class OsmExtractionUI implements IMapLocationListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
public void treeNodesInserted(TreeModelEvent e) {
|
public void treeNodesInserted(TreeModelEvent e) {
|
||||||
}
|
}
|
||||||
public void treeNodesRemoved(TreeModelEvent e) {
|
public void treeNodesRemoved(TreeModelEvent e) {
|
||||||
|
|
|
@ -330,10 +330,10 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
||||||
float y2 = calcDiffPixelY(tileRect.left - ctilex, tileRect.bottom - ctiley);
|
float y2 = calcDiffPixelY(tileRect.left - ctilex, tileRect.bottom - ctiley);
|
||||||
float y3 = calcDiffPixelY(tileRect.right - ctilex, tileRect.top - ctiley);
|
float y3 = calcDiffPixelY(tileRect.right - ctilex, tileRect.top - ctiley);
|
||||||
float y4 = calcDiffPixelY(tileRect.right - ctilex, tileRect.bottom - ctiley);
|
float y4 = calcDiffPixelY(tileRect.right - ctilex, tileRect.bottom - ctiley);
|
||||||
int l = (int) (Math.min(Math.min(x1, x2), Math.min(x3, x4)) + cx);
|
int l = Math.round(Math.min(Math.min(x1, x2), Math.min(x3, x4)) + cx);
|
||||||
int r = (int) (Math.max(Math.max(x1, x2), Math.max(x3, x4)) + cx);
|
int r = Math.round(Math.max(Math.max(x1, x2), Math.max(x3, x4)) + cx);
|
||||||
int t = (int) (Math.min(Math.min(y1, y2), Math.min(y3, y4)) + cy);
|
int t = Math.round(Math.min(Math.min(y1, y2), Math.min(y3, y4)) + cy);
|
||||||
int b = (int) (Math.max(Math.max(y1, y2), Math.max(y3, y4)) + cy);
|
int b = Math.round(Math.max(Math.max(y1, y2), Math.max(y3, y4)) + cy);
|
||||||
pixelRect.set(l, t, r, b);
|
pixelRect.set(l, t, r, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -426,11 +426,17 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
||||||
|
|
||||||
|
|
||||||
public void tileDownloaded(DownloadRequest request) {
|
public void tileDownloaded(DownloadRequest request) {
|
||||||
if (request == null) {
|
if (request == null || rotate != 0 ) {
|
||||||
|
// if image is rotated call refresh the whole canvas
|
||||||
|
// because we can't find dirty rectangular region but all pixels should be drawn
|
||||||
|
|
||||||
// we don't know exact images were changed
|
// we don't know exact images were changed
|
||||||
refreshMap();
|
refreshMap();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(request.error){
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (request.zoom != this.zoom) {
|
if (request.zoom != this.zoom) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -443,6 +449,7 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
||||||
synchronized (holder) {
|
synchronized (holder) {
|
||||||
tilesRect.set(request.xTile, request.yTile, request.xTile + 1, request.yTile + 1);
|
tilesRect.set(request.xTile, request.yTile, request.xTile + 1, request.yTile + 1);
|
||||||
calculatePixelRectangle(boundsRect, w, h, tileX, tileY, tilesRect);
|
calculatePixelRectangle(boundsRect, w, h, tileX, tileY, tilesRect);
|
||||||
|
|
||||||
if(boundsRect.left > getWidth() || boundsRect.right < 0 || boundsRect.bottom < 0 || boundsRect.top > getHeight()){
|
if(boundsRect.left > getWidth() || boundsRect.right < 0 || boundsRect.bottom < 0 || boundsRect.top > getHeight()){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -452,18 +459,19 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
||||||
try {
|
try {
|
||||||
ResourceManager mgr = ResourceManager.getResourceManager();
|
ResourceManager mgr = ResourceManager.getResourceManager();
|
||||||
Bitmap bmp = mgr.getTileImageForMapSync(map, request.xTile, request.yTile, zoom, false);
|
Bitmap bmp = mgr.getTileImageForMapSync(map, request.xTile, request.yTile, zoom, false);
|
||||||
float x = (request.xTile - getXTile()) * getTileSize() + w;
|
float x = (request.xTile - tileX) * getTileSize() + w;
|
||||||
float y = (request.yTile - getYTile()) * getTileSize() + h;
|
float y = (request.yTile - tileY) * getTileSize() + h;
|
||||||
if (bmp == null) {
|
if (bmp == null) {
|
||||||
drawEmptyTile(canvas, x, y);
|
drawEmptyTile(canvas, x, y);
|
||||||
} else {
|
} else {
|
||||||
canvas.drawBitmap(bmp, x, y, null);
|
canvas.drawBitmap(bmp, x, y, paintBitmap);
|
||||||
}
|
}
|
||||||
drawOverMap(canvas);
|
drawOverMap(canvas);
|
||||||
} finally {
|
} finally {
|
||||||
holder.unlockCanvasAndPost(canvas);
|
holder.unlockCanvasAndPost(canvas);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue