it's possible to give osmand this functionality, but it requires
modifying both the DataExtractionOSM package as well as OsmAnd itself.
otherwise the notes don't get put into the sqlite db.
i'll see if i can manage to post a set of patches that will do this.
perhaps in the future there could be a way to specify to
dataextractionOSM which additional fields should be added to the odb
file? It would also be nice to edit the note, or even attach binaries
like gpspapparazzi.
the references to "ws" are because i was looking to use it in
conjunction with data from a website with those initials. I'm
recruiting people from that website to donate and do testing and bug
reports for the main osmand project; i will be sure to forward on any
worthwhile information if i don't see participation from them on this
list.
From b520fd8accef7dcf5712c8b14a0a487a4cbee5ec Mon Sep 17 00:00:00 2001
From: rigel <rigelc\\at''gmail;;dot,,com>
Date: Thu, 14 Jul 2011 02:31:33 -0400
Subject: [PATCH] changes to add an additional field to the db
---
DataExtractionOSM/src/net/osmand/data/Amenity.java | 17 +++++++++++++++++
.../osmand/data/preparation/IndexPoiCreator.java | 15 ++++++++++++---
.../src/net/osmand/osm/OSMSettings.java | 4 ++++
OsmAnd/res/values/strings.xml | 2 ++
.../net/osmand/plus/AmenityIndexRepositoryOdb.java | 19 +++++++++++++++++--
OsmAnd/src/net/osmand/plus/views/POIMapLayer.java | 5 +++++
6 files changed, 57 insertions(+), 5 deletions(-)
diff --git a/DataExtractionOSM/src/net/osmand/data/Amenity.java
b/DataExtractionOSM/src/net/osmand/data/Amenity.java
index a3b6515..ca176c9 100644
--- a/DataExtractionOSM/src/net/osmand/data/Amenity.java
+++ b/DataExtractionOSM/src/net/osmand/data/Amenity.java
@@ -18,6 +18,9 @@ public class Amenity extends MapObject {
private String openingHours;
private String phone;
private String site;
+ //begin ws
+ private String wsNote;
+ //end ws
public Amenity(Entity entity, AmenityType type, String subtype){
super(entity);
@@ -47,6 +50,10 @@ public class Amenity extends MapObject {
}
}
}
+ //begin ws
+ this.wsNote = entity.getTag(OSMTagKey.WS_NOTE);
+ //end ws
+
}
@Override
@@ -143,6 +150,16 @@ public class Amenity extends MapObject {
this.site = site;
}
+ //begin ws
+ public String getWSNote() {
+ return wsNote;
+ }
+
+ public void setWSNote(String wsNote) {
+ this.wsNote = wsNote;
+ }
+ //end ws
+
public String getPhone() {
return phone;
}
diff --git a/DataExtractionOSM/src/net/osmand/data/preparation/IndexPoiCreator.java
b/DataExtractionOSM/src/net/osmand/data/preparation/IndexPoiCreator.java
index b2e9618..496d6e0 100644
--- a/DataExtractionOSM/src/net/osmand/data/preparation/IndexPoiCreator.java
+++ b/DataExtractionOSM/src/net/osmand/data/preparation/IndexPoiCreator.java
@@ -102,10 +102,12 @@ public class IndexPoiCreator extends
AbstractIndexPartCreator {
poiPreparedStatement.setString(8, amenity.getOpeningHours());
poiPreparedStatement.setString(9, amenity.getSite());
poiPreparedStatement.setString(10, amenity.getPhone());
+ //begin ws
+ poiPreparedStatement.setString(11, amenity.getWSNote());
+ //end ws
addBatch(poiPreparedStatement);
}
-
public void createDatabaseStructure(File poiIndexFile) throws SQLException {
this.poiIndexFile = poiIndexFile;
// delete previous file to save space
@@ -121,6 +123,9 @@ public class IndexPoiCreator extends
AbstractIndexPartCreator {
stat.executeUpdate("create table " + IndexConstants.POI_TABLE
+ //$NON-NLS-1$
"(id bigint, x int, y int, name_en varchar(255), name
varchar(255), " +
"type varchar(255), subtype varchar(255), opening_hours
varchar(255), phone varchar(255), site varchar(255)," +
+ //begin ws
+ " ws_note varchar(255)," +
+ //end ws
"primary key(id, type, subtype))");
stat.executeUpdate("create index poi_loc on poi (x, y, type,
subtype)");
stat.executeUpdate("create index poi_id on poi (id, type, subtype)");
@@ -129,8 +134,12 @@ public class IndexPoiCreator extends
AbstractIndexPartCreator {
// create prepared statment
poiPreparedStatement = poiConnection
- .prepareStatement("INSERT INTO " + IndexConstants.POI_TABLE +
"(id, x, y, name_en, name, type, subtype, opening_hours, site, phone)
" + //$NON-NLS-1$//$NON-NLS-2$
- "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
+// .prepareStatement("INSERT INTO " + IndexConstants.POI_TABLE +
"(id, x, y, name_en, name, type, subtype, opening_hours, site, phone)
" + //$NON-NLS-1$//$NON-NLS-2$
+// "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
+ //begin ws, old version above
+ .prepareStatement("INSERT INTO " + IndexConstants.POI_TABLE +
"(id, x, y, name_en, name, type, subtype, opening_hours, site, phone,
ws_note) " + //$NON-NLS-1$//$NON-NLS-2$
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
+ //end ws
pStatements.put(poiPreparedStatement, 0);
diff --git a/DataExtractionOSM/src/net/osmand/osm/OSMSettings.java
b/DataExtractionOSM/src/net/osmand/osm/OSMSettings.java
index c6f39db..9e58d89 100644
--- a/DataExtractionOSM/src/net/osmand/osm/OSMSettings.java
+++ b/DataExtractionOSM/src/net/osmand/osm/OSMSettings.java
@@ -56,6 +56,10 @@ public class OSMSettings {
WEBSITE("website"), //$NON-NLS-1$
URL("url"), //$NON-NLS-1$
WIKIPEDIA("wikipedia"), //$NON-NLS-1$
+
+ //begin ws
+ WS_NOTE("ws_note"),
+ //end ws
;
private final String value;
diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index 33c034c..a903db2 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -659,4 +659,6 @@
<string name="edit_filter_create_message">Filter {0} has been created</string>
<string name="default_buttons_selectall">Select All</string>
+<string name="ws_note">ws</string>
+
</resources>
diff --git a/OsmAnd/src/net/osmand/plus/AmenityIndexRepositoryOdb.java
b/OsmAnd/src/net/osmand/plus/AmenityIndexRepositoryOdb.java
index 7817ef3..d908724 100644
--- a/OsmAnd/src/net/osmand/plus/AmenityIndexRepositoryOdb.java
+++ b/OsmAnd/src/net/osmand/plus/AmenityIndexRepositoryOdb.java
@@ -40,7 +40,10 @@ public class AmenityIndexRepositoryOdb extends
BaseLocationIndexRepository<Ameni
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 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$
+ //begin ws, previous version above
+ private final String[] columns = new String[]{"id", "x", "y",
"name", "name_en", "type", "subtype", "opening_hours", "phone",
"site", "ws_note"};
//$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$
+ //end ws
public List<Amenity> searchAmenities(double topLatitude, double
leftLongitude, double bottomLatitude, double rightLongitude, int
limit, PoiFilter filter, List<Amenity> amenities){
long now = System.currentTimeMillis();
String squery = "? < y AND y < ? AND ? < x AND x < ?"; //$NON-NLS-1$
@@ -74,6 +77,9 @@ public class AmenityIndexRepositoryOdb extends
BaseLocationIndexRepository<Ameni
am.setOpeningHours(query.getString(7));
am.setPhone(query.getString(8));
am.setSite(query.getString(9));
+ //begin ws
+ am.setWSNote(query.getString(10));
+ //end ws
amenities.add(am);
if(limit != -1 && amenities.size() >= limit){
break;
@@ -106,6 +112,9 @@ public class AmenityIndexRepositoryOdb extends
BaseLocationIndexRepository<Ameni
append(" subtype = ? "). //$NON-NLS-1$
append(" site = ? "). //$NON-NLS-1$
append(" phone = ? "). //$NON-NLS-1$
+ //begin ws
+ append(" ws_note = ? ").
+ //end ws
append(" WHERE append( id = ?"); //$NON-NLS-1$
db.execSQL(b.toString(),
@@ -193,7 +202,10 @@ public class AmenityIndexRepositoryOdb extends
BaseLocationIndexRepository<Ameni
}
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$
+// "(id, x, y, name_en, name, type, subtype, opening_hours, site,
phone) values(?,?,?,?,?,?,?,?,?,?)"); //$NON-NLS-1$
+ //begin ws, old is above
+ "(id, x, y, name_en, name, type, subtype, opening_hours, site,
phone, ws_note) values(?,?,?,?,?,?,?,?,?,?,?)"); //$NON-NLS-1$
+ //end ws
for (Amenity a : amenities) {
stat.bindLong(1, a.getId());
stat.bindDouble(2,
MapUtils.get31TileNumberX(a.getLocation().getLongitude()));
@@ -205,6 +217,9 @@ public class AmenityIndexRepositoryOdb extends
BaseLocationIndexRepository<Ameni
bindString(stat, 8 , a.getOpeningHours());
bindString(stat, 9, a.getSite());
bindString(stat, 10, a.getPhone());
+ //begin ws
+ bindString(stat, 11, a.getWSNote());
+ //end ws
stat.execute();
}
stat.close();
diff --git a/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java
b/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java
index 16bbdeb..ac9721d 100644
--- a/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java
+++ b/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java
@@ -100,6 +100,11 @@ public class POIMapLayer implements
OsmandMapLayer, ContextMenuLayer.IContextMen
if(n.getSite() != null){
format += "\n" + view.getContext().getString(R.string.website) +"
: "+ n.getSite(); //$NON-NLS-1$ //$NON-NLS-2$
}
+ //begin ws
+ if(n.getWSNote() != null){
+ format += "\n" + view.getContext().getString(R.string.ws_note) +"
: "+ n.getWSNote();
+ }
+ //end ws
Toast.makeText(view.getContext(), format, Toast.LENGTH_SHORT).show();
return true;
}
--
1.7.0.4
but i just read that sqlite totally disregards the length number you
assign a varchar, so stuffing 400 characters into a varchar(255) is
acceptable. oh well.