add restrictions

change rendering strategy

git-svn-id: https://osmand.googlecode.com/svn/trunk@536 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
Victor Shcherb 2010-10-02 12:45:17 +00:00
parent 15622be00e
commit 34753e897a
6 changed files with 124 additions and 55 deletions

View file

@ -7,33 +7,33 @@ package net.osmand;
*/
public class ToDoConstants {
// TODO max 97
// FOR 0.4 beta RELEASE
// ! 89. Transport redesign UI (enable run from context menu, switch go to goal/not) !
// !_25. Add all attributes needed for routing (highway attributes, turn_restrictions)
// !_22. Verify all POI has a point_type (in order to search them) and fix POI issues (!)
// !_29. Fix memory for netherlands map creator
/// PROFILE AND REVIEW Rendering !!!
// - Review Ref on the road on low zooms
// - Fix broken multipolygon
//+-!_28. Rotate crash (progress dialog) [not reproducible]
//+- _18. Fix loading map data in rotated mode (check properly boundaries)
//+ !_1 . VELCOM animation
//+ _30. About screen (Issue)
//+ _30. Bug with landscape (?)
// not required
// POI
// ! 69. Add phone and site information to POI (enable call to POI and open site)
// ! 81. Add some objects to POI category (1) to add them into OSM 2) to help navigation)
// highway (?), traffic_calming (?), barrier(?), military(?-), landuse (?), office(?), man_made(?), power(?),
// railway( station, subway?) - issue 17
// !_22. Verify all POI has a point_type (in order to search them) and fix POI issues (!)
// !_30. Add poi issues
// !_31. Implement stop rendering !!
// !_25. Add all attributes needed for routing (highway attributes, turn_restrictions)
// ! 87. Use network availability for defining loading tiles from internet.
// 96. Introduce settings for MPH, imperial units
// ! 89. Transport redesign UI (enable run from context menu, switch go to goal/not) !
// !_29. Fix memory for netherlands map creator
/// PROFILE AND REVIEW Rendering and map creator!!!
// - Fix broken multipolygon
// - Review Ref on the road on low zooms
// not required
// 96. Introduce settings for MPH, imperial units
// _19. colors for road trunk and motorway
// _12. Fix : find proper location for streets ! centralize them (when create index)?
@ -47,18 +47,19 @@ public class ToDoConstants {
// 94. Revise index to decrease their size (especially address) - replace to float lat/lon and remove for POI
// remove en_names from POI (possibly from address)
///////////////////////////// UNKNOWN STATE ////////////////////
// Unscheduled (complex)
// 65. Intermediate points - for better control routing, to avoid traffic jams ...(?)
// 63. Support simple offline routing(require index file with turn restrictions etc) (?)
// Not clear if it is really needed
// 69. Add phone information to POI
// 66. Transport routing (show next stop, total distance, show stop get out, voice) (needed ?).
// 85. Enable on/off screen for bike navigation (?)
// 83. Add monitoring service to send locations to internet (?)
/////////////////////////// DONE //////////////////////////////
// DONE ANDROID :
// 93. Implement multitype vector objects - building with fence, road & tram ...
// 90. Use Junidecode library on the client for english translation for map rendering

View file

@ -60,7 +60,7 @@ public class BusyIndicator {
animation = new RotateAnimation(0, 360, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
animation.setRepeatCount(Animation.INFINITE);
animation.setInterpolator(new LinearInterpolator());
animation.setDuration(850);
animation.setDuration(1200);
animation.setStartTime(RotateAnimation.START_ON_FIRST_FRAME);
animation.setStartOffset(0);
} else {

View file

@ -202,24 +202,51 @@ public class ResourceManager {
}
// introduce cache in order save memory
private int insertString(char[] ar, int offset, String s) {
for (int j = 0; j < s.length(); j++) {
ar[offset++] = s.charAt(j);
}
return offset;
}
protected StringBuilder builder = new StringBuilder(40);
protected char[] tileId = new char[120];
public synchronized String calculateTileId(ITileSource map, int x, int y, int zoom){
builder.setLength(0);
if(map == null){
builder.append(TEMP_SOURCE_TO_LOAD);
if(false){
// performance improve ?
int ind = 0;
String mapName = map == null ? TEMP_SOURCE_TO_LOAD : map.getName();
ind = insertString(tileId, ind, mapName);
if (map instanceof SQLiteTileSource) {
tileId[ind++] = '@';
} else {
tileId[ind++] = '/';
}
ind = insertString(tileId, ind, Integer.toString(zoom));
tileId[ind++] = '/';
ind = insertString(tileId, ind, Integer.toString(x));
tileId[ind++] = '/';
ind = insertString(tileId, ind, Integer.toString(y));
ind = insertString(tileId, ind, map == null ? ".jpg" : map.getTileFormat()); //$NON-NLS-1$
ind = insertString(tileId, ind, ".tile"); //$NON-NLS-1$
return new String(tileId, 0, ind);
} else {
builder.append(map.getName());
builder.setLength(0);
if (map == null) {
builder.append(TEMP_SOURCE_TO_LOAD);
} else {
builder.append(map.getName());
}
if (map instanceof SQLiteTileSource) {
builder.append('@');
} else {
builder.append('/');
}
builder.append(zoom).append('/').append(x).append('/').append(y)
.append(map == null ? ".jpg" : map.getTileFormat()).append(".tile"); //$NON-NLS-1$ //$NON-NLS-2$
return builder.toString();
}
if(map instanceof SQLiteTileSource){
builder.append('@');
} else {
builder.append('/');
}
builder.append(zoom).append('/').append(x).
append('/').append(y).append(map == null ? ".jpg" : map.getTileFormat()).append(".tile"); //$NON-NLS-1$ //$NON-NLS-2$
String file = builder.toString();
return file;
}
@ -536,6 +563,7 @@ public class ResourceManager {
}
public void updateRendererMap(RectF tileRect, RectF boundsTileRect, int zoom, float rotate){
renderer.interruptLoadingMap();
asyncLoadingTiles.requestToLoadMap(
new MapLoadRequest(tileRect, boundsTileRect, zoom, rotate));
}

View file

@ -44,8 +44,8 @@ public class OsmandApplication extends Application {
public void onCreate(){
super.onCreate();
manager = new ResourceManager(this);
routingHelper = new RoutingHelper(OsmandSettings.getApplicationMode(OsmandApplication.this), OsmandApplication.this, player);
manager = new ResourceManager(this);
uiHandler = new Handler();
startApplication();
}

View file

@ -25,6 +25,7 @@ import net.osmand.osm.MapRenderObject;
import net.osmand.osm.MapRenderingTypes;
import net.osmand.osm.MapUtils;
import net.osmand.osm.MultyPolygon;
import net.osmand.render.OsmandRenderer.RenderingContext;
import org.apache.commons.logging.Log;
@ -57,6 +58,8 @@ public class MapRenderRepositories {
private float cachedRotate = 0;
private Bitmap bmp;
private boolean interrupted = false;
private RenderingContext currentRenderingContext;
public MapRenderRepositories(Context context){
@ -157,9 +160,9 @@ public class MapRenderRepositories {
}
if (!found) {
bounds = getBoundsForIndex(stat, IndexConstants.indexMapLocationsTable);
bounds = getBoundsForIndex(stat, IndexConstants.indexMapLocationsTable2);
if(bounds.left == bounds.right || bounds.bottom == bounds.top){
bounds = getBoundsForIndex(stat, IndexConstants.indexMapLocationsTable2);
bounds = getBoundsForIndex(stat, IndexConstants.indexMapLocationsTable);
if(bounds.left == bounds.right || bounds.bottom == bounds.top){
bounds = getBoundsForIndex(stat, IndexConstants.indexMapLocationsTable3);
}
@ -247,7 +250,24 @@ public class MapRenderRepositories {
" IN (SELECT id FROM "+IndexConstants.indexMapLocationsTable3 + //$NON-NLS-1$
" WHERE ? < maxLat AND ? > minLat AND maxLon > ? AND minLon < ?)"; //$NON-NLS-1$
public void interruptLoadingMap(){
interrupted = true;
if(currentRenderingContext != null){
currentRenderingContext.interrupted = true;
}
}
private boolean checkWhetherInterrupted(){
if(interrupted){
// clear zoom to enable refreshing next time
cZoom = 1;
return true;
}
return false;
}
public synchronized void loadMap(RectF tileRect, RectF boundsTileRect, int zoom, float rotate) {
interrupted = false;
// currently doesn't work properly (every rotate bounds will be outside)
boolean inside = insideBox(boundsTileRect.top, boundsTileRect.left, boundsTileRect.bottom, boundsTileRect.right, zoom);
cRotate = rotate < 0 ? rotate + 360 : rotate;
@ -334,6 +354,9 @@ public class MapRenderRepositories {
for (int k = 0; k < obj.getMultiTypes(); k++) {
registerMultipolygon(multiPolygons, obj.getAdditionalType(k), obj);
}
if(checkWhetherInterrupted()){
return;
}
cObjects.add(obj);
}
@ -346,6 +369,9 @@ public class MapRenderRepositories {
int bottomY = MapUtils.get31TileNumberY(cBottomLatitude);
int topY = MapUtils.get31TileNumberY(cTopLatitude);
List<MultyPolygon> pMulti = proccessMultiPolygons(multiPolygons, leftX, rightX, bottomY, topY);
if(checkWhetherInterrupted()){
return;
}
cObjects.addAll(pMulti);
log.info(String
.format("Search has been done in %s ms. %s results were found.", System.currentTimeMillis() - now, count)); //$NON-NLS-1$
@ -360,7 +386,18 @@ public class MapRenderRepositories {
int width = (int) calcDiffPixelX(cRotate, tileRect.right - tileRect.left, tileRect.bottom - tileRect.top);
int height = (int) calcDiffPixelY(cRotate, tileRect.right - tileRect.left, tileRect.bottom - tileRect.top);
Bitmap bmp = renderer.generateNewBitmap(width, height, tileRect.left, tileRect.top, cObjects, cZoom, cRotate, OsmandSettings.usingEnglishNames(context));
currentRenderingContext = new OsmandRenderer.RenderingContext();
currentRenderingContext.leftX = tileRect.left;
currentRenderingContext.topY = tileRect.top;
currentRenderingContext.zoom = cZoom;
currentRenderingContext.rotate = cRotate;
currentRenderingContext.width = width;
currentRenderingContext.height = height;
Bitmap bmp = renderer.generateNewBitmap(currentRenderingContext, cObjects, OsmandSettings.usingEnglishNames(context));
if(currentRenderingContext.interrupted){
cZoom = 1;
return;
}
Bitmap oldBmp = this.bmp;
this.bmp = bmp;
cachedWaysLoc = newLoc;

View file

@ -100,6 +100,8 @@ public class OsmandRenderer {
}
/*package*/ static class RenderingContext {
public boolean interrupted = false;
List<TextDrawInfo> textToDraw = new ArrayList<TextDrawInfo>();
List<IconDrawInfo> iconsToDraw = new ArrayList<IconDrawInfo>();
@ -254,8 +256,7 @@ public class OsmandRenderer {
}
public Bitmap generateNewBitmap(int width, int height, float leftTileX, float topTileY,
List<MapRenderObject> objects, int zoom, float rotate, boolean useEnglishNames) {
public Bitmap generateNewBitmap(RenderingContext rc, List<MapRenderObject> objects, boolean useEnglishNames) {
long now = System.currentTimeMillis();
// put in order map
int sz = objects.size();
@ -274,22 +275,18 @@ public class OsmandRenderer {
for (int j = 0; j < multiTypes; j++) {
put(orderMap, MapRenderObject.getOrder(o.getAdditionalType(j)), sh + (j + 3), init);
}
if(rc.interrupted){
return null;
}
}
Bitmap bmp = null;
if (objects != null && !objects.isEmpty() && width > 0 && height > 0) {
if (objects != null && !objects.isEmpty() && rc.width > 0 && rc.height > 0) {
// init rendering context
RenderingContext rc = new RenderingContext();
rc.leftX = leftTileX;
rc.topY = topTileY;
rc.zoom = zoom;
rc.rotate = rotate;
rc.width = width;
rc.height = height;
rc.tileDivisor = (int) (1 << (31 - zoom));
rc.cosRotateTileSize = FloatMath.cos((float) Math.toRadians(rotate)) * TILE_SIZE;
rc.sinRotateTileSize = FloatMath.sin((float) Math.toRadians(rotate)) * TILE_SIZE;
bmp = Bitmap.createBitmap(width, height, Config.RGB_565);
rc.tileDivisor = (int) (1 << (31 - rc.zoom));
rc.cosRotateTileSize = FloatMath.cos((float) Math.toRadians(rc.rotate)) * TILE_SIZE;
rc.sinRotateTileSize = FloatMath.sin((float) Math.toRadians(rc.rotate)) * TILE_SIZE;
bmp = Bitmap.createBitmap(rc.width, rc.height, Config.RGB_565);
Canvas cv = new Canvas(bmp);
cv.drawRect(0, 0, bmp.getWidth(), bmp.getHeight(), paintFillEmpty);
@ -307,6 +304,9 @@ public class OsmandRenderer {
drawObj(obj, cv, rc, obj.getAdditionalType(l - 3), false);
}
}
if(rc.interrupted){
return null;
}
}
for(IconDrawInfo icon : rc.iconsToDraw){
if(icon.resId != 0){
@ -318,6 +318,9 @@ public class OsmandRenderer {
cv.drawBitmap(ico, icon.x - ico.getWidth() / 2, icon.y - ico.getHeight() / 2, paintIcon);
}
}
if(rc.interrupted){
return null;
}
}
drawTextOverCanvas(rc, cv, useEnglishNames);
log.info(String.format("Rendering has been done in %s ms. (%s points, %s points inside)", System.currentTimeMillis() - now, //$NON-NLS-1$