small bugfix
git-svn-id: https://osmand.googlecode.com/svn/trunk@62 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
parent
2060618cb8
commit
86395f8bc9
12 changed files with 77 additions and 70 deletions
|
@ -35,6 +35,9 @@ public class ToDoConstants {
|
|||
// 9. Log to see when exception occured(android)
|
||||
// 10. Specify auto-rotating map (compass).
|
||||
// 11. Print out additional info speed, altitude, number of satellites
|
||||
// 12. Show point where are you going (the arrow not the point)
|
||||
// 13. Save point as favourite
|
||||
// 14. Show zoom level directly on map
|
||||
// -------------------
|
||||
|
||||
|
||||
|
@ -44,8 +47,10 @@ public class ToDoConstants {
|
|||
// 2. implement bundle downloading tiles ()
|
||||
// 3. download tiles without using dir tiles
|
||||
// 4. Config file log & see log from file
|
||||
// 6. Predefine what should be extracted from osm (building, poi or roads)
|
||||
// 6. Predefine before file loading what should be extracted from osm (building, poi or roads)
|
||||
// 7. Fix TODO in files (accept amenity - way)
|
||||
// 8. add progress for data generation process
|
||||
// 9. Normalizing streets
|
||||
// 10. Reinvent index mechanism (save in zip file with tile indexes, save city/town addresses separately, read partially !)
|
||||
// 11. Street setName() change in city index!
|
||||
|
||||
}
|
||||
|
|
|
@ -4,17 +4,10 @@ import com.osmand.osm.Entity;
|
|||
|
||||
public class Building extends MapObject<Entity> {
|
||||
|
||||
private Entity e;
|
||||
|
||||
public Building(Entity e){
|
||||
this.e = e;
|
||||
super(e);
|
||||
}
|
||||
|
||||
public Building(){}
|
||||
|
||||
@Override
|
||||
public Entity getEntity() {
|
||||
return e;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -41,12 +41,11 @@ public class City extends MapObject<Node> {
|
|||
}
|
||||
}
|
||||
|
||||
private Node el;
|
||||
private CityType type = null;
|
||||
private Map<String, Street> streets = new TreeMap<String, Street>();
|
||||
|
||||
public City(Node el){
|
||||
this.el = el;
|
||||
super(el);
|
||||
type = CityType.valueFromString(el.getTag(OSMTagKey.PLACE));
|
||||
}
|
||||
|
||||
|
@ -87,11 +86,6 @@ public class City extends MapObject<Node> {
|
|||
return streets.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node getEntity() {
|
||||
return el;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "City [" +type+"] " + getName();
|
||||
|
|
|
@ -10,9 +10,22 @@ public abstract class MapObject<T extends Entity> implements Comparable<MapObjec
|
|||
protected String name = null;
|
||||
protected LatLon location = null;
|
||||
protected Long id = null;
|
||||
|
||||
// could be null
|
||||
public abstract T getEntity();
|
||||
protected T entity = null;
|
||||
|
||||
public MapObject(){}
|
||||
|
||||
public MapObject(T e){
|
||||
entity = e;
|
||||
}
|
||||
|
||||
public T getEntity(){
|
||||
return entity;
|
||||
}
|
||||
|
||||
public void setEntity(T e){
|
||||
entity = e;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
|
|
|
@ -10,15 +10,15 @@ import java.util.Map;
|
|||
|
||||
import com.osmand.Algoritms;
|
||||
import com.osmand.data.City.CityType;
|
||||
import com.osmand.osm.Entity;
|
||||
import com.osmand.osm.LatLon;
|
||||
import com.osmand.osm.MapUtils;
|
||||
import com.osmand.osm.Node;
|
||||
import com.osmand.osm.io.OsmBaseStorage;
|
||||
|
||||
public class Region {
|
||||
public class Region extends MapObject<Entity> {
|
||||
|
||||
private DataTileManager<Amenity> amenities = new DataTileManager<Amenity>();
|
||||
private String name;
|
||||
private OsmBaseStorage storage;
|
||||
|
||||
private static class CityComparator implements Comparator<City>{
|
||||
|
@ -41,8 +41,6 @@ public class Region {
|
|||
this.name = "Region";
|
||||
}
|
||||
|
||||
|
||||
|
||||
public OsmBaseStorage getStorage() {
|
||||
return storage;
|
||||
}
|
||||
|
@ -52,14 +50,6 @@ public class Region {
|
|||
}
|
||||
|
||||
|
||||
public String getName(){
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Collection<City> getCitiesByType(CityType type){
|
||||
return cities.get(type);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ public class Street extends MapObject<Entity> {
|
|||
|
||||
private List<Building> buildings = new ArrayList<Building>();
|
||||
private List<Node> wayNodes = new ArrayList<Node>();
|
||||
private Node center = null;
|
||||
|
||||
public Street(String name){
|
||||
this.name = name;
|
||||
|
@ -37,15 +36,15 @@ public class Street extends MapObject<Entity> {
|
|||
}
|
||||
|
||||
public LatLon getLocation(){
|
||||
if(center == null){
|
||||
if(entity == null){
|
||||
calculateCenter();
|
||||
}
|
||||
return center == null ? null : center.getLatLon();
|
||||
return entity == null ? null : entity.getLatLon();
|
||||
}
|
||||
|
||||
protected void calculateCenter(){
|
||||
if(wayNodes.size() == 1){
|
||||
center = wayNodes.get(0);
|
||||
entity = wayNodes.get(0);
|
||||
return;
|
||||
}
|
||||
LatLon c = MapUtils.getWeightCenterForNodes(wayNodes);
|
||||
|
@ -54,7 +53,7 @@ public class Street extends MapObject<Entity> {
|
|||
if (n != null) {
|
||||
double nd = MapUtils.getDistance(n, c);
|
||||
if (nd < dist) {
|
||||
center = n;
|
||||
entity = n;
|
||||
dist = nd;
|
||||
}
|
||||
}
|
||||
|
@ -71,9 +70,4 @@ public class Street extends MapObject<Entity> {
|
|||
Collections.sort(buildings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity getEntity() {
|
||||
return center;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -311,18 +311,22 @@ public class MapPanel extends JPanel implements IMapDownloaderCallback {
|
|||
|
||||
@Override
|
||||
public void tileDownloaded(DownloadRequest request) {
|
||||
if(request == null){
|
||||
prepareImage(false);
|
||||
return;
|
||||
}
|
||||
int tileSize = getTileSize();
|
||||
double xTileLeft = getXTile() - getSize().width / (2d * tileSize);
|
||||
double yTileUp = getYTile() - getSize().height / (2d * tileSize);
|
||||
int i = request.xTile - (int)xTileLeft;
|
||||
int j = request.yTile - (int)yTileUp;
|
||||
if(request.zoom == this.zoom &&
|
||||
(i >=0 && i<images.length) && (j>=0 && j< images[i].length)){
|
||||
if (request.zoom == this.zoom && (i >= 0 && i < images.length) && (j >= 0 && j < images[i].length)) {
|
||||
try {
|
||||
System.out.println();
|
||||
images[i][j] = getImageFor(request.xTile, request.yTile, zoom, false);
|
||||
repaint();
|
||||
} catch (IOException e) {
|
||||
log.error("Eror reading png " + request.xTile +" " + request.yTile + " zoom : " + zoom, e);
|
||||
log.error("Eror reading png " + request.xTile + " " + request.yTile + " zoom : " + zoom, e);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -260,9 +260,14 @@ public class OsmExtractionUI implements IMapLocationListener {
|
|||
DefaultMutableTreeNode node;
|
||||
node = (DefaultMutableTreeNode)
|
||||
(e.getTreePath().getLastPathComponent());
|
||||
if(node instanceof DataExtractionTreeNode && ((DataExtractionTreeNode) node).getModelObject() instanceof Region){
|
||||
Region r = (Region) ((DataExtractionTreeNode) node).getModelObject();
|
||||
r.setName(node.getUserObject().toString());
|
||||
if(node instanceof DataExtractionTreeNode){
|
||||
if(((DataExtractionTreeNode) node).getModelObject() instanceof Region){
|
||||
Region r = (Region) ((DataExtractionTreeNode) node).getModelObject();
|
||||
r.setName(node.getUserObject().toString());
|
||||
} else if(((DataExtractionTreeNode) node).getModelObject() instanceof MapObject<?>){
|
||||
MapObject<?> r = (MapObject<?>) ((DataExtractionTreeNode) node).getModelObject();
|
||||
r.setName(node.getUserObject().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
public void treeNodesInserted(TreeModelEvent e) {
|
||||
|
@ -726,7 +731,7 @@ public class OsmExtractionUI implements IMapLocationListener {
|
|||
Object node = tree.getLastSelectedPathComponent();
|
||||
if (node instanceof DataExtractionTreeNode) {
|
||||
DataExtractionTreeNode treeNode = (DataExtractionTreeNode) node;
|
||||
if (treeNode.getModelObject() instanceof Region) {
|
||||
if (treeNode.getModelObject() instanceof Region || treeNode.getModelObject() instanceof MapObject<?>) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<resources>
|
||||
<string name="show_poi_over_map_description">Show POI on map</string>
|
||||
<string name="show_poi_over_map">Show POI</string>
|
||||
<string name="map_tile_source_descr">Choose the source of tiles</string>
|
||||
<string name="map_tile_source_descr">Choose the source of tiles:</string>
|
||||
<string name="map_tile_source">Map tile source</string>
|
||||
<string name="map_source">Map source</string>
|
||||
<string name="use_internet">Use internet</string>
|
||||
|
|
|
@ -207,7 +207,8 @@ public class ResourceManager {
|
|||
try {
|
||||
OsmBaseStorage storage = new OsmBaseStorage();
|
||||
stream = new FileInputStream(f);
|
||||
stream = new BufferedInputStream(stream);
|
||||
// stream = new BufferedInputStream(stream);
|
||||
InputStream streamForProgress = stream;
|
||||
if (zipped) {
|
||||
if (stream.read() != 'B' || stream.read() != 'Z') {
|
||||
log.error("Can't read poi file " + f.getAbsolutePath()
|
||||
|
@ -220,7 +221,7 @@ public class ResourceManager {
|
|||
if(progress != null){
|
||||
progress.startTask("Indexing poi " + f.getName(), stream.available());
|
||||
}
|
||||
storage.parseOSM(stream, progress);
|
||||
storage.parseOSM(stream, progress, streamForProgress);
|
||||
for (Entity e : storage.getRegisteredEntities().values()) {
|
||||
if (e instanceof Node && Amenity.isAmenity((Node) e)) {
|
||||
poiIndex.registerObject(((Node)e).getLatitude(), ((Node)e).getLongitude(), new Amenity((Node) e));
|
||||
|
|
|
@ -42,22 +42,22 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
|
|||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
useInternetToDownloadTiles.setChecked(OsmandSettings.isUsingInternetToDownloadTiles(this));
|
||||
showPoiOnMap.setChecked(OsmandSettings.isShowingPoiOverMap(this));
|
||||
super.onResume();
|
||||
useInternetToDownloadTiles.setChecked(OsmandSettings.isUsingInternetToDownloadTiles(this));
|
||||
showPoiOnMap.setChecked(OsmandSettings.isShowingPoiOverMap(this));
|
||||
|
||||
List<TileSourceTemplate> list = TileSourceManager.getKnownSourceTemplates();
|
||||
String[] entries = new String[list.size()];
|
||||
for(int i=0; i<list.size(); i++){
|
||||
entries[i] = list.get(i).getName();
|
||||
}
|
||||
List<TileSourceTemplate> list = TileSourceManager.getKnownSourceTemplates();
|
||||
String[] entries = new String[list.size()];
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
entries[i] = list.get(i).getName();
|
||||
}
|
||||
|
||||
tileSourcePreference.setEntries(entries);
|
||||
tileSourcePreference.setEntryValues(entries);
|
||||
tileSourcePreference.setValue(OsmandSettings.getMapTileSourceName(this));
|
||||
tileSourcePreference.setSummary(tileSourcePreference.getSummary() + "\t\t[" + OsmandSettings.getMapTileSourceName(this)+"]");
|
||||
|
||||
}
|
||||
tileSourcePreference.setEntries(entries);
|
||||
tileSourcePreference.setEntryValues(entries);
|
||||
tileSourcePreference.setValue(OsmandSettings.getMapTileSourceName(this));
|
||||
String mapName = " " +OsmandSettings.getMapTileSourceName(this);
|
||||
tileSourcePreference.setSummary(tileSourcePreference.getSummary() + mapName);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
|
@ -73,6 +73,13 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
|
|||
} else if (preference == tileSourcePreference) {
|
||||
edit.putString(OsmandSettings.MAP_TILE_SOURCES, (String) newValue);
|
||||
edit.commit();
|
||||
String summary = tileSourcePreference.getSummary().toString();
|
||||
if (summary.lastIndexOf(':') != -1) {
|
||||
summary = summary.substring(0, summary.lastIndexOf(':') + 1);
|
||||
}
|
||||
summary += " " + OsmandSettings.getMapTileSourceName(this);
|
||||
tileSourcePreference.setSummary(summary);
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ public class PointLocationLayer implements OsmandMapLayer {
|
|||
private Paint area;
|
||||
|
||||
protected Location lastKnownLocation = null;
|
||||
protected final static int RADIUS = 7;
|
||||
private OsmandMapTileView view;
|
||||
|
||||
private void initUI() {
|
||||
|
@ -52,9 +53,9 @@ public class PointLocationLayer implements OsmandMapLayer {
|
|||
.getAccuracy(), view.getTileSize(), view.getWidth());
|
||||
|
||||
if (locationX >= 0 && locationY >= 0) {
|
||||
canvas.drawCircle(locationX, locationY, 4, location);
|
||||
canvas.drawCircle(locationX, locationY, RADIUS, location);
|
||||
}
|
||||
if (radius > 4) {
|
||||
if (radius > RADIUS) {
|
||||
canvas.drawCircle(locationX, locationY, radius, area);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue