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)
|
||||
// ( 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)
|
||||
// 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),
|
||||
|
@ -40,29 +40,24 @@ public class ToDoConstants {
|
|||
// 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)
|
||||
|
||||
// 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. (?)
|
||||
|
||||
|
||||
// BUGS Android
|
||||
// 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)
|
||||
// 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
|
||||
// 4. Fix issues with big files (such as netherlands) - save memory (!)
|
||||
// Current result : for big file (1 - task 60-80% time, 90% memory)
|
||||
|
||||
// 1. Download tiles without using dir tiles (?)
|
||||
|
||||
|
||||
// BUGS Swing
|
||||
|
||||
// DONE ANDROID :
|
||||
|
||||
// 20. Implement save track/route to gpx
|
||||
|
||||
// DONE SWING
|
||||
|
||||
|
|
|
@ -73,6 +73,7 @@ public class MapTileDownloader {
|
|||
public final int xTile;
|
||||
public final int yTile;
|
||||
public final String url;
|
||||
public boolean error;
|
||||
|
||||
public DownloadRequest(String url, File fileToSave, int xTile, int yTile, int zoom) {
|
||||
this.url = url;
|
||||
|
@ -89,6 +90,10 @@ public class MapTileDownloader {
|
|||
yTile = -1;
|
||||
zoom = -1;
|
||||
}
|
||||
|
||||
public void setError(boolean error){
|
||||
this.error = error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -163,12 +168,16 @@ public class MapTileDownloader {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
if(log.isDebugEnabled()){
|
||||
log.debug("Start downloading tile : " + request.url);
|
||||
}
|
||||
if (request != null && request.fileToSave != null && request.url != null) {
|
||||
long time = System.currentTimeMillis();
|
||||
if(currentlyDownloaded.contains(request.fileToSave)){
|
||||
return;
|
||||
}
|
||||
|
||||
currentlyDownloaded.add(request.fileToSave);
|
||||
if(log.isDebugEnabled()){
|
||||
log.debug("Start downloading tile : " + request.url);
|
||||
}
|
||||
long time = System.currentTimeMillis();
|
||||
try {
|
||||
request.fileToSave.getParentFile().mkdirs();
|
||||
URL url = new URL(request.url);
|
||||
|
@ -189,9 +198,11 @@ public class MapTileDownloader {
|
|||
}
|
||||
} catch (UnknownHostException e) {
|
||||
currentErrors++;
|
||||
request.setError(true);
|
||||
log.error("UnknownHostException, cannot download tile " + request.url + " " + e.getMessage());
|
||||
} catch (IOException e) {
|
||||
currentErrors++;
|
||||
request.setError(true);
|
||||
log.warn("Cannot download tile : " + request.url, e);
|
||||
} finally {
|
||||
currentlyDownloaded.remove(request.fileToSave);
|
||||
|
|
|
@ -105,7 +105,7 @@ public class OsmExtractionUI implements IMapLocationListener {
|
|||
@Override
|
||||
public void uncaughtException(Thread t, Throwable e) {
|
||||
if(!(e instanceof ThreadDeath)){
|
||||
log.error("Error in thread " + t.getName(), e);
|
||||
ExceptionHandler.handle("Error in thread " + t.getName(), e);
|
||||
}
|
||||
defaultHandler.uncaughtException(t, e);
|
||||
}
|
||||
|
@ -299,24 +299,26 @@ public class OsmExtractionUI implements IMapLocationListener {
|
|||
|
||||
treeModelListener = new TreeModelListener() {
|
||||
public void treeNodesChanged(TreeModelEvent e) {
|
||||
for (Object node : e.getChildren()) {
|
||||
if (node instanceof DataExtractionTreeNode) {
|
||||
DataExtractionTreeNode n = ((DataExtractionTreeNode) node);
|
||||
if (n.getModelObject() instanceof MapObject) {
|
||||
MapObject r = (MapObject) n.getModelObject();
|
||||
String newName = n.getUserObject().toString();
|
||||
if(!r.getName().equals(newName)){
|
||||
r.setName(n.getUserObject().toString());
|
||||
}
|
||||
if (r instanceof Street && !((Street) r).isRegisteredInCity()) {
|
||||
DefaultMutableTreeNode parent = ((DefaultMutableTreeNode) n.getParent());
|
||||
parent.remove(n);
|
||||
((DefaultTreeModel) treePlaces.getModel()).nodeStructureChanged(parent);
|
||||
}
|
||||
Object node = e.getTreePath().getLastPathComponent();
|
||||
if(e.getChildren() != null && e.getChildren().length > 0){
|
||||
node =e.getChildren()[0];
|
||||
}
|
||||
if (node instanceof DataExtractionTreeNode) {
|
||||
DataExtractionTreeNode n = ((DataExtractionTreeNode) node);
|
||||
if (n.getModelObject() instanceof MapObject) {
|
||||
MapObject r = (MapObject) n.getModelObject();
|
||||
String newName = n.getUserObject().toString();
|
||||
if (!r.getName().equals(newName)) {
|
||||
r.setName(n.getUserObject().toString());
|
||||
}
|
||||
if (r instanceof Street && !((Street) r).isRegisteredInCity()) {
|
||||
DefaultMutableTreeNode parent = ((DefaultMutableTreeNode) n.getParent());
|
||||
parent.remove(n);
|
||||
((DefaultTreeModel) treePlaces.getModel()).nodeStructureChanged(parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void treeNodesInserted(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 y3 = calcDiffPixelY(tileRect.right - ctilex, tileRect.top - 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 r = (int) (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 b = (int) (Math.max(Math.max(y1, y2), Math.max(y3, y4)) + cy);
|
||||
int l = Math.round(Math.min(Math.min(x1, x2), Math.min(x3, x4)) + cx);
|
||||
int r = Math.round(Math.max(Math.max(x1, x2), Math.max(x3, x4)) + cx);
|
||||
int t = Math.round(Math.min(Math.min(y1, y2), Math.min(y3, y4)) + cy);
|
||||
int b = Math.round(Math.max(Math.max(y1, y2), Math.max(y3, y4)) + cy);
|
||||
pixelRect.set(l, t, r, b);
|
||||
}
|
||||
|
||||
|
@ -426,11 +426,17 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
|
||||
|
||||
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
|
||||
refreshMap();
|
||||
return;
|
||||
}
|
||||
if(request.error){
|
||||
return;
|
||||
}
|
||||
if (request.zoom != this.zoom) {
|
||||
return;
|
||||
}
|
||||
|
@ -443,6 +449,7 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
synchronized (holder) {
|
||||
tilesRect.set(request.xTile, request.yTile, request.xTile + 1, request.yTile + 1);
|
||||
calculatePixelRectangle(boundsRect, w, h, tileX, tileY, tilesRect);
|
||||
|
||||
if(boundsRect.left > getWidth() || boundsRect.right < 0 || boundsRect.bottom < 0 || boundsRect.top > getHeight()){
|
||||
return;
|
||||
}
|
||||
|
@ -452,18 +459,19 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
try {
|
||||
ResourceManager mgr = ResourceManager.getResourceManager();
|
||||
Bitmap bmp = mgr.getTileImageForMapSync(map, request.xTile, request.yTile, zoom, false);
|
||||
float x = (request.xTile - getXTile()) * getTileSize() + w;
|
||||
float y = (request.yTile - getYTile()) * getTileSize() + h;
|
||||
float x = (request.xTile - tileX) * getTileSize() + w;
|
||||
float y = (request.yTile - tileY) * getTileSize() + h;
|
||||
if (bmp == null) {
|
||||
drawEmptyTile(canvas, x, y);
|
||||
} else {
|
||||
canvas.drawBitmap(bmp, x, y, null);
|
||||
canvas.drawBitmap(bmp, x, y, paintBitmap);
|
||||
}
|
||||
drawOverMap(canvas);
|
||||
} finally {
|
||||
holder.unlockCanvasAndPost(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue