fix small issues
git-svn-id: https://osmand.googlecode.com/svn/trunk@168 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
parent
9b6212b5ed
commit
8b8c7928b2
8 changed files with 57 additions and 32 deletions
|
@ -53,12 +53,16 @@ public class ToDoConstants {
|
|||
// 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. Improvement postal_code search : replace search city <-> postal_code (show streets for postal_code)
|
||||
|
||||
|
||||
// TODO swing
|
||||
// 4. Fix issues with big files (such as netherlands) - save memory (!)
|
||||
// 4. Fix issues with big files (such as netherlands) - save memory (!) - very slow due to transport index !
|
||||
// Current result : for big file (1 - task 60-80% time, 90% memory)
|
||||
// 1. Download tiles without using dir tiles (?)
|
||||
// 5. Improve address indexing (use relations).
|
||||
// Use relation "postal_code" to assign postcodes, use relation "a6" (to accumulate streets!),
|
||||
// "a3" to read all cities & define boundaries for city (& define that street in city).
|
||||
|
||||
// BUGS Swing
|
||||
|
||||
|
|
|
@ -119,10 +119,8 @@ public class DataIndexWriter {
|
|||
Connection conn = DriverManager.getConnection("jdbc:sqlite:"+file.getAbsolutePath());
|
||||
try {
|
||||
Statement stat = conn.createStatement();
|
||||
assert IndexCityTable.values().length == 6;
|
||||
assert IndexBuildingTable.values().length == 6;
|
||||
assert IndexStreetNodeTable.values().length == 5;
|
||||
assert IndexStreetTable.values().length == 6;
|
||||
|
||||
|
||||
|
||||
stat.executeUpdate(IndexConstants.generateCreateSQL(IndexCityTable.values()));
|
||||
stat.executeUpdate(IndexConstants.generateCreateIndexSQL(IndexCityTable.values()));
|
||||
|
@ -136,13 +134,13 @@ public class DataIndexWriter {
|
|||
stat.close();
|
||||
|
||||
PreparedStatement prepCity = conn.prepareStatement(
|
||||
IndexConstants.generatePrepareStatementToInsert(IndexCityTable.getTable(), 6));
|
||||
IndexConstants.generatePrepareStatementToInsert(IndexCityTable.getTable(), IndexCityTable.values().length));
|
||||
PreparedStatement prepStreet = conn.prepareStatement(
|
||||
IndexConstants.generatePrepareStatementToInsert(IndexStreetTable.getTable(), 6));
|
||||
IndexConstants.generatePrepareStatementToInsert(IndexStreetTable.getTable(), IndexStreetTable.values().length));
|
||||
PreparedStatement prepBuilding = conn.prepareStatement(
|
||||
IndexConstants.generatePrepareStatementToInsert(IndexBuildingTable.getTable(), 7));
|
||||
IndexConstants.generatePrepareStatementToInsert(IndexBuildingTable.getTable(), IndexBuildingTable.values().length));
|
||||
PreparedStatement prepStreetNode = conn.prepareStatement(
|
||||
IndexConstants.generatePrepareStatementToInsert(IndexStreetNodeTable.getTable(), 5));
|
||||
IndexConstants.generatePrepareStatementToInsert(IndexStreetNodeTable.getTable(), IndexStreetNodeTable.values().length));
|
||||
Map<PreparedStatement, Integer> count = new HashMap<PreparedStatement, Integer>();
|
||||
count.put(prepStreet, 0);
|
||||
count.put(prepCity, 0);
|
||||
|
@ -155,6 +153,7 @@ public class DataIndexWriter {
|
|||
if(city.getId() == null || city.getLocation() == null){
|
||||
continue;
|
||||
}
|
||||
assert IndexCityTable.values().length == 6;
|
||||
prepCity.setLong(IndexCityTable.ID.ordinal() + 1, city.getId());
|
||||
prepCity.setDouble(IndexCityTable.LATITUDE.ordinal() + 1, city.getLocation().getLatitude());
|
||||
prepCity.setDouble(IndexCityTable.LONGITUDE.ordinal() + 1, city.getLocation().getLongitude());
|
||||
|
@ -163,10 +162,12 @@ public class DataIndexWriter {
|
|||
prepCity.setString(IndexCityTable.CITY_TYPE.ordinal() + 1, CityType.valueToString(city.getType()));
|
||||
addBatch(count, prepCity);
|
||||
|
||||
|
||||
for(Street street : city.getStreets()){
|
||||
if(street.getId() == null || street.getLocation() == null){
|
||||
continue;
|
||||
}
|
||||
assert IndexStreetTable.values().length == 6;
|
||||
prepStreet.setLong(IndexStreetTable.ID.ordinal() + 1, street.getId());
|
||||
prepStreet.setString(IndexStreetTable.NAME_EN.ordinal() + 1, street.getEnName());
|
||||
prepStreet.setDouble(IndexStreetTable.LATITUDE.ordinal() + 1, street.getLocation().getLatitude());
|
||||
|
@ -179,6 +180,7 @@ public class DataIndexWriter {
|
|||
if(n == null){
|
||||
continue;
|
||||
}
|
||||
assert IndexStreetNodeTable.values().length == 5;
|
||||
prepStreetNode.setLong(IndexStreetNodeTable.ID.ordinal() + 1, n.getId());
|
||||
prepStreetNode.setDouble(IndexStreetNodeTable.LATITUDE.ordinal() + 1, n.getLatitude());
|
||||
prepStreetNode.setDouble(IndexStreetNodeTable.LONGITUDE.ordinal() + 1, n.getLongitude());
|
||||
|
@ -193,6 +195,7 @@ public class DataIndexWriter {
|
|||
if(building.getId() == null || building.getLocation() == null){
|
||||
continue;
|
||||
}
|
||||
assert IndexBuildingTable.values().length == 7;
|
||||
prepBuilding.setLong(IndexBuildingTable.ID.ordinal() + 1, building.getId());
|
||||
prepBuilding.setDouble(IndexBuildingTable.LATITUDE.ordinal() + 1, building.getLocation().getLatitude());
|
||||
prepBuilding.setDouble(IndexBuildingTable.LONGITUDE.ordinal() + 1, building.getLocation().getLongitude());
|
||||
|
|
|
@ -248,7 +248,7 @@ public class IndexConstants {
|
|||
}
|
||||
|
||||
public enum IndexBuildingTable implements IndexColumn {
|
||||
ID("long"), LATITUDE("double"), LONGITUDE("double"), NAME, NAME_EN, STREET("long", true), POSTCODE;
|
||||
ID("long"), LATITUDE("double"), LONGITUDE("double"), NAME, NAME_EN, STREET("long", true), POSTCODE(null, true);
|
||||
boolean index = false;
|
||||
String type = null;
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- This file is at /res/layout/list.xml -->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical" android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
|
|
|
@ -12,8 +12,9 @@ import com.osmand.osm.MapUtils;
|
|||
|
||||
public class PoiFilter {
|
||||
|
||||
public static String STD_PREFIX = "std_";
|
||||
public static String USER_PREFIX = "user_";
|
||||
public final static String STD_PREFIX = "std_";
|
||||
public final static String USER_PREFIX = "user_";
|
||||
public final static String CUSTOM_FILTER_ID = USER_PREFIX + "custom_id";
|
||||
|
||||
private Map<AmenityType, List<String>> acceptedTypes = new LinkedHashMap<AmenityType, List<String>>();
|
||||
private String filterByName = null;
|
||||
|
@ -34,9 +35,7 @@ public class PoiFilter {
|
|||
filterId = STD_PREFIX + type;
|
||||
name = type == null ? "Closest poi" : Algoritms.capitalizeFirstLetterAndLowercase(type.name()).replace('_', ' ');
|
||||
if(type == null){
|
||||
for(AmenityType t : AmenityType.values()){
|
||||
acceptedTypes.put(t, null);
|
||||
}
|
||||
initSearchAll();
|
||||
} else {
|
||||
acceptedTypes.put(type, null);
|
||||
}
|
||||
|
@ -50,8 +49,18 @@ public class PoiFilter {
|
|||
}
|
||||
this.filterId = filterId;
|
||||
this.name = name;
|
||||
if(acceptedTypes == null){
|
||||
initSearchAll();
|
||||
} else {
|
||||
this.acceptedTypes.putAll(acceptedTypes);
|
||||
}
|
||||
}
|
||||
|
||||
private void initSearchAll(){
|
||||
for(AmenityType t : AmenityType.values()){
|
||||
acceptedTypes.put(t, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean isSearchFurtherAvailable(){
|
||||
|
@ -185,6 +194,7 @@ public class PoiFilter {
|
|||
return filterId;
|
||||
}
|
||||
|
||||
|
||||
public String getFilterByName() {
|
||||
return filterByName;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.osmand;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -105,25 +106,25 @@ public class PoiFiltersHelper {
|
|||
////ctx.deleteDatabase(PoiFilterDbHelper.DATABASE_NAME);
|
||||
|
||||
cacheUserDefinedFilters = new ArrayList<PoiFilter>();
|
||||
PoiFilter filter = new PoiFilter("Custom filter", PoiFilter.CUSTOM_FILTER_ID, null);
|
||||
cacheUserDefinedFilters.add(filter);
|
||||
PoiFilterDbHelper helper = new PoiFilterDbHelper(ctx);
|
||||
cacheUserDefinedFilters.addAll(helper.getFilters());
|
||||
helper.close();
|
||||
}
|
||||
return cacheUserDefinedFilters;
|
||||
return Collections.unmodifiableList(cacheUserDefinedFilters);
|
||||
}
|
||||
|
||||
private static List<PoiFilter> cacheOsmDefinedFilters;
|
||||
public static List<PoiFilter> getOsmDefinedPoiFilters(Context ctx){
|
||||
if(cacheOsmDefinedFilters == null){
|
||||
cacheOsmDefinedFilters = new ArrayList<PoiFilter>();
|
||||
// TODO for test purposes
|
||||
cacheOsmDefinedFilters.addAll(getUserDefinedPoiFilters(ctx));
|
||||
cacheOsmDefinedFilters.add(new PoiFilter(null));
|
||||
for(AmenityType t : AmenityType.values()){
|
||||
cacheOsmDefinedFilters.add(new PoiFilter(t));
|
||||
}
|
||||
}
|
||||
return cacheOsmDefinedFilters;
|
||||
return Collections.unmodifiableList(cacheOsmDefinedFilters);
|
||||
}
|
||||
|
||||
public static boolean removePoiFilter(Context ctx, PoiFilter filter){
|
||||
|
|
|
@ -37,6 +37,7 @@ public class RegionAddressRepository {
|
|||
private SQLiteDatabase db;
|
||||
private String name;
|
||||
private LinkedHashMap<Long, City> cities = new LinkedHashMap<Long, City>();
|
||||
|
||||
private Map<CityType, List<City>> cityTypes = new HashMap<CityType, List<City>>();
|
||||
|
||||
private boolean useEnglishNames = false;
|
||||
|
@ -335,11 +336,7 @@ public class RegionAddressRepository {
|
|||
query = db.query(IndexBuildingTable.getTable(), IndexConstants.generateColumnNames(IndexBuildingTable.values()), "? = postcode",
|
||||
new String[] { street.getName().toUpperCase()}, null, null, null);
|
||||
} else {
|
||||
IndexBuildingTable[] columns = IndexBuildingTable.values();
|
||||
IndexBuildingTable[] columnsWithoutPostcode = new IndexBuildingTable[columns.length-1];
|
||||
// we don't need postcode information here
|
||||
System.arraycopy(columns, 0, columnsWithoutPostcode, 0, columnsWithoutPostcode.length);
|
||||
query = db.query(IndexBuildingTable.getTable(), IndexConstants.generateColumnNames(columnsWithoutPostcode), "? = street",
|
||||
query = db.query(IndexBuildingTable.getTable(), IndexConstants.generateColumnNames(IndexBuildingTable.values()), "? = street",
|
||||
new String[] { street.getId() + "" }, null, null, null);
|
||||
}
|
||||
log.debug("Start loading buildings for " + street.getName());
|
||||
|
|
|
@ -3,10 +3,12 @@
|
|||
*/
|
||||
package com.osmand.activities.search;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import android.app.ListActivity;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -28,12 +30,18 @@ import com.osmand.R;
|
|||
public class SearchPoiFilterActivity extends ListActivity {
|
||||
|
||||
|
||||
private Typeface typeFace;
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
setContentView(R.layout.searchpoilist);
|
||||
List<PoiFilter> filters = PoiFiltersHelper.getOsmDefinedPoiFilters(this);
|
||||
|
||||
List<PoiFilter> filters = new ArrayList<PoiFilter>(PoiFiltersHelper.getUserDefinedPoiFilters(this)) ;
|
||||
filters.addAll(PoiFiltersHelper.getOsmDefinedPoiFilters(this));
|
||||
setListAdapter(new AmenityAdapter(filters));
|
||||
typeFace = Typeface.create((String)null, Typeface.ITALIC);
|
||||
}
|
||||
|
||||
|
||||
|
@ -61,7 +69,10 @@ public class SearchPoiFilterActivity extends ListActivity {
|
|||
ImageView icon = (ImageView) row.findViewById(R.id.folder_icon);
|
||||
PoiFilter model = getItem(position);
|
||||
label.setText(model.getName());
|
||||
icon.setImageResource(R.drawable.folder);
|
||||
if(model.getFilterId().equals(PoiFilter.CUSTOM_FILTER_ID)){
|
||||
label.setTypeface(typeFace);
|
||||
}
|
||||
icon.setImageResource(model.isStandardFilter() ? R.drawable.folder : R.drawable.favorites);
|
||||
return (row);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue