PDA

View Full Version : PHP script for routes, POI files in /PSP/COMMON



Nieko
June 21st, 2007, 11:19
Hi all :)

I found it quite annoying that the only way to place routes (POI files with WAYPOINT) in MapThis is by means of a PC (e.g. GMDL). I thus made a small script that basically does the same thing. You can find it at:
http://getroute.nieko.net/
(The source can be found at http://nieko.net/tools/getroute.phps.)

I know the algorithm for deciding what MIDPOINTs to take out looks rather random, but for me it seemed to work just fine :) If anyone has suggestions on how to improve this, then feel free to tell me!

The idea is that you can access this script using the PSP browser, and then save the file it returns to a folder in MapThis. Of course you still need a WiFi connection for this, but at least you do not need a PC anymore :) Unfortunately, the stupid PSP browser only wants to save in a few directories, including /PSP/COMMON.

I thus made a few alterations to the MapThis source:

_MY_POIS has been renamed to _#MY_POIS, so that it shows up at the top of the POI list.
POI files are read from /PSP/COMMON by default (this includes _#MY_POIS). These show up in the POI list in MapThis as "ms0:/PSP/COMMON/_<name>". The added benefit of this is that route files are now accessible in every map.
POI files are still also read from the map directory, as in the official version.
When showing POI files, it doesn't also show _#MY_POIS anymore.
Icons used in POI files are now always read from MapThis/system/icons.
The makefile has been slightly changed (removed BUILD_PRX=1), cause otherwise the thing wouldn't compile :P


In the attachment, you can find the patch for MapThis 0.497 beta, and the PSP-290 EBOOT with this functionality.

The patch should be applied in the src/ directory (where main.c, etc. are), and should be called using: cat mapthis-patch | patch -p1

Enjoy :)

Nylon32
June 21st, 2007, 11:47
I've just tried planning a route on it but using the standard Mapthis 0.499 eboot and I have to admit it's great. Once I get the psptoolchain working I'll have a go at compiling this and trying it on the psp, great work

Mobz87
June 21st, 2007, 20:02
This is really big if you can get it working 100% :P

Nieko
June 22nd, 2007, 09:07
How do you mean, 100%? Is there something that doesn't work well?

Mobz87
June 22nd, 2007, 10:52
I mean when it becomes a part of mapthis and when google.maps upgrade thier map to more countries it will be perfect :P

Problem is that here in Denmark google.map doesnt support street numbers :(
So I cant really use your cool program Nieko :(

jakekoh
July 20th, 2007, 07:12
Nieko, is your site down or something?

Nieko
July 20th, 2007, 09:32
I'm having some server problems indeed. I'm on holiday now, but someone is currently going there to fix it.

Codaz
July 20th, 2007, 10:59
Nieko why did you release this for mapthis .97 and not .99 ? .99 has a lot more bugfixes.

Nieko
July 20th, 2007, 11:17
This script is not linked to any specific MapThis version, it can be used in all so far. Other than that, it's up again :)

The MapThis version I made (see New Code Contribution) is indeed based on 0.497, because I didn't like the sound in 0.499 much and didn't feel like stripping all that out.

We'll see what the 0.5 version will bring us, and how I can implement the changes I've made in 0.497 in 0.5 also :)

Anyway, I'm off again :) Bye!

jakekoh
July 21st, 2007, 02:23
yo got it, thanks. you doing a great help for us.

AlexRoxUrSox
July 21st, 2007, 07:13
Deniska? Care to comment?

Codaz
July 24th, 2007, 15:20
I hope that Deniska sees that he has a LOT of work to do hehe. Nieko presented various versions, MIB.42, atari800 and himself has various versions.

Hope to see that Deniska can combine them all :)

Bolemichel
August 21st, 2007, 20:01
holy shi... amazing!

just tested this little php script with the psp browser and it works just fine!

ok, I don't understand what this means: "Show max. 400 points (trim midpoints)" but it looks very fine when activated.

Nieko, another name to remember! Good work... now no pc is needed any more :=)

PDG
August 22nd, 2007, 09:09
I'm having some server problems indeed. I'm on holiday now, but someone is currently going there to fix it.

If you can code it in .asp i can help you host it :)
I have a server on a 200/200 Mbit/s pipe without any limitations regarding transfer :thumbup:

Waltrock
August 22nd, 2007, 10:24
it would be nice if you could integrate multilanguage-support!

Nieko
September 5th, 2007, 19:21
PDG: thanks for the offer, but I don't know ASP, and I can host it at my work if necessary.

Waltrock: for now, that's not a priority. I'll first include sound support in my PHP script, make that customizable, and then work on MapThis itself a bit.

But who knows, perhaps after that :)

Nieko
September 8th, 2007, 14:59
Hi all :)

With the new sound support in MapThis 0.5 and higher, I have updated my route proxy with sound support as well. The main changes I made to MapThis when I first released this script (see first post in this thread) have been built into the official MapThis, so this script now works flawlessly with newer MapThis versions!

The script can be found at: http://getroute.nieko.net/

As always, you can input source and destination address to get your route, and there is some fault handling ("Source location not found", "Couldn't calculate route", etc.)

The changelog is as follows:

Removed trimming of midpoints, MapThis handles this just fine;
Removed images from front page (MapThis has these by default);
Introduced sound list, default is more or less the same as the GMDL version;
Sound list is also customizable (through a cookie).


Press the "Manage sound list" button to see how to create your own sound list.

harryk
September 12th, 2007, 17:42
Neiko

Just wanted to drop a line to say thankyou for this sweet little addition.

Side question for both you and Deniska

how hard or impossible will it be to include native lookup and waypoint creation using the address lookup in MapThis! , instead of requiring internet access to hit a 3rd party site to perform the lookup?

Nieko
September 13th, 2007, 12:28
There's two ways this can be done.

One, have an extra screen in MapThis that takes care of actually downloading the route (either through the proxy, or processing it itself), saving it, etc. I think this would have MapThis take on too much functionality, so you can still just do this through the browser.

Two, actually calculate the route, like Google does, in MapThis. For this you need more data than is currently available, and I think there is already a thread about this. The conclusion was something like "not for some time to come", unfortunately.

harryk
September 13th, 2007, 16:00
I kinda thought that it would be a bit much for MapThis, but maybe before it hits 1.0 ... maybe ;)

deleted note, I just realized the feature I requested had already been implemented.

Just a thought.

cheers,
harryk

lansingone
September 18th, 2007, 05:09
must be some bugs in it, i just made a route and then tried to use the swap fields button to make the same in the other direction and it said couldn't calculate route. i wonder why it could only do the route in that direction, i would have thought it just needed to do everything backwards

dragonslayere
September 18th, 2007, 07:26
site is down i guess

maybe try hosting it on google pages...?

Nieko
September 18th, 2007, 09:22
lansingone: can you PM me the addresses you tried (or another pair where reverse doesn't work)? Then I can see what's going on. Perhaps there's simply a one-way road somewhere that messes things up.

dragonslayere: if my script says that Google couldn't calculate the route, then that already means my site was up. If I indeed get problems hosting this (which I doubt, I've had only one failure in the last two years or so, see earlier in this thread), then I will move to more professional hosting.

Besides, does Google Pages support PHP?

PDG
September 18th, 2007, 09:25
lansingone: can you PM me the addresses you tried (or another pair where reverse doesn't work)? Then I can see what's going on. Perhaps there's simply a one-way road somewhere that messes things up.

dragonslayere: if my script says that Google couldn't calculate the route, then that already means my site was up. If I indeed get problems hosting this (which I doubt, I've had only one failure in the last two years or so, see earlier in this thread), then I will move to more professional hosting.

Besides, does Google Pages support PHP?

I can always host it, keep me in mind :thumbup:

GoDE
September 18th, 2007, 16:26
Hi,
i have written a small vb script to convert the created routes with strange signs to the german "specials".
ä = ä(ae), ö = ö(oe), ü = ü(ue), ß = ß(ss)
In the moment only for lowercase signs.
Put the code in an text file and name it "filename.vbs". Drag and drop the route on the script and an "_GER" version is created.
Please report any problems.

--script begin--
'ä = ä
'ö = ö
'ü = ü
'ß = ss or ß

Const ForReading = 1
Const ForWriting = 2
mydebug = 0

Set objFSO = CreateObject("Scripting.FileSystemObject")

Filename = Wscript.arguments(0)
Filename2 = Filename+"_GER"

if mydebug = 1 then
Wscript.Echo(Filename)
Wscript.Echo(Filename2)
end if

Set objFile = objFSO.OpenTextFile(Filename, ForReading)
Set objFile2 = objFSO.OpenTextFile(Filename2, ForWriting, True)


Do Until objFile.AtEndOfStream
MyTextLine = objFile.ReadLine
MyTextLine = Replace(MyTextLine,"ä","ae") 'ä
MyTextLine = Replace(MyTextLine,"ö","oe") 'ö
MyTextLine = Replace(MyTextLine,"ü","ue") 'ü
MyTextLine = Replace(MyTextLine,"ß","ss") 'ß/ss
objFile2.WriteLine MyTextLine
Loop

objFile.Close


Wscript.Echo("FINISH")
--script end--

I know that can be coded better, but it's my first VB Script.
Cheers
GoDE

Edited: Code changes 18-Sept

dragonslayere
September 18th, 2007, 20:03
if it's not down then it maybe something on my end... i keep getting
"Forbidden

You don't have permission to access / on this server."

Nieko
September 18th, 2007, 21:48
dragonslayere: do you happen to be an Ameritech user? I've had a lot of problems with different clients from this ISP in the past hammering me all the time, so I had to block the entire domain.

If yes, then I'll remove those kinds of bans, and hopefully the mess will stay away this time. If not, could you tell me your IP address (just PM)? Then I can look it up in the logs and see what's going wrong.

dragonslayere
September 19th, 2007, 07:45
yes I'm a ameritech user
:(

Nieko
September 19th, 2007, 10:45
dragonslayere: I've removed all the bans, it should work just fine now :).

Nieko
October 1st, 2007, 11:45
Update: like in GMDL, you can now indicate you want to avoid highways in your route.

Soon I'll also implement choosing another Google server (have to test if this works) and user specified encoding (so CP1251 instead of UTF8 e.g.).

If anyone is aware of more options in Google Maps, please tell me :).

Nieko
October 1st, 2007, 16:53
Update: I've added user specified encoding. When you click Settings, you can indicate what encoding the POI file should get (default from Google is UTF-8). If characters cannot be recognized, they are replaced by question marks (?).

For Russian, you'd usually choose Windows-1251 (cp1251), for most European languages, you'd choose ISO-8859-1.

Make sure that MapThis also understands what these characters mean. See http://www.dcemu.co.uk/vbulletin/showthread.php?t=70091 for this.

jakekoh
October 2nd, 2007, 06:45
Nieko, are you able to write a code that query geodata? because everytime i uses GMDL it gives me whole lot of problems even the directions option.

their direction waypoints are unlike yours which indicated midpoints, compared to them GMDL doesen't work on my maps.google.com page. i really hope they can admend them.

Nieko
October 2nd, 2007, 10:41
jakekoh: I don't understand your question. Geodata is a database with streets, zip codes and city names in it. It doesn't have to do with POI directions through GMDL or my site.

Nieko
October 2nd, 2007, 15:31
Update: I've added language settings for POI files. This can be found under Settings, and will return the actual directions ("go left", "u-turn", etc.) in one of the languages available.

You should then also update the sound list with settings for your language, and possibly the encoding as well.

Because MapThis doesn't properly show Unicode filenames (POI filename is based on destination address), you can also specify an alternative filename.

See http://getroute.nieko.net.

seroxeno
October 2nd, 2007, 17:51
Update: I've added language settings for POI files. This can be found under Settings, and will return the actual directions ("go left", "u-turn", etc.) in one of the languages available.

You should then also update the sound list with settings for your language, and possibly the encoding as well.

Because MapThis doesn't properly show Unicode filenames (POI filename is based on destination address), you can also specify an alternative filename.

See http://getroute.nieko.net.

Nice update with internacianalization.

Now would be perfect if change sounds text on textbox when onchage event of country combo :thumbup:. But this need colaboration too bory for one...

Nieko
October 2nd, 2007, 18:04
Not only that, if you have a custom sound list (I have 27 entries already), then you can't automatically translate that. This will remain manual work for now.

jakekoh
October 7th, 2007, 02:26
what i meant was..

first GMDL was unable to extract the directions from maps.google.com even it is searchable in the frame.

2ndly GMDL beta geodata query once again is unable to query google.com for any data i input even with extreme low frequency that it requested.

Nieko
October 7th, 2007, 09:01
As for extracting routes, if that's what you want, you can always use http://getroute.nieko.net/.

As for Google geodata in GMDL, I found that it took way too long anyway (and it apparently blocks you after 10.000 queries or so) for any area of reasonable size. The Netherlands alone already have ~840.000 streets e.g.

As to why GMDL doesn't work, wouldn't know...

cyberg0at
February 15th, 2008, 10:41
Seems like a while since the last person who posted here Nieko, but just wanted to say personally what a great job on the coding you have done! :D Works great.

Nieko
February 15th, 2008, 20:49
Thanks :).

Nieko
March 23rd, 2008, 19:13
I've changed GMapToGPX (http://www.elsewhere.org/journal/gmaptogpx/) to produce output compatible with Map This!, as requested here (http://www.dcemu.co.uk/vbulletin/showthread.php?p=2148031626#post2148031626).

See http://getroute.nieko.net/ (second section) for instructions.

I will try to add sound support soon as well.

BanKiR
March 25th, 2008, 08:01
It is awesome!

Thanks for your work!

BanKiR
March 25th, 2008, 09:46
Hi Nieko,

Is there a way to calculate 3-4 routes in your page? for example: from A to B to C

If I go directly to maps.google.com to the get direction page, I'm able to do so by inputting
Start Address: A
End Address: B to: C to: D
And I can click the "Google Maps to POI" to get these directions, but I must save it to notepad and rename it.

But from your getroute.nieko.net cannot do this. It only gives me direction A to B, ignoring C and D. I prefer your page, since it gives me the file automatically.

Thanks.

Nieko
March 25th, 2008, 11:55
On http://getroute.nieko.net multiple routes aren't possible, somehow it does indeed ignore C, D, etc. I'm not sure how to fix this. If someone knows how, please tell me :-).

Personally I like that I can see the actual route first before downloading, so I will take a look at making the Javascript produce a file download instead.

Nieko
March 25th, 2008, 14:33
(I moved the previous two posts here.)

It is possible in IE, but it saves the entire document, not just the contents from the textarea. Cross-browser won't work for sure, it's the server that tells the browser to do something, not the client itself (i.e., javascript).

Anyone here with better Javascript knowledge? :)

BanKiR
April 1st, 2008, 01:57
Hi Nieko,

I tot I got all figured out, but no.

How do I use GMaptoGPX so that MapThis can read it? This is what I did
- Find direction
- Click on GMaptoGPX bookmark in toolbar
- I copy and paste the script to notepad and save it as _@ABCDE (No extension)
- I open MapThis on PSP and find _@ABCDE
- The Map does not show

What did I do wrong?

I know you didn't create GMaptoGPX but if you could give me some light, that'll be great! Thanks..

Nieko
April 1st, 2008, 10:23
The output you get from the script should have the following format: lat,lon,desc1,desc2. E.g.: 40.316218,-5.41832,GO 80M,HEAD NORTHEAST

You can paste the two numbers ("40.316218,-5.41832") in maps.google.com and it'll show you where exactly it is.

Saving it as _SOMETHING then should make it load.

If all else fails, you can of course post here the file the script gives you.

BanKiR
April 1st, 2008, 15:18
Um, that means, I have to do a lot of editing if I were to use from Point A to B to C to D, using GMaptoGPX.

I tot I could just copy and paste the whole script and save it as _SOMETHING and MapThis would read this. Or I thought you meant that when you say that the script would be compatible with MapThis. My bad..

Oh well, I like your getroute.nieko.net better than in this case. So simple to use! As I have mentioned before that it'll be great if you could make it to have multipoint directions. I wish I could help, I dunno any programming language :(

Btw, how do you delete the extension .html when you use PSP browser to download? I haven't tried really, but I'm pretty sure that there is no file manager in PSP. I read somewhere someone suggests to use PSPPDA or something like that. Any other suggestion for a good File Manager? (to use only to delete .html to no_extension).

Thanks anyway, I appreciate your help.

Nieko
April 1st, 2008, 19:23
Um, that means, I have to do a lot of editing if I were to use from Point A to B to C to D, using GMaptoGPX.

You shouldn't. You can add as many destinations in Google Maps as you want, as well as drag points from the blue line somewhere else. When you're done, and press the GMapToPOI button (not GMapToGPX, that's what it's based on), then it'll show in the textbox exactly the coordinates and instructions for the blue line you saw in Google Maps.


I tot I could just copy and paste the whole script

You shouldn't copy the script, because it's Javascript code. You should instead copy the text in the textbox, generated by the Javascript.


and save it as _SOMETHING and MapThis would read this. Or I thought you meant that when you say that the script would be compatible with MapThis. My bad..

No no, that's exactly how it's supposed to work :). If it's broken somehow, then I'm curious as to what exactly you are getting, instead of the proper route. Could you post the file you got?


Oh well, I like your getroute.nieko.net better than in this case. So simple to use! As I have mentioned before that it'll be great if you could make it to have multipoint directions.

I'll try to find out if it's possible, but I do think it'd be rather cumbersome if I'd have to make several requests for A-B, B-C, C-D etc. to the Google Maps server.


Btw, how do you delete the extension .html when you use PSP browser to download?

That's the thing, I really don't know. When using Opera, it also insists on adding .HTM. But that's OK, Map This! doesn't care about extension, as long as the filename begins with an underscore.

Edit: I tried using " " as extension (so "filename. "), and though that works in Opera, it doesn't in the PSP browser...

Nieko
April 10th, 2008, 19:04
Just now I've added sound support for GMapToPOI.js (see previous posts of mine). The JavaScript loaded by the browser is in fact PHP, which loads the settings from a cookie. The source can be found here: http://nieko.net/tools/gmaptopoi.js.phps.

The sound settings can be edited at http://getroute.nieko.net/.

The scriptlet supports Unicode and thus non-latin alphabets, but Map This! does not. Take into account that when you use such an alphabet, you need to save the route from the textarea to a file on your PSP's memory stick using an editor in which you can choose the file encoding.

For routes in English this is not necessary.