Geocaches: How to display the information from the "note" tag?

298 views
Skip to first unread message

Straputsky

unread,
Jul 13, 2011, 3:04:30 PM7/13/11
to Osmand
Hello,
one problem solved, the next steps around. :-)

Thanks to the "How To"-forum I managed to transform the loc file from
groundspeak to an odb format. The geocaches are recognized in the
correct category - so far so good. But I don't know how to display the
information, which is stored in the note tag. This would be very
helpful to find out, which Geocache I'm hunting for, for example:

<tag k='name' v='GC5RMCX'/>
<tag k='note' v='Lumber Mill Stage 6 by Jojo'/>
<tag k='geocache' v='not found'/>

I can see the information vom the tags name and geocache, but not from
the tag note. Where's my mistake?

Rigel Christian

unread,
Jul 13, 2011, 3:22:20 PM7/13/11
to osm...@googlegroups.com
this is pretty much the same problem i've been trying to address.

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.

Straputsky

unread,
Jul 13, 2011, 4:25:27 PM7/13/11
to Osmand
It would be very nice, if this could be adressed. For the time being
one can edit the name tag and add the information from the note tag.
In this case it would look like this:

<tag k='name' v='GC5RMCX Lumber Mill Stage 6 by Jojo'/>
<tag k='note' v='Lumber Mill Stage 6 by Jojo'/>
<tag k='geocache' v='not found'/>

At least it would now display the information. Problem now is: It's
fine for my first few caches, but it would be nice to have a smart
script, which would do this for a larger group of caches. But I'm no
programmer. What seems simple to me, could be a tough thing explaining
to a computer.

First other topic: I suggest to change from "found" and "not found" to
"open" and "closed" or something different, cause the filter is
useless at the moment. Filtering "found" gives you all "not found"
results too.

Second other topic: I don't get an icon if I use "not found". It
appears one when I use "found", maybe I did something wrong, maybe the
icon is missing. If someone can have a look at it, I would be pleased.

Thank you all!

Rigel Christian

unread,
Jul 14, 2011, 2:50:10 AM7/14/11
to osm...@googlegroups.com
Since someone else is suggesting this, I've attached a patch for the
changes i made to the July 8 nightly, in the hopes that they are of
use to someone in spite of how trivial the changes are. is there an
easier way to do this? i would like to know, since i don't know my ass
from a hole in the ground.

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

Victor Shcherb

unread,
Jul 14, 2011, 5:27:52 AM7/14/11
to osm...@googlegroups.com
Why do so difficult?

It can be done on creation step. Just when object is created add ws_note to name.
name="123"
ws_note="Note"
Will go to -> name ="123 Note".

Restructuring database is not in our plan.

Best Regards,
Victor

2011/7/14 Rigel Christian <rig...@gmail.com>

Straputsky

unread,
Jul 14, 2011, 6:04:57 AM7/14/11
to Osmand
OK, the missing icon was an Error-40 (as always ;)

Still: Can we change the value "not_found" to "hidden" or something
else? At the moment, when I use Osmand, there is no possibility to
display the "found" values only. I can filter for "not_found" and all
"found" values won't be displayed. But there is no possibility to
filter for the "found" values only (well, you can, but all not_found
values will be displayed too...).
> > //$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$
> ...
>
> Erfahren Sie mehr »

Victor Shcherb

unread,
Jul 14, 2011, 6:26:31 AM7/14/11
to osm...@googlegroups.com
First of all 

There is explanation how not_found tag is created and how it can be replaced to different. So will probably you find more details about your issue and help others to fix it.

2011/7/14 Straputsky <lungen...@googlemail.com>

Straputsky

unread,
Jul 14, 2011, 7:08:39 AM7/14/11
to Osmand
Oh, I did, That's where my mistake comes from, cause in Issue 265
szims... used 'not found' instead of 'not_found'. I did the same and
that's why I missed the icon. On the other hand I do now know, that I
can use every word I wish. The problem left is, that if I do that,
I'll loose the reference to the icon. But solving this goes far beyond
my capabilities. Simply changing the rendering.xml didn't help.
Yesterday I learned that a jar-file is simply an archive. Well, I
found some "rendering" named xml inside this archive, but changing the
names there didn't have an effect too. So maybe someone with more
experience might solve this.
I think the answer is within Issue 265.


On 14 Jul., 12:26, Victor Shcherb <vics...@gmail.com> wrote:
> First of all
> take a look at existing issueshttp://code.google.com/p/osmand/issues/list?can=1&q=geocache&colspec=...
>
> There is explanation how not_found tag is created and how it can be replaced
> to different. So will probably you find more details about your issue and
> help others to fix it.
>
> 2011/7/14 Straputsky <lungenfil...@googlemail.com>
> ...
>
> Erfahren Sie mehr »

Rigel Christian

unread,
Jul 14, 2011, 1:44:13 PM7/14/11
to osm...@googlegroups.com
i thought there was the possibility i would need to conserve the
number of characters in the field.

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.

Reply all
Reply to author
Forward
0 new messages