GPS Text Output file import to Google Earth or Google Maps.

Anyone know how to import this automatically to google maps or google earth ???
gps.txt file contains the following and is emailed to me every 24hours…I need to be able to
send/save these as KMZ files automatically…

jul/26/2010 14:32: 8 by RouterOS 5.0beta4

software id = SYPQ-LP73

date-and-time: jul/26/2010 04:32:07
longitude: “E xxx x’ xx’'”
latitude: “S xx xx’ xx’'”
altitude: “223.800003m”
speed: “0.000000 km/h”
valid: yes
satellites: 8

Thanks

use gpsvisualizer.com to convert this to normal GPX or KML files:
http://www.gpsvisualizer.com/convert_input?convert_format=gpx

you will first need to convert this to one line, so that data is in columns. probably a script could do that for you.

it would be ideal if you could get that text file like this:

name,desc,latitude,longitude

(or any other way that can be written in one line, separated by some sort of identifiable character, like a comma)

Hi Guys,
I’m looking for someone to write a script for what I am trying to achieve, and I’m willing to send them a 433AH board if they like or pay cash?

I would like a script that would Monitor the GPS Lat/Long, if the unit moves more than 15 meters it would send out a email notification with a link to Google Earth or KMZ file etc…until the unit stops moving…
This script would be running in the background every 5mins or so…
Anyone interested ??? Please leave your contact details here and I will email you…
Cheers

I can’t make scripts, but if anyone can, all that needs to be done is to put the coordinates at end of this string:
http://maps.google.com/?q=

like
http://maps.google.com/?q=N 56° 57.012 E 024° 05.022

Thanks normis, that is kind of what I was looking for but in Google Earth if possible..
Most of our radios are on mining sites where i have to overlay flyover images(maps) into Google Earth as the terrain changes so quickly
So when a repeater trailer is moved Google Earth is much easier to see where it has been moved to…
If the script is only run if the trailers moves more than 25 mtrs this will ease the burden of getting emails for trailers (radios) that haven’t been moved…
…thanks…

What format do you need in your file for Google Earth? I have your file split into lat/long variables in the router, but in the format:
N xx xx’ xx’’
E xxx xx’ xx’’

Whew! I’m all the way up to 9 lines of code, and that includes parsing ‘valid’ out also. You will want to check that before using the coordinates, correct?

ADD: I see the KML format. Give me a bit to convert formats. Check back!

Hi Tim,
The format would have to be in a xml format with the extension of *.kml ,more info here www.earthslot.org/ipy/geassets/nsidc_how2kml4ipy.doc
I’ve attached a kml file of mine if you wish to take a further look into it…its in xml formate but would have to be saved as *.kml from the RB if possible…
Many thanks
Drill 288.xml (1.03 KB)

The only challenge I have is the format conversion to a decimal degree. I have tried the other formats on Google Earth and want to insure the coordinate format works before going any farther. Would you check if standard lat/long coordinates work in the kml file. They are supposed to work.

    <?xml version="1.0" encoding="UTF-8"?>
     <kml xmlns="http://www.opengis.net/kml/2.2">
       <Placemark>
         <name>Simple placemark</name>
         <description>Attached to the ground. Intelligently places itself
            at the height of the underlying terrain.</description>
         <Point>
           <coordinates>E 123 45' 12.3",S 12 34' 56.2"</coordinates>
         </Point>
       </Placemark>
     </kml>

Also, verify the gps file ends each part of the coordinates (denotes seconds) with two single quotes (') rather than a double quote (").

I just went ahead and did the decimal conversion. I tested the coordinate output using coordinates of Destin Airport with Google Maps. It was a good exercise in parsing.

# jul/26/2010 14:32: 8 by RouterOS 5.0beta4
# software id = SYPQ-LP73
#
date-and-time: jul/26/2010 04:32:07
longitude: "W 86 28' 17''"
latitude: "N 30 24' 0''"
altitude: "223.800003m"
speed: "0.000000 km/h"
valid: yes
satellites: 8

…and this is the file output in gps.kml:

   <?xml version="1.0" encoding="UTF-8"?>
     <kml xmlns="http://www.opengis.net/kml/2.2">
       <Placemark>
         <name>My router</name>
         <description>Where is my router?</description>
         <Point>
           <coordinates>+86.4713,+30.4000</coordinates>
         </Point>
       </Placemark>
     </kml>

…and this is the code. You must create a file named gps.kml and upload it to the router prior to use:

:global gpstext [/file get gps.txt contents];
:local longstart [:find $gpstext "longitude" -1];
:local longend [:find $gpstext "\n" $longstart];
:local latstart [:find $gpstext "latitude" -1];
:local latend [:find $gpstext "\n" $latstart];
:local validstart [:find $gpstext "valid" -1];
:local validend [:find $gpstext "\n" $validstart];

:global longitude [:pick $gpstext ($longstart + 12) $longend];
:local degreestart [:find $longitude " " -1];
:local minutestart [:find $longitude " " $degreestart];
:local secondstart [:find $longitude "'" $minutestart];
:local secondend [:find $longitude "'" $secondstart];

:local longdegree;

:if ([:pick $longitude 0 1] = "W") do={:set longdegree "+"} else={:set longdegree "-"};

:set longdegree ($longdegree . [:pick $longitude 2 $minutestart]);
:local longmin [:pick $longitude ($minutestart + 1) $secondstart];
:local longsec [:pick $longitude ($secondstart + 2) $secondend];
:local longfract ((([:tonum $longmin] * 6000) + ([:tonum $longsec] * 100)) / 36);
:global newlong ($longdegree . "." . $longfract);

:global latitude [:pick $gpstext (latstart + 11) $latend];
:set degreestart [:find $latitude " " -1];
:set minutestart [:find $latitude " " $degreestart];
:set secondstart [:find $latitude "'" $minutestart];
:set secondend [:find $latitude "'" $secondstart];

:local latdegree;

:if ([:pick $latitude 0 1] = "N") do={:set latdegree "+"} else={:set latdegree "-"};

:set latdegree ($latdegree . [:pick $latitude 2 $minutestart]);
:local latmin [:pick $latitude ($minutestart + 1) $secondstart];
:local latsec [:pick $latitude ($secondstart + 2) $secondend];
:local latfract ((([:tonum $latmin] * 6000) + ([:tonum $latsec] * 100)) / 36);
:global newlat ($latdegree . "." . $latfract);

:global coordinates ($newlong . "," . $newlat);

:global kmlout "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<kml xmlns=\"http://www.opengis.net/kml/2.2\">
  <Placemark>
    <name>My router</name>
    <description>My router's location</description>
    <Point>
      <coordinates>$coordinates</coordinates>
    </Point>
  </Placemark>
</kml>
";
/file set [/file find name=gps.kml] contents=$kmlout

You owe me at least some karma! :smiley:

ADD There was an error in the code. I corrected it.

Hi Tim
My GPS outputs are “E 148 9’ 49’'” 2 single commas then one double…
I wasn’t able to get it to work in lat and longs either…Hmmmm

Try the new code I posted above. If you post your (or test) coordinates, I will try the conversion with that.

Thanks Tim I will test it right now…My cords are longitude:

“E 148 9’ 49’'”
“S 23 33’ 19’'”
altitude: “208.399994m”

Not sure on how you mean create a gps.kml file and upload to router…
Do you mean with the bottom source code you have in yr post and add it as a file or add the code as part of a script ???

Thanks

There was an error in the code above, two declarations of “latdegree”. It is now corrected.

My bad! There is no “file create” function in this OS. Create a text file with an editor, and save it as gps.kml. Doesn’t matter what is in it. Then upload it to the router. That is the file the code will put the kml code in. I could create the file by “cheating”, but this is easier for me.

I put your coordinates in gps.txt, and this line ended up in gps.kml
-148.1636,-23.5552

ADD: Google Maps puts you in a city called Emerald in Australia.

ADD2: Do you have a plan for getting the file to a web server? TFTP would be my choice. To use it, you must add the file to the tftp server in the router, or it won’t find the file.

Thanks Tim,
I would really love it to be able to send by email if possible.
Only if it moves away from its current position.
My situation is that i have a lot of repeater trailers and need to only now if they have been moved.
A email alert would be much easier then I wouldn’t need another server running..

Emerald was correct also

Add this at the end of the first code:

:global oldpos;

:if ($oldpos != $coordinates) do={
     /tool e-mail
     send to=me@mydomain.com subject="Router move" body="Moved to $coordinates" file=gps.kml
    :set oldpos $coordinates;
};

Change me@mydomain.com to your email address. The server and ‘from’ address must be correct in “/tool e-mail”.

Schedule this script to run as often as you want to check it. It only emails if the last position is different from the current position.

Thanks Tim, I will run some further test, looks good though…

Bear in mind, with no decimal fraction value for the seconds, the accuracy is only to about 30 meters (100’). Just the way the math and the planet work.

Hey mate, it works a treat…and the 30meters is good, it wont email me thinking its moving until it is being towed away etc…
Still playing around with it, but it’s a beautiful thing…