strukturart / o.map

Open Street Map app - KaiOS
MIT License
84 stars 15 forks source link

geocaching #5

Closed david-p-s closed 4 years ago

david-p-s commented 4 years ago

Hello.

Just an idea...

Could it be possible to addapt this app in order to play geocaching with an offline map and using a gpx file to set the waypoints? I mean, to make something similar to https://www.cgeo.org/ that works on kaiOS phones.

Thank you.

edit: https://github.com/cgeo/cgeo

strukturart commented 4 years ago

you can use .gpx files and the offline maps must be in geojson format.

david-p-s commented 4 years ago

Thank you for the information. I tried it, but it doesn't seem to work for play geocaching.

The europemap.geojson loads well, but you need to see streets and paths to find the geocache, and I only see blue when I zoomed :-). I tried to find a more detailed map in geojson format but I can't find it. And gpx files in geocaching have all these fields (see the attached file). But only coordinates are really important. You need see at the same time, your position and the cache position in order to find it. :-(

A good thing would be coordinates in DºM.m' format too :-)

I hacked and modified https://www.kaiostech.com/store/apps/?bundle_id=com.redmechanic.gpsmeter for show me my coordinates in that format. Also to show distance in meters and degrees to a coordinates point that the user gives. I also put a link to the geocaching map, and a very simple config menu. Now I was thinking about parsing the gpx files and show... My app works more or less fine, but i need wifi or data to use it with the map. I was thinking to upload my app to bananahackers... but i don't have permission to modify the original app, so I'm afraid of upload it.

These are some of the functions I added to my app (and more for some User Interface that I think that are not interesting...). Maybe you want to use something similar on your nest version of the app:

if (app.gpsCoordRepresentation == "DD") { latDisplay = crd.latitude.toFixed(5); longDisplay = crd.longitude.toFixed(5); } else if (app.gpsCoordRepresentation == "DMS") { var point = new GeoPoint(crd.longitude, crd.latitude); latDisplay = point.getLatDeg(); longDisplay = point.getLonDeg(); } else if (app.gpsCoordRepresentation == "DM") { //DM var latD, latM, lonD, lonM; if(crd.latitude>=0){ latD=Math.floor(crd.latitude); latM=((crd.latitude-Math.floor(crd.latitude))60).toFixed(3); } else{ var latit=Math.abs(crd.latitude); latD=-Math.floor(latit); latM=((latit-Math.floor(latit))60).toFixed(3); } if(crd.longitude>=0){ lonD=Math.floor(crd.longitude);

lonM=((crd.longitude-Math.floor(crd.longitude))60).toFixed(3); } else{ var longit=Math.abs(crd.longitude); lonD=-Math.floor(longit); lonM=((longit-Math.floor(longit))60).toFixed(3); }

  latDisplay = " "+latD+"º "+latM+"'";
  longDisplay = " "+lonD+"º "+lonM+"'";
}

function calculaDistancia(p,g){ var lat1=1.p[0]; var lon1=1.p[1]; var lat2=1.g[0]; var lon2=1.g[1];

//----------------- formula de haversine
var R = 6371000; // metros
var radlat1 = 1.*lat1*Math.PI/180;
var radlat2 = 1.*lat2*Math.PI/180;
var deltaradlat = 1.*(1.*lat2-1.*lat1)*Math.PI/180;
var deltaradlon = 1.*(1.*lon2-1.*lon1)*Math.PI/180;

var a =

1.Math.sin(deltaradlat/2)Math.sin(deltaradlat/2)+Math.cos(radlat1)Math.cos(radlat2)Math.sin(deltaradlon/2)Math.sin(deltaradlon/2); var c = 2.Math.atan2(Math.sqrt(a), Math.sqrt(1-a));

var d = Math.floor(1.*R * c);
//----------------fin de formula de haversine

return d; }

function calculaRumbo(p,g){ var lat1=1.p[0]; var lon1=1.p[1]; var lat2=1.g[0]; var lon2=1.g[1];

//------------------formula bearing

var radlat1 = 1.*lat1*Math.PI/180;
var radlat2 = 1.*lat2*Math.PI/180;
var radlon1 = 1.*lon1*Math.PI/180;
var radlon2 = 1.*lon2*Math.PI/180;

var y = Math.sin(radlon2-radlon1) * this.Math.cos(radlat2);
var x = Math.cos(radlat1)*this.Math.sin(radlat2)

-Math.sin(radlat1)Math.cos(radlat2)Math.cos(radlon2-radlon1); var brng = Math.floor(1.Math.atan2(y, x)180/Math.PI); //------------------fin de fórmula bearing return brng; }

function calcularDestino(mygoal,myGPS){ // note: mygoal is a string with this aspect: "Goto N40º40.400' W6º33.333' " or "Goto N40.40055º W6.33333º " or "Goto N40º40'400" W6º33'333" " var goal_lat_str= mygoal.split(" ")[1]; var goal_lon_str= mygoal.split(" ")[2]; var point=[0, 0]; var gps=[0, 0]; var retorno=[0, 0];

  point[0]=stractValue(goal_lat_str);
  point[1]=stractValue(goal_lon_str);

  gps[0]=myGPS.latitude;
  gps[1]=myGPS.longitude;

  var miDistancia=calculaDistancia(point,gps);
  var miRumbo=calculaRumbo(point,gps);

retorno[0]=miDistancia; retorno[1]=miRumbo;

return retorno; }

http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail Libre de virus. www.avg.com http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

El mar., 28 jul. 2020 a las 15:08, John-David Deubl (< notifications@github.com>) escribió:

you can use .gpx files and the offline maps must be in geojson format.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/strukturart/osm-map/issues/5#issuecomment-665029094, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQNXJN6TL6KGD6HDCID2AXLR53EU3ANCNFSM4PKPVKYQ .

strukturart commented 4 years ago

You need see at the same time, your position and the cache position in order to find it.

You can save markers and then have them shown on the map and at the same time you can see your position. in order to always update your position you have to activate the function with keypad 4. https://github.com/strukturart/osm-map/blob/master/osm-map.json

can you please fork my repo and mod. this part: https://github.com/strukturart/osm-map/blob/e83765f8e94e6c9950f0d5b4bf88b6a63b3a1301/application/app.js#L475 to get an other coordinate system.

strukturart commented 4 years ago

check out the new version, the distance is shown as tooltip at the markers.