Remove local poi storage

This commit is contained in:
Victor Shcherb 2013-05-31 17:13:06 +02:00
parent fdb87329c7
commit 174b30ad3a
9 changed files with 5 additions and 518 deletions

View file

@ -18,10 +18,8 @@ import net.osmand.AndroidUtils;
import net.osmand.CallbackWithObject;
import net.osmand.IndexConstants;
import net.osmand.Location;
import net.osmand.PlatformUtil;
import net.osmand.access.AccessibleAlertBuilder;
import net.osmand.access.AccessibleToast;
import net.osmand.data.Amenity;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.map.ITileSource;
@ -39,7 +37,6 @@ import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.Version;
import net.osmand.plus.activities.search.SearchActivity;
import net.osmand.plus.osmedit.AmenityIndexRepositoryOdb;
import net.osmand.plus.routing.RouteProvider.GPXRouteParams;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.BaseMapLayer;
@ -50,7 +47,6 @@ import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.DialogInterface;
@ -68,7 +64,6 @@ import android.os.Bundle;
import android.text.ClipboardManager;
import android.text.Html;
import android.util.FloatMath;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
@ -289,59 +284,6 @@ public class MapActivityActions implements DialogProvider {
return mapActivity.getString(res);
}
protected void updatePoiDb(int zoom, double latitude, double longitude){
if(zoom < 15){
AccessibleToast.makeText(mapActivity, getString(R.string.update_poi_is_not_available_for_zoom), Toast.LENGTH_SHORT).show();
return;
}
final AmenityIndexRepositoryOdb repo = ((OsmandApplication) mapActivity.getApplication()).
getResourceManager().getUpdatablePoiDb();
if(repo == null){
AccessibleToast.makeText(mapActivity, getString(R.string.update_poi_no_offline_poi_index), Toast.LENGTH_LONG).show();
return;
} else {
AccessibleToast.makeText(mapActivity, getString(R.string.update_poi_does_not_change_indexes), Toast.LENGTH_LONG).show();
}
final OsmandMapTileView mapView = mapActivity.getMapView();
Rect pixRect = new Rect(-mapView.getWidth()/2, -mapView.getHeight()/2, 3*mapView.getWidth()/2, 3*mapView.getHeight()/2);
RectF tileRect = new RectF();
mapView.calculateTileRectangle(pixRect, mapView.getCenterPointX(), mapView.getCenterPointY(),
mapView.getXTile(), mapView.getYTile(), tileRect);
final double leftLon = MapUtils.getLongitudeFromTile(zoom, tileRect.left);
final double topLat = MapUtils.getLatitudeFromTile(zoom, tileRect.top);
final double rightLon = MapUtils.getLongitudeFromTile(zoom, tileRect.right);
final double bottomLat = MapUtils.getLatitudeFromTile(zoom, tileRect.bottom);
ProgressDialog progressDlg = ProgressDialog.show(mapActivity, getString(R.string.loading), getString(R.string.loading_data));
mapActivity.setProgressDlg(progressDlg);
new Thread(new Runnable(){
@Override
public void run() {
try {
List<Amenity> amenities = new ArrayList<Amenity>();
boolean loadingPOIs = AmenityIndexRepositoryOdb.loadingPOIs(amenities, leftLon, topLat, rightLon, bottomLat);
if(!loadingPOIs){
showToast(getString(R.string.update_poi_error_loading));
} else {
repo.updateAmenities(amenities, leftLon, topLat, rightLon, bottomLat);
showToast(MessageFormat.format(getString(R.string.update_poi_success), amenities.size()));
mapView.refreshMap();
}
} catch(Exception e) {
Log.e(PlatformUtil.TAG, "Error updating local data", e); //$NON-NLS-1$
showToast(getString(R.string.update_poi_error_local));
} finally {
Dialog prog = mapActivity.getProgressDlg();
if(prog !=null){
prog.dismiss();
mapActivity.setProgressDlg(prog);
}
}
}
}, "LoadingPOI").start(); //$NON-NLS-1$
}
protected void showToast(final String msg){
mapActivity.runOnUiThread(new Runnable(){
@Override
@ -910,12 +852,6 @@ public class MapActivityActions implements DialogProvider {
mapView.refreshMap();
}
});
builder.setNeutralButton(R.string.context_menu_item_update_poi, new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which) {
updatePoiDb(args.getInt(KEY_ZOOM), args.getDouble(KEY_LATITUDE), args.getDouble(KEY_LONGITUDE));
}
});
return builder.create();
}

View file

@ -1,50 +0,0 @@
package net.osmand.plus.osmedit;
import java.util.ArrayList;
import java.util.List;
import net.osmand.data.Amenity;
import net.osmand.osm.MapRenderingTypes;
import net.osmand.osm.edit.EntityParser;
import net.osmand.osm.edit.Node;
import net.osmand.plus.OsmandApplication;
import android.app.Activity;
public abstract class AbstractOpenstreetmapUtil implements OpenstreetmapUtil {
@Override
public void updateNodeInIndexes(Activity ctx, OsmPoint.Action action, Node n, Node oldNode) {
final OsmandApplication app = (OsmandApplication) ctx.getApplication();
final AmenityIndexRepositoryOdb repo = app.getResourceManager().getUpdatablePoiDb();
showMessageAfterCommit(ctx, app, repo);
if (repo == null) {
return;
}
if (oldNode != n) { //if the node has changed its ID, remove the old one
repo.deleteAmenities(oldNode.getId() << 1);
repo.clearCache();
}
// delete all amenities with same id
if (OsmPoint.Action.DELETE == action || OsmPoint.Action.MODIFY == action) {
repo.deleteAmenities(n.getId() << 1);
repo.clearCache();
}
// add amenities
if (OsmPoint.Action.DELETE != action) {
List<Amenity> ams = EntityParser.parseAmenities(MapRenderingTypes.getDefault(), n, new ArrayList<Amenity>());
for (Amenity a : ams) {
repo.addAmenity(a);
repo.clearCache();
}
}
}
protected void showMessageAfterCommit(Activity ctx, final OsmandApplication app, final AmenityIndexRepositoryOdb repo) {
}
}

View file

@ -1,312 +0,0 @@
package net.osmand.plus.osmedit;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import net.osmand.IProgress;
import net.osmand.IndexConstants;
import net.osmand.PlatformUtil;
import net.osmand.ResultMatcher;
import net.osmand.data.Amenity;
import net.osmand.data.AmenityType;
import net.osmand.data.LatLon;
import net.osmand.osm.MapRenderingTypes;
import net.osmand.osm.edit.Entity;
import net.osmand.osm.edit.EntityParser;
import net.osmand.osm.edit.Node;
import net.osmand.osm.io.IOsmStorageFilter;
import net.osmand.osm.io.OsmBaseStorage;
import net.osmand.plus.PoiFilter;
import net.osmand.plus.resources.AmenityIndexRepository;
import net.osmand.plus.resources.BaseLocationIndexRepository;
import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils;
import net.sf.junidecode.Junidecode;
import org.apache.commons.logging.Log;
import org.xml.sax.SAXException;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteStatement;
public class AmenityIndexRepositoryOdb extends BaseLocationIndexRepository<Amenity> implements AmenityIndexRepository {
private static final Log log = PlatformUtil.getLog(AmenityIndexRepositoryOdb.class);
public final static int LIMIT_AMENITIES = 500;
// cache amenities
private String cFilterId;
private final String[] columns = new String[]{"id", "x", "y", "name", "name_en", "type", "subtype", "opening_hours", "phone", "site"}; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$//$NON-NLS-5$//$NON-NLS-6$//$NON-NLS-7$//$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
private boolean changes = false;
@Override
public List<Amenity> searchAmenities(int stop, int sleft, int sbottom, int sright, int zoom, PoiFilter filter,
List<Amenity> amenities, ResultMatcher<Amenity> matcher){
long now = System.currentTimeMillis();
String squery = "? < y AND y < ? AND ? < x AND x < ?"; //$NON-NLS-1$
if(filter != null){
String sql = filter.buildSqlWhereFilter();
if(sql != null){
squery += " AND " + sql; //$NON-NLS-1$
}
}
int limit = -1;
if(zoom != -1){
limit = 200;
squery += " ORDER BY RANDOM() LIMIT 200"; //$NON-NLS-1$
}
Cursor query = db.query(IndexConstants.POI_TABLE, columns, squery,
new String[]{stop+"", //$NON-NLS-1$
sbottom+"", sleft+"", //$NON-NLS-1$ //$NON-NLS-2$
sright+""}, null, null, null); //$NON-NLS-1$
if(query.moveToFirst()){
do {
Amenity am = new Amenity();
am.setId(query.getLong(0));
am.setLocation(MapUtils.get31LatitudeY(query.getInt(2)),
MapUtils.get31LongitudeX(query.getInt(1)));
am.setName(query.getString(3 ));
am.setEnName(query.getString(4));
if(am.getEnName().length() == 0){
am.setEnName(Junidecode.unidecode(am.getName()));
}
am.setType(AmenityType.fromString(query.getString(5)));
am.setSubType(query.getString(6));
am.setOpeningHours(query.getString(7));
am.setPhone(query.getString(8));
am.setSite(query.getString(9));
if (matcher == null || matcher.publish(am)) {
amenities.add(am);
}
if(limit != -1 && amenities.size() >= limit){
break;
}
} while(query.moveToNext());
}
query.close();
if (log.isDebugEnabled()) {
log.debug(String.format("Search for %s done in %s ms found %s.", //$NON-NLS-1$
MapUtils.get31LatitudeY(stop) + " " + MapUtils.get31LongitudeX(sleft), System.currentTimeMillis() - now, amenities.size())); //$NON-NLS-1$
}
return amenities;
}
@Override
public synchronized void clearCache(){
super.clearCache();
cFilterId = null;
}
@Override
public void evaluateCachedAmenities(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude, int zoom,
PoiFilter filter, ResultMatcher<Amenity> matcher) {
cTopLatitude = topLatitude;
cBottomLatitude = bottomLatitude;
cLeftLongitude = leftLongitude;
cRightLongitude = rightLongitude;
cFilterId = filter == null ? null : filter.getFilterId();
cZoom = zoom;
// first of all put all entities in temp list in order to not freeze other read threads
ArrayList<Amenity> tempList = new ArrayList<Amenity>();
int sleft = MapUtils.get31TileNumberX(cLeftLongitude);
int sright = MapUtils.get31TileNumberX(cRightLongitude);
int sbottom = MapUtils.get31TileNumberY(cBottomLatitude);
int stop = MapUtils.get31TileNumberY(cTopLatitude);
searchAmenities(stop, sleft, sbottom, sright, cZoom, filter, tempList, matcher);
synchronized (this) {
cachedObjects.clear();
cachedObjects.addAll(tempList);
}
}
@Override
public synchronized boolean checkCachedAmenities(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude, int zoom, String filterId, List<Amenity> toFill, boolean fillFound){
if (db == null) {
return true;
}
boolean inside = cTopLatitude >= topLatitude && cLeftLongitude <= leftLongitude && cRightLongitude >= rightLongitude
&& cBottomLatitude <= bottomLatitude && zoom == cZoom;
boolean noNeedToSearch = inside && Algorithms.objectEquals(filterId, cFilterId);
if((inside || fillFound) && toFill != null && Algorithms.objectEquals(filterId, cFilterId)){
for(Amenity a : cachedObjects){
LatLon location = a.getLocation();
if (location.getLatitude() <= topLatitude && location.getLongitude() >= leftLongitude && location.getLongitude() <= rightLongitude
&& location.getLatitude() >= bottomLatitude) {
toFill.add(a);
}
}
}
return noNeedToSearch;
}
public boolean checkCachedAmenities(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude, int zoom, String filterId, List<Amenity> toFill){
return checkCachedAmenities(topLatitude, leftLongitude, bottomLatitude, rightLongitude, zoom, filterId, toFill, false);
}
public boolean initialize(final IProgress progress, File file) {
return super.initialize(progress, file, IndexConstants.POI_TABLE_VERSION, IndexConstants.POI_TABLE, true);
}
// Update functionality
public boolean addAmenity(Amenity a){
insertAmenities(Collections.singleton(a));
return true;
}
public boolean updateAmenity(Amenity a){
StringBuilder b = new StringBuilder();
b.append("UPDATE " + IndexConstants.POI_TABLE + " SET "); //$NON-NLS-1$ //$NON-NLS-2$
b.append(" x = ?, "). //$NON-NLS-1$
append(" y = ?, "). //$NON-NLS-1$
append(" opening_hours = ?, "). //$NON-NLS-1$
append(" name = ?, "). //$NON-NLS-1$
append(" name_en = ?, ").//$NON-NLS-1$
append(" type = ?, "). //$NON-NLS-1$
append(" subtype = ? "). //$NON-NLS-1$
append(" site = ? "). //$NON-NLS-1$
append(" phone = ? "). //$NON-NLS-1$
append(" WHERE append( id = ?"); //$NON-NLS-1$
db.execSQL(b.toString(),
new Object[] { MapUtils.get31TileNumberX(a.getLocation().getLongitude()), MapUtils.get31TileNumberY(a.getLocation().getLatitude()),
a.getOpeningHours(), a.getName(), a.getEnName(), AmenityType.valueToString(a.getType()), a.getSubType(),
a.getSite(), a.getPhone(), a.getId()});
changes = true;
return true;
}
public boolean deleteAmenities(long id){
db.execSQL("DELETE FROM " + IndexConstants.POI_TABLE+ " WHERE id="+id); //$NON-NLS-1$ //$NON-NLS-2$
changes = true;
return true;
}
public boolean updateAmenities(List<Amenity> amenities, double leftLon, double topLat, double rightLon, double bottomLat){
int l = MapUtils.get31TileNumberX(leftLon);
int r = MapUtils.get31TileNumberX(rightLon);
int t = MapUtils.get31TileNumberY(topLat);
int b = MapUtils.get31TileNumberY(bottomLat);
db.execSQL("DELETE FROM " + IndexConstants.POI_TABLE + " WHERE " + //$NON-NLS-1$ //$NON-NLS-2$
" x >= ? AND ? >= x AND " + //$NON-NLS-1$
" y >= ? AND ? >= y ", new Integer[] { l, r, t, b }); //$NON-NLS-1$
insertAmenities(amenities);
return true;
}
private void insertAmenities(Collection<Amenity> amenities) {
SQLiteStatement stat = db.compileStatement("DELETE FROM " + IndexConstants.POI_TABLE + " WHERE id = ?"); //$NON-NLS-1$//$NON-NLS-2$
for (Amenity a : amenities) {
stat.bindLong(1, a.getId());
stat.execute();
}
stat.close();
stat = db.compileStatement("INSERT INTO " + IndexConstants.POI_TABLE + //$NON-NLS-1$
"(id, x, y, name_en, name, type, subtype, opening_hours, site, phone) values(?,?,?,?,?,?,?,?,?,?)"); //$NON-NLS-1$
for (Amenity a : amenities) {
stat.bindLong(1, a.getId());
stat.bindDouble(2, MapUtils.get31TileNumberX(a.getLocation().getLongitude()));
stat.bindDouble(3, MapUtils.get31TileNumberY(a.getLocation().getLatitude()));
dataBottomLatitude = Math.min(a.getLocation().getLatitude() - 0.5, dataBottomLatitude);
dataTopLatitude = Math.max(a.getLocation().getLatitude() + 0.5, dataTopLatitude);
dataLeftLongitude = Math.min(a.getLocation().getLongitude() - 0.5, dataLeftLongitude);
dataRightLongitude = Math.max(a.getLocation().getLongitude() + 0.5, dataRightLongitude);
bindString(stat, 4, a.getEnName());
bindString(stat, 5, a.getName());
bindString(stat, 6, AmenityType.valueToString(a.getType()));
bindString(stat, 7, a.getSubType());
bindString(stat, 8 , a.getOpeningHours());
bindString(stat, 9, a.getSite());
bindString(stat, 10, a.getPhone());
stat.execute();
}
stat.close();
updateMaxMinBoundaries(IndexConstants.POI_TABLE);
changes = true;
}
@Override
public boolean hasChange() {
return changes;
}
@Override
public void clearChange() {
changes = false;
}
private final static String SITE_API = "http://api.openstreetmap.org/"; //$NON-NLS-1$
public static void createAmenityIndexRepository(File file) {
SQLiteDatabase db = SQLiteDatabase.openDatabase(file.getAbsolutePath(), null, SQLiteDatabase.CREATE_IF_NECESSARY);
db.execSQL("create table " + IndexConstants.POI_TABLE + //$NON-NLS-1$
"(id bigint, x int, y int, name_en varchar(1024), name varchar(1024), "
+ "type varchar(1024), subtype varchar(1024), opening_hours varchar(1024), phone varchar(1024), site varchar(1024),"
+ "primary key(id, type, subtype))");
db.execSQL("create index poi_loc on poi (x, y, type, subtype)");
db.execSQL("create index poi_id on poi (id, type, subtype)");
db.setVersion(IndexConstants.POI_TABLE_VERSION);
db.close();
}
public static boolean loadingPOIs(List<Amenity> amenities, double leftLon, double topLat, double righLon, double bottomLat) {
try {
// bbox=left,bottom,right,top
String u = SITE_API+"api/0.6/map?bbox="+leftLon+","+bottomLat+","+righLon+","+topLat; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
URL url = new URL(u);
log.info("Start loading poi : " + u); //$NON-NLS-1$
InputStream is = url.openStream();
OsmBaseStorage st = new OsmBaseStorage();
final Map<Amenity, Entity> amen = new LinkedHashMap<Amenity, Entity>();
final List<Amenity> tempList = new ArrayList<Amenity>();
final MapRenderingTypes def = MapRenderingTypes.getDefault();
st.getFilters().add(new IOsmStorageFilter(){
@Override
public boolean acceptEntityToLoad(OsmBaseStorage storage, Entity.EntityId id, Entity entity) {
EntityParser.parseAmenities(def, entity, tempList);
if(!tempList.isEmpty()){
for(Amenity a : tempList){
amen.put(a, entity);
}
tempList.clear();
return true;
}
// to
return entity instanceof Node;
}
});
st.parseOSM(is, null, null, false);
for (Amenity am : amen.keySet()) {
// update location (when all nodes of way are loaded)
EntityParser.parseAmenity(am, amen.get(am));
if(am.getEnName().length() == 0){
am.setEnName(Junidecode.unidecode(am.getName()));
}
amenities.add(am);
}
log.info("Loaded " +amenities.size() + " amenities"); //$NON-NLS-1$//$NON-NLS-2$
} catch (IOException e) {
log.error("Loading nodes failed", e); //$NON-NLS-1$
return false;
} catch (SAXException e) {
log.error("Loading nodes failed", e); //$NON-NLS-1$
return false;
}
return true;
}
}

View file

@ -555,10 +555,7 @@ public class EditingPOIActivity implements DialogProvider {
}
@Override
protected Node doInBackground(Void... params) {
Node node = null;
if ((node = openstreetmapUtil.commitNodeImpl(action, n, info, comment, closeChangeSet)) != null) {
openstreetmapUtil.updateNodeInIndexes(ctx, action, node, n);
}
Node node = openstreetmapUtil.commitNodeImpl(action, n, info, comment, closeChangeSet);
return node;
}
@Override

View file

@ -142,11 +142,6 @@ public class LocalOpenstreetmapActivity extends OsmandListActivity {
OsmPoint info = (OsmPoint) listAdapter.getItem(pos);
if (info.getGroup() == OsmPoint.Group.POI) {
dbpoi.deletePOI((OpenstreetmapPoint) info);
if (info.getAction() == Action.CREATE) {
AmenityIndexRepositoryOdb repo = getMyApplication().getResourceManager().getUpdatablePoiDb();
repo.deleteAmenities(info.getId() << 1);
repo.clearCache();
}
} else if (info.getGroup() == OsmPoint.Group.BUG) {
dbbug.deleteAllBugModifications((OsmNotesPoint) info);
}
@ -327,9 +322,8 @@ public class LocalOpenstreetmapActivity extends OsmandListActivity {
if (OsmPoint.Action.CREATE != p.getAction()) {
entityInfo = remotepoi.loadNode(p.getEntity());
}
Node n;
if ((n = remotepoi.commitNodeImpl(p.getAction(), p.getEntity(), entityInfo, p.getComment(), false)) != null) {
remotepoi.updateNodeInIndexes(LocalOpenstreetmapActivity.this, p.getAction(), n, p.getEntity());
Node n = remotepoi.commitNodeImpl(p.getAction(), p.getEntity(), entityInfo, p.getComment(), false);
if (n != null) {
dbpoi.deletePOI(p);
publishProgress(p);
uploaded++;

View file

@ -3,24 +3,19 @@ package net.osmand.plus.osmedit;
import java.util.Map;
import net.osmand.PlatformUtil;
import net.osmand.access.AccessibleToast;
import net.osmand.data.Amenity;
import net.osmand.data.AmenityType;
import net.osmand.osm.MapRenderingTypes;
import net.osmand.osm.edit.EntityInfo;
import net.osmand.osm.edit.Node;
import net.osmand.osm.edit.OSMSettings.OSMTagKey;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.util.MapUtils;
import org.apache.commons.logging.Log;
import android.app.Activity;
import android.content.Context;
import android.widget.Toast;
public class OpenstreetmapLocalUtil extends AbstractOpenstreetmapUtil {
public class OpenstreetmapLocalUtil implements OpenstreetmapUtil {
private final Context ctx;
private final OpenstreetmapsDbHelper db;
@ -55,21 +50,6 @@ public class OpenstreetmapLocalUtil extends AbstractOpenstreetmapUtil {
return newNode;
}
@Override
protected void showMessageAfterCommit(Activity ctx, final OsmandApplication app, final AmenityIndexRepositoryOdb repo) {
ctx.runOnUiThread(new Runnable() {
@Override
public void run() {
if (repo == null) {
AccessibleToast.makeText(app, app.getString(R.string.update_poi_no_offline_poi_index), Toast.LENGTH_LONG).show();
} else {
AccessibleToast.makeText(app, app.getString(R.string.update_poi_does_not_change_indexes), Toast.LENGTH_LONG).show();
}
}
});
}
@Override
public Node loadNode(Amenity n) {
if(n.getId() % 2 == 1){

View file

@ -35,18 +35,6 @@ import net.osmand.plus.Version;
import net.osmand.util.MapUtils;
import org.apache.commons.logging.Log;
import org.apache.http.HttpResponse;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.xml.sax.SAXException;
import org.xmlpull.v1.XmlSerializer;
@ -55,7 +43,7 @@ import android.util.Xml;
import android.view.View;
import android.widget.Toast;
public class OpenstreetmapRemoteUtil extends AbstractOpenstreetmapUtil {
public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
// private final static String SITE_API = "http://api06.dev.openstreetmap.org/";
private final static String SITE_API = "http://api.openstreetmap.org/"; //$NON-NLS-1$

View file

@ -3,7 +3,6 @@ package net.osmand.plus.osmedit;
import net.osmand.data.Amenity;
import net.osmand.osm.edit.EntityInfo;
import net.osmand.osm.edit.Node;
import android.app.Activity;
public interface OpenstreetmapUtil {
@ -15,5 +14,4 @@ public interface OpenstreetmapUtil {
public Node loadNode(Amenity n);
public void updateNodeInIndexes(Activity ctx, OsmPoint.Action action, Node n, Node oldNode);
}

View file

@ -42,7 +42,6 @@ import net.osmand.plus.RotatedTileBox;
import net.osmand.plus.SQLiteTileSource;
import net.osmand.plus.SearchByNameFilter;
import net.osmand.plus.Version;
import net.osmand.plus.osmedit.AmenityIndexRepositoryOdb;
import net.osmand.plus.render.MapRenderRepositories;
import net.osmand.plus.render.NativeOsmandLibrary;
import net.osmand.plus.resources.AsyncLoadingThread.AmenityLoadRequest;
@ -82,7 +81,6 @@ public class ResourceManager {
private static final Log log = PlatformUtil.getLog(ResourceManager.class);
private static final String MINE_POI_DB = "mine"+ IndexConstants.POI_INDEX_EXT;
protected static ResourceManager manager = null;
@ -131,8 +129,6 @@ public class ResourceManager {
protected boolean internetIsNotAccessible = false;
protected AmenityIndexRepositoryOdb updatablePoiDb = null;
public ResourceManager(OsmandApplication context) {
this.context = context;
this.renderer = new MapRenderRepositories(context);
@ -403,7 +399,6 @@ public class ResourceManager {
// do it lazy
// indexingImageTiles(progress);
warnings.addAll(indexingMaps(progress));
warnings.addAll(indexingPoi(progress));
warnings.addAll(indexVoiceFiles(progress));
warnings.addAll(OsmandPlugin.onIndexingFiles(progress));
@ -668,44 +663,6 @@ public class ResourceManager {
return warnings;
}
// POI INDEX //
private List<String> indexingPoi(final IProgress progress) {
File updatablePoiDbFile = context.getAppPath(MINE_POI_DB);
if(updatablePoiDbFile.exists() && updatablePoiDbFile.canRead()){
tryToOpenUpdatablePoiDb(updatablePoiDbFile);
}
return new ArrayList<String>();
}
public AmenityIndexRepositoryOdb getUpdatablePoiDb() {
if (updatablePoiDb == null) {
File updatablePoiDbFile = context.getAppPath(MINE_POI_DB);
if (!tryToOpenUpdatablePoiDb(updatablePoiDbFile)) {
if (updatablePoiDbFile.exists()) {
updatablePoiDbFile.delete();
}
AmenityIndexRepositoryOdb.createAmenityIndexRepository(updatablePoiDbFile);
tryToOpenUpdatablePoiDb(updatablePoiDbFile);
}
}
return updatablePoiDb;
}
private boolean tryToOpenUpdatablePoiDb(File updatablePoiDbFile) {
try {
AmenityIndexRepositoryOdb odb = new AmenityIndexRepositoryOdb();
boolean initialize = odb.initialize(IProgress.EMPTY_PROGRESS, updatablePoiDbFile);
if (initialize) {
amenityRepositories.add(odb);
this.updatablePoiDb = odb;
return true;
}
} catch (SQLiteException e) {
}
return false;
}
////////////////////////////////////////////// Working with amenities ////////////////////////////////////////////////
public List<Amenity> searchAmenities(PoiFilter filter,
double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude,
@ -870,7 +827,6 @@ public class ResourceManager {
r.close();
}
amenityRepositories.clear();
updatablePoiDb = null;
}
public void closeAddresses(){