More tracks inside one GPX file

Hi,

my question is refering to following blocks

According to these blocks I can draw gpx file in map component. But often inside one gpx file there are more tracks. Pls check image of sample of gpx file with three tracks.

I would like to ask for guidelines how to make app that will check how many tracks are inside one gpx file and then draw them all in map component.

I tried with “number of items inside list”, but I am able just to count number of coordinates inside first track…

Thx/Mat

You can draw a single polygon from the gpx. Great going Mat. You might be able to get all the traks if you:

  • Convert the gpx file to a geojson file. Possibly use one of these tools.
  • Use the geojson you make to populate the Map FeatureCollection object.

Does that work?

Regards,
Steve

Hi Steve,

thank you for your prompt reply. Unfortunatelly other users will not use any additonal tools to draw gpx…

I was thinking as follows:

As I will not be the only one to use this app, I don’t know how many tracks will gpx file contain. But let say I limit number of track inside gpx file to 3. Therefore, inside one gpx can be 1, 2 or 3 tracks. One track to the mountain, second around the mountain back to the starting point, third alternative path like shortcut etc. to the mountain, any other tracks are ignored.

I can use three linestrings for each track. If there is one track then first linestring with blocks is true, other two are false etc.,

But here is a problem how to find out how many tracks are inside one gpx. My approach was to count how many tags “name” is inside gpx file, as each track has only one name.

I did it with following block. First step is to get text from entire gpx file.

Second step is to count how many “names” is inside gpx file text.

That works great if………. gpx file is small, therefore if gpx is record of short trail. If there is 10 hours long trail gpx file contains more thousand coordinates and proces of counting could take 1 minute or even more which make app useless.

Do you have any idea how to proceed? Maybe somehow to replace all text that is not “name” before counting? Or maybe something completly else?

Thx/Mat

  • App Inventor cannot convert gpx tracks to a FeatureCollection using a native tool. Either do that with Blocks or outside of AI, convert the gpx to a json file (that AI can use)… You already have a basic framework that works but is slow for large gpx files. What you do depends on where your trak information resides and its source.
  • “maybe something completely else?” Here is how App Inventor users can provide traks in their app (not gpx format but they are traks)
    App Inventor GPS Trak Basics . There are two examples (one using Map, the other usin GoogleMaps API) that post a Marker or a series of LineStrings (a trak) on a map either using a timer or on demand.or using the LocationChanged block ( if I remember correctly). This creates an App Inventor compatible trak. Save the List of trak segments to a TinyDB and record your hikes. Later you can recall them.
  • You said “If there is 10 hours long trail gpx file contains more thousand coordinates and process of counting could take 1 minute or even more which make app useless.” … so why are you using gpx files. Provide an app to convert gpx files to a geojson and your users could download the ‘converted gpx’ from a googlespreadsheet or whatever.
  • GPX , or GPS Exchange Format , is an XML schema designed as a common GPS data format. App Inventor can handle xml files, so it might be possible to work with the gpx as a xml. Regardless, in order to post the trak on a Map component, that information must be converted into a LineString or FeatureCollection.
    -GPX format shows what the gpx file looks like.

Hope something here helps you continue your Project development. You may have to either learn to convert gpx to something App Inventor can use or modify your concept of how your app should work.

—Steve

.

GPX because it is common GPS Exchange Format that Garmin and similar popular navigation devices provide.

Therefore, user gets gpx file with its own Garmin device, or download it from web. Then he store it into his mobile phone into internal storage MyDocuments/Track from where app pick it up with ListPicker and draw it with Map component.

Generaly there is one track inside gpx file, but with Garmin’s BaseCamp software user can draw or import a few single tracks/gpx files and then export them as one gpx file etc. Therefore my app must check if there are more tracks inside one gpx file.

Thanks for the explanation about what a gpx file is. Developers will appreciate it.

If you got to use a gpx,use the following advice provided earlier to convert the gpx file to a geojson file . Load the geojson version as a FeatureCollection and the data should display as a trak… Use one of these tools . to convert to a geojson.

Once you convert a gpx file, save it on a googleSpreadsheet so others can use it in your app Mike. You can access a spreadsheet using the Web component. Did you try converting your gpx using the online services; create the geojson and load it as a featureCollection? Converting that way to be the easiest way to get the data from a gpx in a form usable by AI2.

If the user has a Garmin (I have several) he can use the Garmin to use the gpx trak. Garmin has a way to convert the geolocation information into a csv file . I guess this converter provides the lat/lon pairs needed to plot a trak. Consider using the lat/long info to create a linestring. It is not difficult.

You have several options:

  • convert the gpx to a geojson, parse the gpx so you can use the supplementary traks - use the technique you are currently using

  • forget about using gpx and use a linestring trak. Create and save your own traks using the non-standard linestring. This technique works very well.

  • use Garmin’s tool to strip out the coordinate pairs from the gpx into a csv; use the csv to construct an line string trak.

  • extract your data using techniques described for extracting xml data (a gpx is an xml file).

  • you might be able to use javascript within the AI2 app to manipulate the gpx file . Possibly something here

  • someone else might have some other ideas. You might convince an extension developer to create an extension that will do what you want.

    Figure out what you want to do and do it. A word of warning; your 10 hour gpx trak with over 1000 points might not load or post to the OSM Leaflet, even if converted. You can try if you get that far.

Hi Steve,

thx for your ideas. I found better solution,but its not sufficient enought. I managed to reblocked above “names” blocks, so app can now read even large gpx files - like two day hikes. But it is still slow, it takes upto 20 seconds, but without freezing, crushing etc. like before.

Otherwise, I already made hiking app with my own gpx files. My procedure so far is to import gpx into BaseCamp, copy/paste it into Excell where I extract lat/lons in proper form and then copy/paste them into AI blocks. App works very fast even with largest files, but I guess BaseCamp/Excell procedure could be optimised with any other tool as you suggest. Also probaly it is better to store large amount of lat/lons into txt/csv file instead of copy them directly into blocks?

What I am trying to do now is for gpx files that other users will provide as these users will not convert gpxs into any other format. Especially as there are plenty apps like GPX Viewer etc.

Anyway, I will study your ideas, as problem - how many tracks are inside one gpx file - still exists. One approach could be lenght of list where one track is one item. Just dont know how to do it with gpx yet.

Brgds