Community discussions

MikroTik App
 
brof
newbie
Topic Author
Posts: 48
Joined: Mon Mar 30, 2009 11:30 am
Location: Qld, Australia

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

Mon Jul 26, 2010 10:50 am

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
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 24745
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: GPS Text Output file import to Google Earth or Google Ma

Mon Jul 26, 2010 8:05 pm

use gpsvisualizer.com to convert this to normal GPX or KML files:
http://www.gpsvisualizer.com/convert_in ... 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)
No answer to your question? How to write posts
 
brof
newbie
Topic Author
Posts: 48
Joined: Mon Mar 30, 2009 11:30 am
Location: Qld, Australia

Re: GPS Text Output file import to Google Earth or Google Ma

Wed Jul 28, 2010 1:56 pm

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
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 24745
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: GPS Text Output file import to Google Earth or Google Ma

Wed Jul 28, 2010 2:47 pm

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
No answer to your question? How to write posts
 
brof
newbie
Topic Author
Posts: 48
Joined: Mon Mar 30, 2009 11:30 am
Location: Qld, Australia

Re: GPS Text Output file import to Google Earth or Google Ma

Wed Jul 28, 2010 3:27 pm

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......
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: GPS Text Output file import to Google Earth or Google Ma

Wed Jul 28, 2010 3:56 pm

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!
 
brof
newbie
Topic Author
Posts: 48
Joined: Mon Mar 30, 2009 11:30 am
Location: Qld, Australia

Re: GPS Text Output file import to Google Earth or Google Ma

Wed Jul 28, 2010 4:37 pm

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
You do not have the required permissions to view the files attached to this post.
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: GPS Text Output file import to Google Earth or Google Ma

Wed Jul 28, 2010 7:42 pm

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 (").
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: GPS Text Output file import to Google Earth or Google Ma

Thu Jul 29, 2010 12:04 am

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! :D

ADD There was an error in the code. I corrected it.
Last edited by SurferTim on Thu Jul 29, 2010 12:11 am, edited 1 time in total.
 
brof
newbie
Topic Author
Posts: 48
Joined: Mon Mar 30, 2009 11:30 am
Location: Qld, Australia

Re: GPS Text Output file import to Google Earth or Google Ma

Thu Jul 29, 2010 12:06 am

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
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: GPS Text Output file import to Google Earth or Google Ma

Thu Jul 29, 2010 12:08 am

Try the new code I posted above. If you post your (or test) coordinates, I will try the conversion with that.
 
brof
newbie
Topic Author
Posts: 48
Joined: Mon Mar 30, 2009 11:30 am
Location: Qld, Australia

Re: GPS Text Output file import to Google Earth or Google Ma

Thu Jul 29, 2010 12:09 am

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
Last edited by brof on Thu Jul 29, 2010 12:57 am, edited 1 time in total.
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: GPS Text Output file import to Google Earth or Google Ma

Thu Jul 29, 2010 12:13 am

There was an error in the code above, two declarations of "latdegree". It is now corrected.
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: GPS Text Output file import to Google Earth or Google Ma

Thu Jul 29, 2010 1:13 am

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
<coordinates>-148.1636,-23.5552</coordinates>

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.
 
brof
newbie
Topic Author
Posts: 48
Joined: Mon Mar 30, 2009 11:30 am
Location: Qld, Australia

Re: GPS Text Output file import to Google Earth or Google Ma

Thu Jul 29, 2010 3:54 am

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..
 
brof
newbie
Topic Author
Posts: 48
Joined: Mon Mar 30, 2009 11:30 am
Location: Qld, Australia

Re: GPS Text Output file import to Google Earth or Google Ma

Thu Jul 29, 2010 3:55 am

Emerald was correct also
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: GPS Text Output file import to Google Earth or Google Ma

Thu Jul 29, 2010 4:43 am

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.
 
brof
newbie
Topic Author
Posts: 48
Joined: Mon Mar 30, 2009 11:30 am
Location: Qld, Australia

Re: GPS Text Output file import to Google Earth or Google Ma

Thu Jul 29, 2010 6:06 am

Thanks Tim, I will run some further test, looks good though....
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: GPS Text Output file import to Google Earth or Google Ma

Thu Jul 29, 2010 2:02 pm

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.
 
brof
newbie
Topic Author
Posts: 48
Joined: Mon Mar 30, 2009 11:30 am
Location: Qld, Australia

Re: GPS Text Output file import to Google Earth or Google Ma

Thu Jul 29, 2010 2:05 pm

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...
 
brof
newbie
Topic Author
Posts: 48
Joined: Mon Mar 30, 2009 11:30 am
Location: Qld, Australia

Re: GPS Text Output file import to Google Earth or Google Ma

Thu Jul 29, 2010 2:09 pm

going to try and now link it so i can push it out to the guys on the ground IPhone,, probably maps.Google as the IPhones don't load kml/kmz files...
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: GPS Text Output file import to Google Earth or Google Ma

Thu Jul 29, 2010 2:18 pm

If you read normis' post carefully, you will see how I tested the coordinates. I did not build a kml file. I built a Google maps link instead. Doesn't need a kml file.
 
brof
newbie
Topic Author
Posts: 48
Joined: Mon Mar 30, 2009 11:30 am
Location: Qld, Australia

Re: GPS Text Output file import to Google Earth or Google Ma

Thu Jul 29, 2010 2:23 pm

arr yes i see,,,,
could we include that in the email as well, like in the body ??
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: GPS Text Output file import to Google Earth or Google Ma

Thu Jul 29, 2010 2:32 pm

That is easy, but give me a bit to get the code together. I deleted the Google Maps link generator code when I completed the kml file generator code. I have a business to run while I am not on the forum. :wink:

ADD: I must build coordinates that use 'E', 'W' and 'N', 'S', instead of '+' and '-', but keep the decimal format.
Here is yours from my browser history.
http://maps.google.com/?q=E148.1636S23.5552
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: GPS Text Output file import to Google Earth or Google Ma

Thu Jul 29, 2010 3:13 pm

Here is the new code. Puts a Google Maps link in the email instead of the coordinates. Should be copy-and-paste into the script editor and save as gps (I did anyway). . Change the email address!
: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;
:local longdegreelink;

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

:set longdegree ($longdegree . [:pick $longitude 2 $minutestart]);
:set longdegreelink ($longdegreelink . [: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 newlonglink ($longdegreelink . "." . $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;
:local latdegreelink;

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

:set latdegree ($latdegree . [:pick $latitude 2 $minutestart]);
:set latdegreelink ($latdegreelink . [: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 newlatlink ($latdegreelink . "." . $latfract);

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

:global linkout "http://maps.google.com?q=$newlonglink$newlatlink";

: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>
";

:global oldpos;

:if ($oldpos != $coordinates) do={
    /file set [/file find name=gps.kml] contents=$kmlout
    /tool e-mail
    send to=me@mydomain.com subject="Router move" body="Move to $linkout" file=gps.kml
    :set oldpos $coordinates;
};
I changed a couple minor things too. Now it doesn't write to the file if it isn't going to send the email. Saves write cycles on the memory.

Check back for changes.

EDIT: Changed '+' and '-' to show correct hemisphere in the kml file. :lol:
Last edited by SurferTim on Thu Jul 29, 2010 4:06 pm, edited 3 times in total.
 
brof
newbie
Topic Author
Posts: 48
Joined: Mon Mar 30, 2009 11:30 am
Location: Qld, Australia

Re: GPS Text Output file import to Google Earth or Google Ma

Thu Jul 29, 2010 3:42 pm

great,,,it worked a treat on the Iphone once i remove the "moved to " part
Also I changed the
:if ([:pick $longitude 0 1] = "W") do={
:set longdegree "+";
:set longdegreelink "W";
} else={
:set longdegree "-";
:set longdegreelink "E";

to

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

as the link was in the ocean somewhere lol
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: GPS Text Output file import to Google Earth or Google Ma

Thu Jul 29, 2010 4:00 pm

Made a change, then removed it. Before I change it, do you mean the '+' and '-' is reversed on the coordinates in the kml file?
 
brof
newbie
Topic Author
Posts: 48
Joined: Mon Mar 30, 2009 11:30 am
Location: Qld, Australia

Re: GPS Text Output file import to Google Earth or Google Ma

Thu Jul 29, 2010 4:06 pm

yer the KML file had the cord of 148° 9'48.96"W instead of 148° 9'48.96"E
so i changed the
:if ([:pick $longitude 0 1] = "W") do={ <---- to a E
:set longdegree "+";
:set longdegreelink "W"; <---- to a E
} else={
:set longdegree "-";
:set longdegreelink "E" <----- to a W
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: GPS Text Output file import to Google Earth or Google Ma

Thu Jul 29, 2010 4:08 pm

OK, I changed the '-' and '+' in the code. Same result as switching 'E' and 'W'. Didn't notice when I converted from Google Maps to the kml file. Now it is in the correct hemisphere! :lol:
 
brof
newbie
Topic Author
Posts: 48
Joined: Mon Mar 30, 2009 11:30 am
Location: Qld, Australia

Re: GPS Text Output file import to Google Earth or Google Ma

Thu Jul 29, 2010 4:12 pm

works like a charm :D many many thanks
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: GPS Text Output file import to Google Earth or Google Ma

Thu Jul 29, 2010 6:38 pm

Now in the wiki.
http://wiki.mikrotik.com/wiki/GPS_text_ ... Earth/Maps

ADD: If you are interested, check back at the wiki now and then. I still must add the position valid check.
 
brof
newbie
Topic Author
Posts: 48
Joined: Mon Mar 30, 2009 11:30 am
Location: Qld, Australia

Re: GPS Text Output file import to Google Earth or Google Ma

Thu Jul 29, 2010 7:00 pm

a very much needed wiki,,,,thanks Tim
 
someuser
Member Candidate
Member Candidate
Posts: 102
Joined: Tue Apr 13, 2010 7:05 am

Re: GPS Text Output file import to Google Earth or Google Ma

Mon Aug 02, 2010 5:58 am

Now in the wiki.
http://wiki.mikrotik.com/wiki/GPS_text_ ... Earth/Maps

ADD: If you are interested, check back at the wiki now and then. I still must add the position valid check.
Wow, incredible piece of work Tim!
That has a great many app. possibilites.

I'm waiting for Shark Week :shock:
Any idea which day of the week it shows you on?
My slingbox is down right now, as I don't have TV on my boat (office). I do have internet, All I need.
T
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: GPS Text Output file import to Google Earth or Google Ma

Mon Aug 02, 2010 1:26 pm

I'm waiting for Shark Week :shock:
Any idea which day of the week it shows you on?
The Discovery Channel Guide show it scheduled for August 7th at 10 am Eastern/Pacific.
The moral of the story: If you go to the beach, don't swim out too far!
I rescued three near-drowning victims over the last several years also, but unlike the shark attack victim, all those survived.
 
brof
newbie
Topic Author
Posts: 48
Joined: Mon Mar 30, 2009 11:30 am
Location: Qld, Australia

Re: GPS Text Output file import to Google Earth or Google Ma

Wed Aug 04, 2010 1:21 am

FYI - just a small note, if the GPS unit losses power or is unplugged the RB retains the last set of Lat/Longs its received.
Look at the time and you will notice that its not moving...
Hopefully this could be looked at in a future firmware upgrade as this can be misleading ?? Normis any thoughts??
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: GPS Text Output file import to Google Earth or Google Ma

Wed Aug 04, 2010 1:03 pm

The global variables are reset after a power failure. The files are not.

If you want to avoid receiving an email about moving after a power failure, you should modify the script to check the variable oldpos for an entry. If oldpos is blank (length = 0), the router has been powered down since the last check.

ADD: I thought it was a good idea to let the code send the email if there was a power fail. Since it doesn't remember where it was last check, then it did 'move' from where it thought it was (nowhere).
 
brof
newbie
Topic Author
Posts: 48
Joined: Mon Mar 30, 2009 11:30 am
Location: Qld, Australia

Re: GPS Text Output file import to Google Earth or Google Ma

Fri Sep 10, 2010 1:35 am

About to deploy around 50 of these units over different sites, I will let everyone know the outcome....
Next side of this little project would be to have a static map running on the dude server and somehow getting it to probe each unit and update is location....anyone got any ideas on if this could be done ?
 
xezen
Long time Member
Long time Member
Posts: 628
Joined: Fri May 30, 2008 10:23 am
Location: South Africa

Re: GPS Text Output file import to Google Earth or Google Ma

Mon Dec 27, 2010 12:33 am

that would be cool any updates on this?
If i dont No Ask someone That Does!
 
brof
newbie
Topic Author
Posts: 48
Joined: Mon Mar 30, 2009 11:30 am
Location: Qld, Australia

Re: GPS Text Output file import to Google Earth or Google Ma

Fri Jan 07, 2011 4:55 am

Just conducted my first mobile test and all works very well...
had to make some small changes but the results are great....
 
mchapman
just joined
Posts: 5
Joined: Mon Aug 13, 2007 7:30 pm

Re: GPS Text Output file import to Google Earth or Google Ma

Sun Sep 18, 2011 4:22 pm

Tim,

Would you be willing to modify the code to use Openstreet Maps instead of Google Maps? The reason being Google charges 10,000 dollars to use their maps for asset tracking.

Mike
 
WirelessRudy
Forum Guru
Forum Guru
Posts: 3094
Joined: Tue Aug 08, 2006 5:54 pm
Location: Spain

Re: GPS Text Output file import to Google Earth or Google Ma

Mon Sep 19, 2011 2:27 am

Tim,

Would you be willing to modify the code to use Openstreet Maps instead of Google Maps? The reason being Google charges 10,000 dollars to use their maps for asset tracking.

Mike
Oeps, be prepared to pay him some % of this.... :o
Great topic though!
Show your appreciation of this post by giving me Karma! Thanks.

Rudy R. Puister

WISP operator based on MT routerboard & ROS.
 
David1234
Forum Guru
Forum Guru
Posts: 1301
Joined: Sun Sep 18, 2011 7:00 pm

unable to use GPS text file converter to Google Earth/Maps

Sun May 13, 2012 7:00 pm

hello
I'm trying to use this script - but no good .
I get in google maps that I'm in the middle of the ocean - well I'm not...............
why is it ?
and how can i fix this?

when I open the klm file - I can see that he put this values in the coordinates -4.2 , 2.800

please help ?

Thank you,
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 24745
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: unable to use GPS text file converter to Google Earth/Ma

Mon May 14, 2012 8:28 am

what script?
No answer to your question? How to write posts
 
David1234
Forum Guru
Forum Guru
Posts: 1301
Joined: Sun Sep 18, 2011 7:00 pm

Re: unable to use GPS text file converter to Google Earth/Ma

Mon May 14, 2012 10:21 am

 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 24745
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: unable to use GPS text file converter to Google Earth/Ma

Mon May 14, 2012 10:39 am

What do you see in the "/system gps" menu? Does it show correct coordinates?
Also do you have a gps.txt file in the files folder? You must first make the file with the monitor command:

/system gps monitor file=gps.txt
No answer to your question? How to write posts
 
David1234
Forum Guru
Forum Guru
Posts: 1301
Joined: Sun Sep 18, 2011 7:00 pm

Re: unable to use GPS text file converter to Google Earth/Ma

Mon May 14, 2012 12:44 pm

yes , they are correct.

and I made a file call gps.txt
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 24745
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: unable to use GPS text file converter to Google Earth/Ma

Mon May 14, 2012 12:44 pm

what is inside that file? paste here the full contents
No answer to your question? How to write posts
 
David1234
Forum Guru
Forum Guru
Posts: 1301
Joined: Sun Sep 18, 2011 7:00 pm

Re: unable to use GPS text file converter to Google Earth/Ma

Mon May 14, 2012 1:38 pm

# may/14/2012 13:28:40 by RouterOS 5.7
# software id = XH03-CEG9
#
date-and-time: may/14/2012 10:28:40
latitude: N ** *' **.168''
longitude: E ** **' **.168''
altitude: 59.500000m
speed: 0.000000 km/h
bearing: none
valid: yes
satellites: 4
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 24745
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: GPS Text Output file import to Google Earth or Google Ma

Mon May 14, 2012 1:46 pm

Maybe ask this in the original script topic. I have merged your topic with that one, hopefully the author will be able to help
No answer to your question? How to write posts
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: GPS Text Output file import to Google Earth or Google Ma

Mon May 14, 2012 2:02 pm

I'm the author. What is the problem? Is the hemisphere not correct? Latitude? Longitude?

-4.2 = South latitude 4 degrees 12 minutes (approx)
2.800 = East longitude 2 degrees 48 minutes (approx)
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 24745
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: GPS Text Output file import to Google Earth or Google Ma

Mon May 14, 2012 2:39 pm

I'm the author. What is the problem? Is the hemisphere not correct? Latitude? Longitude?

-4.2 = South latitude 4 degrees 12 minutes (approx)
2.800 = East longitude 2 degrees 48 minutes (approx)
yes, points to the ocean.

David1234, post your actual coordinates, you are hiding them, so we can't see which calculation goes wrong
No answer to your question? How to write posts
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: GPS Text Output file import to Google Earth or Google Ma

Mon May 14, 2012 3:00 pm

@mchapman: I missed your post about OpenStreetMaps. I took a look at the site, but haven't found the format yet. If you are still interested in that, let me know.

I found and tested the format for OpenStreetMaps, and the conversion seems very simple. You would use the same decimal format as Google Maps, just sent a little different. Here is the conversion of the lat/long of the current "ocean" location.
http://www.openstreetmap.org/
?lat=-4.2&lon=2.800&zoom=4&layers=M

Adjust the "zoom" number to zoom in. It will take zoom numbers up to 19.
edit: I split the link into two parts so you can see the format easier.
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: GPS Text Output file import to Google Earth or Google Ma

Mon May 14, 2012 5:26 pm

There was a bug in the creation of the Google Maps URL. There is now a plus sign between the latitude and longitude. I also added the link in the email for OpenStreetMaps.

The wiki article has been corrected, but I have no GPS to check it real time. I am going by gps.txt files donated by users. Please let me know if this corrects the problem.
http://wiki.mikrotik.com/wiki/GPS_text_ ... Earth/Maps

Here is the gps.txt file I used. It is the Destin, Florida airport.
# 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' 26''"
latitude: "N 30 24' 00''"
altitude: "223.800003m"
speed: "0.000000 km/h"
valid: yes
satellites: 8
The seconds in the lat/long is not a double quote("), It is two single quotes (').
 
David1234
Forum Guru
Forum Guru
Posts: 1301
Joined: Sun Sep 18, 2011 7:00 pm

Re: GPS Text Output file import to Google Earth or Google Ma

Tue May 15, 2012 10:47 am

this is what I get in the E-mail
Move to http://maps.google.com?q=E4.8500S2.833
this is what I get in the kml file
-4.8500,-2.833

and this is the lat/long from the gps

latitude: N 32 5' 21.12''
longitude: E 34 51' 29.12''

thanks ,
 
David1234
Forum Guru
Forum Guru
Posts: 1301
Joined: Sun Sep 18, 2011 7:00 pm

Re: GPS Text Output file import to Google Earth or Google Ma

Tue May 15, 2012 11:57 am

one more thing:
when I try to run the script
in the terminal
I get
admin@3GRouter] > :global kmlout "<xml version=\"1.0\" encoding=\"UTF-8\">
[admin@3GRouter] > <kml xmlns=\"http://www.opengis.net/kml/2.2\">
expected command name (line 1 column 1)
[admin@3GRouter] > <Placemark>
expected command name (line 1 column 3)
[admin@3GRouter] > <name>My router</name>
expected command name (line 1 column 5)
[admin@3GRouter] > <description>Mobiles location</description>
expected command name (line 1 column 5)
[admin@3GRouter] > <Point>
expected command name (line 1 column 5)
[admin@3GRouter] > <coordinates>$coordinates</coordinates>
expected command name (line 1 column 7)
[admin@3GRouter] > </Point>
expected command name (line 1 column 5)
[admin@3GRouter] > </Placemark>
expected command name (line 1 column 3)
[admin@3GRouter] > </kml>
expected command name (line 1 column 1)
[admin@3GRouter] > ";
expected command name (line 1 column 1)
[admin@3GRouter] >
[admin@3GRouter] > :if (valid) do={
{... :global oldpos;
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 24745
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: GPS Text Output file import to Google Earth or Google Ma

Tue May 15, 2012 12:03 pm

why did you just paste an XML file in the console? you are not supposed to be doing that
No answer to your question? How to write posts
 
David1234
Forum Guru
Forum Guru
Posts: 1301
Joined: Sun Sep 18, 2011 7:00 pm

Re: GPS Text Output file import to Google Earth or Google Ma

Tue May 15, 2012 12:06 pm

which xml file?
where do I need to put him and from where is he?

* all I saw is to create 2 files :gps.txt , gps.kml
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: GPS Text Output file import to Google Earth or Google Ma

Tue May 15, 2012 1:42 pm

I edited the wiki code yesterday. It has changed since you downloaded it. If you use the new code on the wiki, you should get this in the email with the gps.kml attachment. The gps.txt file I used had the coordinates for Destin airport.
Note the plus sign (+) between the lat and lon, and the openstreetmap link.

I recommend downloading the code again. There were other changes I made to remove an incorrect hemisphere bug.

edit: If you still have trouble, post your entire gps.txt file. I will try that here and see if I can debug it.
 
David1234
Forum Guru
Forum Guru
Posts: 1301
Joined: Sun Sep 18, 2011 7:00 pm

Re: GPS Text Output file import to Google Earth or Google Ma

Tue May 15, 2012 5:07 pm

it's doesn't work for me
give me many errors
I have' copy it and when I try to run it
this is what I get

:global gpstext [/file get gps.txt contents];
[admin@3GRouter] > :local longstart [:find $gpstext "longitude" -1];
[admin@3GRouter] > :local longend [:find $gpstext "\n" $longstart];
syntax error (line 1 column 38)
[admin@3GRouter] > :local latstart [:find $gpstext "latitude" -1];
[admin@3GRouter] > :local latend [:find $gpstext "\n" $latstart];
syntax error (line 1 column 37)
[admin@3GRouter] > :local validstart [:find $gpstext "valid" -1];
[admin@3GRouter] > :local validend [:find $gpstext "\n" $validstart];
syntax error (line 1 column 39)
[admin@3GRouter] > :local valid false;
[admin@3GRouter] >
[admin@3GRouter] > :if ([:find $gpstext "yes" $validstart] > 0) do={:set valid tru
e;};
syntax error (line 1 column 29)
[admin@3GRouter] >
[admin@3GRouter] >
[admin@3GRouter] > :global longitude [:pick $gpstext ($longstart + 12) $longend];
syntax error (line 1 column 37)
[admin@3GRouter] > :local degreestart [:find $longitude " " -1];
syntax error (line 1 column 28)
[admin@3GRouter] > :local minutestart [:find $longitude " " $degreestart];
syntax error (line 1 column 28)
[admin@3GRouter] > :local secondstart [:find $longitude "'" $minutestart];
syntax error (line 1 column 28)
[admin@3GRouter] > :local secondend [:find $longitude "'" $secondstart];
syntax error (line 1 column 26)
[admin@3GRouter] >
[admin@3GRouter] > :local longdegree;
[admin@3GRouter] > :local longdegreelink;
[admin@3GRouter] >
[admin@3GRouter] > :if ([:pick $longitude 0 1] = "W") do={
syntax error (line 1 column 14)
[admin@3GRouter] > :set longdegree "-";
expected variable name (line 1 column 10)
[admin@3GRouter] > :set longdegreelink "W";
expected variable name (line 1 column 10)
[admin@3GRouter] > } else={
[admin@3GRouter] > :set longdegree "+";
expected variable name (line 1 column 10)
[admin@3GRouter] > :set longdegreelink "E";
expected variable name (line 1 column 10)
[admin@3GRouter] > };
[admin@3GRouter] >
[admin@3GRouter] > :set longdegree ($longdegree . [:pick $longitude 2 $minutestart
]);
expected variable name (line 1 column 6)
[admin@3GRouter] > :set longdegreelink ($longdegreelink . [:pick $longitude 2 $min
utestart]);
expected variable name (line 1 column 6)
[admin@3GRouter] > :local longmin [:pick $longitude ($minutestart + 1) $secondstar
t];
syntax error (line 1 column 24)
[admin@3GRouter] > :local longsec [:pick $longitude ($secondstart + 2) $secondend]
;
syntax error (line 1 column 24)
[admin@3GRouter] > :local longfract ((([:tonum $longmin] * 6000) + ([:tonum $longs
ec] * 100)) / 36);
syntax error (line 1 column 30)
[admin@3GRouter] > :global newlong ($longdegree . "." . $longfract);
syntax error (line 1 column 19)
[admin@3GRouter] > :global newlonglink ($longdegreelink . "." . $longfract);
syntax error (line 1 column 23)
[admin@3GRouter] >
[admin@3GRouter] > :global latitude [:pick $gpstext (latstart + 11) $latend];
syntax error (line 1 column 51)
[admin@3GRouter] > :set degreestart [:find $latitude " " -1];
expected variable name (line 1 column 6)
[admin@3GRouter] > :set minutestart [:find $latitude " " $degreestart];
expected variable name (line 1 column 6)
[admin@3GRouter] > :set secondstart [:find $latitude "'" $minutestart];
expected variable name (line 1 column 6)
[admin@3GRouter] > :set secondend [:find $latitude "'" $secondstart];
expected variable name (line 1 column 6)
[admin@3GRouter] >
[admin@3GRouter] > :local latdegree;
[admin@3GRouter] > :local latdegreelink;
[admin@3GRouter] >
[admin@3GRouter] > :if ([:pick $latitude 0 1] = "N") do={
syntax error (line 1 column 14)
[admin@3GRouter] > :set latdegree "+";
expected variable name (line 1 column 10)
[admin@3GRouter] > :set latdegreelink "N";
expected variable name (line 1 column 10)
[admin@3GRouter] > } else={
[admin@3GRouter] > :set latdegree "-";
expected variable name (line 1 column 10)
[admin@3GRouter] > :set latdegreelink "S";
expected variable name (line 1 column 10)
[admin@3GRouter] > };
[admin@3GRouter] >
[admin@3GRouter] > :set latdegree ($latdegree . [:pick $latitude 2 $minutestart]);

expected variable name (line 1 column 6)
[admin@3GRouter] > :set latdegreelink ($latdegreelink . [:pick $latitude 2 $minute
start]);
expected variable name (line 1 column 6)
[admin@3GRouter] > :local latmin [:pick $latitude ($minutestart + 1) $secondstart]
;
syntax error (line 1 column 23)
[admin@3GRouter] > :local latsec [:pick $latitude ($secondstart + 2) $secondend];
syntax error (line 1 column 23)
[admin@3GRouter] > :local latfract ((([:tonum $latmin] * 6000) + ([:tonum $latsec]
* 100)) / 36);
syntax error (line 1 column 29)
[admin@3GRouter] > :global newlat ($latdegree . "." . $latfract);
syntax error (line 1 column 18)
[admin@3GRouter] > :global newlatlink ($latdegreelink . "." . $latfract);
syntax error (line 1 column 22)
[admin@3GRouter] >
[admin@3GRouter] > :global coordinates ($newlong . "," . $newlat);
syntax error (line 1 column 23)
[admin@3GRouter] >
[admin@3GRouter] > :global linkout "http://maps.google.com

<name> -- name of the new global variable
<value> -- new value of variable


[admin@3GRouter] > :global linkout "http://maps.google.comq=$newlonglink+$newlatli
nk";
expected end of command (line 1 column 42)
[admin@3GRouter] > :global SMlinkout "http://www.openstreetmap.org/

<name> -- name of the new global variable
<value> -- new value of variable


[admin@3GRouter] > :global SMlinkout "http://www.openstreetmap.org/lat=$newlat&lon
=$newlong&zoom=8&layers=M";
expected end of command (line 1 column 53)
[admin@3GRouter] >
[admin@3GRouter] > :global kmlout "<

<name> -- name of the new global variable
<value> -- new value of variable


[admin@3GRouter] > :global kmlout "<xml version=\"1.0\" encoding=\"UTF-8\"

<name> -- name of the new global variable
<value> -- new value of variable


[admin@3GRouter] > :global kmlout "<xml version=\"1.0\" encoding=\"UTF-8\">
[admin@3GRouter] > <kml xmlns=\"http://www.opengis.net/kml/2.2\">
expected command name (line 1 column 1)
[admin@3GRouter] > <Placemark>
expected command name (line 1 column 3)
[admin@3GRouter] > <name>My router</name>
expected command name (line 1 column 5)
[admin@3GRouter] > <description>My router's location</description>
expected command name (line 1 column 5)
[admin@3GRouter] > <Point>
expected command name (line 1 column 5)
[admin@3GRouter] > <coordinates>$coordinates</coordinates>
expected command name (line 1 column 7)
[admin@3GRouter] > </Point>
expected command name (line 1 column 5)
[admin@3GRouter] > </Placemark>
expected command name (line 1 column 3)
[admin@3GRouter] > </kml>
expected command name (line 1 column 1)
[admin@3GRouter] > ";
expected command name (line 1 column 1)
[admin@3GRouter] >
[admin@3GRouter] > :if (valid) do={
{... :global oldpos;
{...
{... :if ($oldpos != $coordinates) do={
syntax error (line 4 column 22)
[admin@3GRouter] > /file set [/file find name=gps.kml] contents=$kmlout
[admin@3GRouter] > /tool e-mail
[admin@3GRouter] /tool e-mail> send to=$email subject="Router move" body="
Move to $linkout\r\n$SMlinkout" file=gps.kml
syntax error (line 1 column 18)
[admin@3GRouter] /tool e-mail> :set oldpos $coordinates;
expected variable name (line 1 column 14)
[admin@3GRouter] /tool e-mail> };
[admin@3GRouter] /tool e-mail> } else={
[admin@3GRouter] /tool e-mail> /tool e-mail
[admin@3GRouter] /tool e-mail> send to=$email subject="Router gps positio
n invalid" body="Router gps position invalid"
syntax error (line 1 column 19)
[admin@3GRouter] /tool e-mail> };


how can it be?
what have I done wrong?
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: GPS Text Output file import to Google Earth or Google Ma

Tue May 15, 2012 5:10 pm

Give me a few minutes to check the code. I may have made a typo or two editing the code. I will download that copy and check it.

Add: I checked it and did find one error. The Google maps URL had the lat and lon backwards (latitude is supposed to be first), but should not have cause your errors. I changed that and the email address, and it worked. I modified the wiki code again just now to switch the two variables. It should have been this.
:global linkout "http://maps.google.com?q=$newlatlink+$newlonglink";
 
David1234
Forum Guru
Forum Guru
Posts: 1301
Joined: Sun Sep 18, 2011 7:00 pm

Re: GPS Text Output file import to Google Earth or Google Ma

Tue May 15, 2012 5:41 pm

o.k

I have run the script - and now he sent me an E-mail
but again put me in the middle of the ocean

this is the E-mail I got

Move to http://maps.google.com?q=E4.8500+S2.833
http://www.openstreetmap.org/?lat=-2.83 ... 8&layers=M

this is the kml file:

<?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>+4.8500,-2.833</coordinates>
</Point>
</Placemark>
</kml>


this is the gps monitor :
ate-and-time: may/15/2012 14:37:21
latitude: N 32 5' 21.312''
longitude: E 34 51' 29.312''
altitude: 83.500000m
speed: 0.000000 km/h
bearing: none

valid: yes
satellites: 4


and this is the value of kmlout:
"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>+4.8500,-2.833</coordinates>
</Point>
</Placemark>
</kml>
"
"longitude"=" 34 51' 28.748''" --- this is O.k
"newlong"="+4.8500"
"newlonglink"="E4.8500"
"latitude"=" 32 5' 20.748''" --- this is O.K
"newlat"="-2.833"
"newlatlink"="S2.833"
"coordinates"="+4.8500,-2.833"
"linkout"="http://maps.google.com?q=E4.8500+S2.833"
"SMlinkout"="http://www.openstreetmap.org/?lat=-2.83 ... 8&layers=M
"oldpos"="+4.8500,-2.833"



maybe it will help you more
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: GPS Text Output file import to Google Earth or Google Ma

Tue May 15, 2012 5:48 pm

I think I found it. It appears to be the lack of the double quotes around the latitude and longitude values in the gps.txt file. I got the same "ocean" location. I will post again when I get it fixed.
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: GPS Text Output file import to Google Earth or Google Ma

Tue May 15, 2012 6:02 pm

I can tell you how to fix your code, but I want to check with Mikrotik support before making a change to the wiki. The earlier examples of gps.txt file had double quotes surrounding the latitude and longitude. Without the quotes, the index of the array is off 1 character, and it does not get the hemispheres N/S or E/W.

Replace these two declarations
:global longitude [:pick $gpstext (longstart + 12) $longend];
:global latitude [:pick $gpstext (latstart + 11) $latend];
with these.
:global longitude [:pick $gpstext (longstart + 11) $longend];
:global latitude [:pick $gpstext (latstart + 10) $latend];
Note the index is decremented by one.
 
David1234
Forum Guru
Forum Guru
Posts: 1301
Joined: Sun Sep 18, 2011 7:00 pm

Re: GPS Text Output file import to Google Earth or Google Ma

Tue May 15, 2012 6:26 pm

still no good
it's closer to my location from the middle of the ocean

this is what I get in the kml file

<?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>+34.8500,+32.833</coordinates>
</Point>
</Placemark>
</kml>


why we can't use the gps coordinate as they are? I mean the
atitude: N 32 5' 21.216''
longitude: E 34 51' 30.216''

?
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: GPS Text Output file import to Google Earth or Google Ma

Tue May 15, 2012 6:30 pm

why we can't use the gps coordinate as they are? I mean the
latitude: N 32 5' 21.216''
longitude: E 34 51' 30.216''
You can if you wish in the kml file. I don't use that file, so I haven't checked it lately. I use only the links. How do the links do? Are they close?

edit: I did not mean to sound like I was not going to fix the kml file, but I want to insure we have the location correct first. :)

OK, I lied. I guess you can't use the standard coordinates in the kml file. Here is the docs on that.
https://developers.google.com/kml/documentation/kml_tut
Read the Placemark section.
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: GPS Text Output file import to Google Earth or Google Ma

Tue May 15, 2012 9:01 pm

I found the problem. It was the lack of leading zeros on the fractional part of the latitude and longitude. My bad. I presume by the new output you are not in the ocean, but somewhere near Tel Aviv?
It is not +32.833. It is +32.0833

I put all the changes in the wiki.

BTW, I checked the gps.kml file. Google Earth says you are in the same place. :D
 
David1234
Forum Guru
Forum Guru
Posts: 1301
Joined: Sun Sep 18, 2011 7:00 pm

Re: GPS Text Output file import to Google Earth or Google Ma

Wed May 16, 2012 9:58 am

sorry - but still not good.

this is my location by the gps :
E 34 51' 28.748'' N 32 5' 20.748''

this is what your script bring my :
+34.8500,+32.0833

you can see that - it's not the same place ///
can you see why is it ?

if you don't have power to deal with this anymore - I understand , maybe we can do it simpler -
with no conversion.
just to sent a link to google with the values from the gps monitor
like so
Move to http://maps.google.com?q=E34 51' 29.168'' N32 5' 21.168''
and if there is no gps signal - to send the normal E-mail Router gps position invalid

what do I need to change in your script to do this?

Thank you ,
Last edited by David1234 on Wed May 16, 2012 10:06 am, edited 1 time in total.
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 24745
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: GPS Text Output file import to Google Earth or Google Ma

Wed May 16, 2012 10:05 am

What should be actual coordinates:
32.089097, 34.857986

Tims script results in:
+34.8500,+32.0833

looks like they are the other way around ;)
No answer to your question? How to write posts
 
David1234
Forum Guru
Forum Guru
Posts: 1301
Joined: Sun Sep 18, 2011 7:00 pm

Re: GPS Text Output file import to Google Earth or Google Ma

Wed May 16, 2012 10:26 am

this is much better
but I have a deviation of ~5km (A - is what the script bring me , B is my real location)
, from where I am to what he show me (in the regular coordinate I get it right )

http://maps.google.com/maps?saddr=HaGef ... m&t=m&z=15
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: GPS Text Output file import to Google Earth or Google Ma

Wed May 16, 2012 1:17 pm

When I enter the latitude and longitude you posted in Google maps:
N32 5' 20.748'' E34 51' 28.748''
I get position B, not A.

My code says you are at position B. Click these links. It was generated by my code.
http://maps.google.com?q=N32.0891+E34.8580
http://www.openstreetmap.org/?lat=+32.0 ... 8&layers=M

Google Earth gps.kml file also says position B, exactly the position displayed by Google Maps and OpenStreetView.

@normis: The lat/lon is lon/lat (backwards) in the kml file. Weird!

EDIT: I just checked your new lat/lon above, and it puts you at position A. If I remove the decimal fraction from the seconds, I get the correct position.

I'll post again when I get that corrected. You have been a big help in debugging this. Thanks.
 
David1234
Forum Guru
Forum Guru
Posts: 1301
Joined: Sun Sep 18, 2011 7:00 pm

Re: GPS Text Output file import to Google Earth or Google Ma

Wed May 16, 2012 4:23 pm

no- thank you ,
you did all the hard work - I'm just want to work with it.

so whenever it will be ready - can you tell me ?

Thanks again,
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: GPS Text Output file import to Google Earth or Google Ma

Wed May 16, 2012 4:36 pm

Good news! It is ready now. I just uploaded the new code to the wiki. It did not convert the decimal fraction seconds number correctly. I have added a couple routines that also increased the accuracy. I was trying to round to the nearest second, and that is the section of code that was incorrect. Now it is to the 10th of a second accuracy, and it seems to work. :D

Try it and let me know how it works.

add: Technically it evaluates the 10th second value, but once the multiply/divide functions are complete, it will be accuracy at about 1/3 second. And if you need more accuracy than that. I just added the actual coordinates returned from the GPS as the first line. The two links are now on the second and third lines.

I also heard from tech support. They say that maybe early versions of the GPS function may have put double quotes around the coordinates. If that is the case for you, support recommends upgrading to a newer version.
 
David1234
Forum Guru
Forum Guru
Posts: 1301
Joined: Sun Sep 18, 2011 7:00 pm

Re: GPS Text Output file import to Google Earth or Google Ma

Thu May 17, 2012 4:16 pm

I'm sorry to tell you but now it's all not good
I get e-mail "Router gps position invalid"
and when I enter the terminal
(the gps monitor is :
date-and-time: may/17/2012 13:15:38
latitude: N 32 5' 20.658''
longitude: E 34 51' 29.658''
altitude: 40.000000m
speed: 0.000000 km/h
bearing: none
valid: yes
satellites: 5
)

this is what I see /environment print

"longitude"="-1];
"newlong"="+].0166"
"newlonglink"="E].0166"
"latitude"="-1];
"newlat"="-].0166"
"newlatlink"="S].0166"
"coordinates"="+].0166,-].0166"
"linkout"="http://maps.google.com?q=S].0166+E].0166"


this is weird no?
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: GPS Text Output file import to Google Earth or Google Ma

Thu May 17, 2012 4:41 pm

That would be the response if the program did not find or was unable to load gps.txt, or the valid was not "yes". This is the contents of the gps.txt I used.
date-and-time: may/17/2012 13:15:38
latitude: N 32 5' 20.658''
longitude: E 34 51' 29.658''
altitude: 40.000000m
speed: 0.000000 km/h
bearing: none
valid: yes
satellites: 5
Here is the output using that file and the code directly from the wiki, replacing only the email address:
If you get that response, it means something may be wrong with the gps.txt file. See if it is the correct size. It should not be very big.
/file print
If it seems large (bigger than 4095 bytes), remove it.
 
David1234
Forum Guru
Forum Guru
Posts: 1301
Joined: Sun Sep 18, 2011 7:00 pm

Re: GPS Text Output file import to Google Earth or Google Ma

Thu May 17, 2012 5:02 pm

now it is working !!!!!
Great job!

but one small thing is not working
why doesn't him send me en E-mail every 1 min? I have put the script in the scheduler for 1 min - and I have moved the antenna?


and another thing -
is it possible to add to the script to send E-mail even when the position didn't change?
something like - "router is still in the same position" - where do I need to change the script?(this why I can know it's still alive and working)?

Thank again!
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: GPS Text Output file import to Google Earth or Google Ma

Thu May 17, 2012 5:14 pm

You can send every time you call the program. At the start of the code, use :
:global oldpos "";
You will need to move the router about 10-15 meters before the position will change. It is not going by the actual coordinate position. That changes too much to be a good trigger. I use the position used by Google Maps (N32.0890+E34.8582). If that computes to the same position, it will not send.

edit: You can see what the code generated for the variable values, even tho it does not send the email. I assigned variables as global when they could be local, so I could see them after the run while debugging.
/system script environment
print
Last edited by SurferTim on Thu May 17, 2012 5:21 pm, edited 1 time in total.
 
David1234
Forum Guru
Forum Guru
Posts: 1301
Joined: Sun Sep 18, 2011 7:00 pm

Re: GPS Text Output file import to Google Earth or Google Ma

Thu May 17, 2012 5:19 pm

A B--I--G Thank you!!!!!

I think we both benefit from this

Thank! (again ,and again).

if I will have any more problems and\or changes to do I will ask.

Thank!
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: GPS Text Output file import to Google Earth or Google Ma

Thu May 17, 2012 5:36 pm

You are welcome! :D

If you have trouble with the gps.txt file again (I presume that was the challenge), let me know. It may be a collision thing. Scripts run concurrently, so the GPS function could be running concurrently with this code. That may cause file corruption.

You can use another script to clear the oldpos variable if you don't want to send every minute. Schedule this script to run once a day (or ??). Here is the script
:global oldpos "";
 
David1234
Forum Guru
Forum Guru
Posts: 1301
Joined: Sun Sep 18, 2011 7:00 pm

Re: GPS Text Output file import to Google Earth or Google Ma

Thu May 24, 2012 2:18 pm

Do you think it is possible to a dynamic map?
to make a page with HTML and sent the GPS automatically to that page.
that way - all you need to do is to open the page you made and to see the movement change (let say the RB sent every 5 min)?
how hard do you think it should be to do something like this?

thanks ,
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 24745
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: GPS Text Output file import to Google Earth or Google Ma

Thu May 24, 2012 2:23 pm

You can't "send to page", but you can upload the TXT file to a server, and the server could read from that file continuously. Probably as easy as some PHP code.
No answer to your question? How to write posts
 
David1234
Forum Guru
Forum Guru
Posts: 1301
Joined: Sun Sep 18, 2011 7:00 pm

Re: GPS Text Output file import to Google Earth or Google Ma

Thu May 24, 2012 2:31 pm

do you know where can I found example ?
or something like this?
or even what to search in google?
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 24745
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: GPS Text Output file import to Google Earth or Google Ma

Thu May 24, 2012 2:33 pm

no, you need to ask somebody who is a PHP programmer
No answer to your question? How to write posts
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: GPS Text Output file import to Google Earth or Google Ma

Thu May 24, 2012 2:35 pm

The challenge is security. You will probably need to use tftp to transfer the file from the router to the web server. That could cause some security holes if not set up correctly.

Once you get the file onto the server, the challenge there is not so difficult. But it won't be easy.
 
David1234
Forum Guru
Forum Guru
Posts: 1301
Joined: Sun Sep 18, 2011 7:00 pm

Re: GPS Text Output file import to Google Earth or Google Ma

Thu May 24, 2012 2:41 pm

o.k

Thanks again ,
 
videoicu
just joined
Posts: 15
Joined: Sat Aug 07, 2010 4:11 pm

Re: GPS Text Output file import to Google Earth or Google Ma

Sun Mar 17, 2013 3:55 pm

Thanks to ST for such an interesting script.

RB 411U, RBOS 5.24

[admin@GPS Demo] > /system gps print
enabled: yes
port: usb2
channel: 0
set-system-time: yes

[admin@GPS Demo] > /system gps monitor
date-and-time: mar/17/2013 13:51:27
latitude: N xxxxxxxxxxxxxxxxx
longitude: W xxxxxxxxxxxxxxxxxx
altitude: 202.399994m
speed: 0.537080 km/h
bearing: none
valid: yes
satellites: 6


Question: The code below only writes the gps coordinate information once to the file gps.txt as it appears to me. It does not update the file automatically. What is the code to make it repeat the update, just as it does to the console without the file=gps.txt in the code?

Otherwise I don't see how ST's great gps script updates changes in gps position as reported in gps.txt....
 /system gps monitor file=gps.txt
Thanks, I may just be missing something in the code line to make it repeat to update the file.
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: GPS Text Output file import to Google Earth or Google Ma

Sun Mar 17, 2013 4:27 pm

That should be run as a script. I don't have a GPS unit here to test. This is from that wiki page
Go to "/system schedule" and schedule the script "gps" to run at whatever interval is appropriate for your application. It sends email always if the position is not valid, and also when the position is valid and it changed from the last time the script was run.
You may need to run "/system gps monitor" in the system scheduler also. I did the gps script, not the gps.txt file update.
 
videoicu
just joined
Posts: 15
Joined: Sat Aug 07, 2010 4:11 pm

Re: GPS Text Output file import to Google Earth or Google Ma

Sun Mar 17, 2013 5:18 pm

Thanks ST for reply....

That's what I thought but didn't want to miss a simple syntax error in the gps monitor code, not much said in MT wiki about the command.

Since you don't have a GPS unit to test, the output of /system gps monitor refreshes on the console automatically about every 2 seconds it appears, but it does not overwrite the gps.txt file automatically.

Simple enough to add in scheduler as long as updates are coming fast enough.

BTW, seems you deserve a GPS unit to test with for all you have done on this script and Wiki......if it will help continue your efforts on GPS scripting for MT, I will gladly supply you one at no charge.........
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: GPS Text Output file import to Google Earth or Google Ma

Sun Mar 17, 2013 5:32 pm

That is a generous offer. If you are serious, here is my address.

Tim Dicus
9950 US Hwy 98 West G-12
Miramar Beach, FL 32550

I have my RB433UAH out on loan to a customer while waiting for a warranty replacement, but hopefully that will be coming home soon. :D
 
videoicu
just joined
Posts: 15
Joined: Sat Aug 07, 2010 4:11 pm

Re: GPS Text Output file import to Google Earth or Google Ma

Sun Mar 24, 2013 5:27 pm

SurferTim, your GPS unit is on order and I will forward it to you as soon as it arrives in about a week...you will be receiving a GlobalSat BU-353 USB GPS Navigation Receiver....it works well with MT. Thanks for your work and replies.

Your script works well and we have modified it to also "fetch" to http rather than email.

If you have any thoughts though on how to get data directly from the GPS unit on the USB port, such that the data could be buffered and parsed on the MT rather than writing to a file, it would be appreciated.

Serial-terminal will send the data out over http (tcp) but we don't want to send the entire stream (bandwidth). It would be much more efficient to do exactly what you did in your script except get the data from the device rather than using the "GPS monitor" command to write to a txt file.

It would seem that if MT can do it with their GPS monitor command then I would hope there would be a way we could get the same data without sending it off the MT board and use RBOS to buffer the data, say to an array, etc and then parse and assign global variables just as you did. Just not from the GPS.txt file. I just don't see any additional syntax in the forum to modify GPS>Monitor> File=GPS.txt beyond that.

Any thoughts STim or anyone? I think MT has indicated no.
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: GPS Text Output file import to Google Earth or Google Ma

Sun Mar 24, 2013 6:37 pm

Wow! Very generous of you. :D

As far as the GPS and the usb, that will take a bit of playing. I'll see what I can do. You will be the first to know.
 
xezen
Long time Member
Long time Member
Posts: 628
Joined: Fri May 30, 2008 10:23 am
Location: South Africa

Re: GPS Text Output file import to Google Earth or Google Ma

Tue May 14, 2013 10:12 am

im looking for help i export all the data to a text file amd im ttrying to right the text file into the following


my program of choice
http://opengts.sourceforge.net/

so then i can log this information

it users mysql
is there anyone that would like to help me solve this sript problem

as i dont think mikrotik will add the optipn to export any data directly to a mysql server
If i dont No Ask someone That Does!
 
xezen
Long time Member
Long time Member
Posts: 628
Joined: Fri May 30, 2008 10:23 am
Location: South Africa

Re: GPS Text Output file import to Google Earth or Google Ma

Tue May 14, 2013 10:42 am

urealy looking for someone thats good with php and mysql to help with this project

as i can see it small simple changes but i dont know mysql
If i dont No Ask someone That Does!
 
Smueller
just joined
Posts: 6
Joined: Wed Jun 27, 2012 1:32 pm

Re: GPS Text Output file import to Google Earth or Google Ma

Tue Aug 13, 2013 10:50 pm

Hello Tim,

i see you are a GPS GURU :-)

i am looking since 3 Month ago to a GPS Hardware that works with Routerboards.

I have a RB433 UAHR with a SierraWireless MC78xx 3G Modem,
now i want check the Position of my Box and will track my System but my biggest problem is that i cannot find a GPS Gardware that i can use with my board. can you give me a tip whats working ???


thanks

Stefan
 
xezen
Long time Member
Long time Member
Posts: 628
Joined: Fri May 30, 2008 10:23 am
Location: South Africa

Re: GPS Text Output file import to Google Earth or Google Ma

Mon Oct 06, 2014 6:09 pm

im going to make api to output mikrotik gps data into opengts server
If i dont No Ask someone That Does!
 
mickeymouse690
Member Candidate
Member Candidate
Posts: 105
Joined: Sun May 20, 2007 3:08 am

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

Wed Nov 08, 2017 5:40 am

I know this is bad etiquette reviving an old thread but I was wondering how hard it would be to be able to show the current gps speed as lets say the google maps pin label or something of that nature.? :s

Regards,
C

Who is online

Users browsing this forum: aesmith, gilliardmelo, Google [Bot], mixig, Olalilu and 120 guests