[map module] Export to Google Earth not working

Huebli

Joined: 2004-06-08
Posts: 11
Posted: Tue, 2006-05-09 20:41

I've prepared my GPS data from my Gramin Forerunner 301 according to the instructions at
http://codex.gallery2.org/index.php/Gallery2:Modules:Gps
For testing purposes, the GPS data is attached.

When pressing the export button on the "Export to Google Earth Page",
http://www.brics.dk/~chris/gallery2/main.php?g2_view=map.GoogleEarthAlbum&g2_itemId=14742
a file containing the following error message is downloaded:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.0">
<Folder>
<name>gps test</name><br />
<b>Fatal error</b>: Call to undefined function curl_init() in <b>/web/chris/public_html/gallery2/modules/map/GoogleEarthAlbum.inc</b> on line <b>113</b><br />

The same error occurs when not using any GPS data at all.

Any help greatly appreciated!


Gallery version = 2.0.2+ core 1.0.10
PHP version = 4.3.11 apache2handler
Webserver = Apache
Database = mysql 4.1.10a-max
Toolkits = ArchiveUpload, Exif, NetPBM, Thumbnail, ImageMagick
Operating system = Linux gorm 2.6.9-22.0.2.ELsmp #1 SMP Thu Jan 5 17:13:01 EST 2006 i686
Browser = Mozilla/5.0 (X11; Linux i686; U; en) Opera 8.51
Google Map Module 0.5.0g 0.5.0g Show item on a Google Map Using the API
http://www.brics.dk/~chris/gallery2/phpinfo.php

AttachmentSize
x.custom.txt157.6 KB
 
Termitenshort
Termitenshort's picture

Joined: 2005-10-09
Posts: 1894
Posted: Tue, 2006-05-09 21:04

I think there was a report that the curl_init() function ins't a very good choice as it's relying on some library to be installed on the Server. I also think that there was a solution for it.

I'll dig in a bit and let you know (unless someone else finds it faster) ;-)

See you !
-------------------------
The Termite :-)

 
galmoid

Joined: 2005-11-07
Posts: 364
Posted: Tue, 2006-05-09 22:02

Just comment out (put two slashes in front of each line '//') the curl
section from the GoogleEarthAlbum.inc file. Should be about line 109-120.

$u='http://pingomatic.com/ping/?title=' . urlencode($child->getTitle()) .
'&blogurl=' . urlencode(str_replace('&amp;', '&', $urlGenerator->generateUrl (array (
  'view' => 'core.ShowItem', 'itemId' => $child->getId()), false))) .
   '&chk_geourl=on&chk_a2b=on';
            $ch = curl_init ($u);

            $devnull = fopen ('/dev/null', 'w');
            curl_setopt ($ch, CURLOPT_FILE, $devnull);
            curl_exec ($ch);

            curl_close ($ch);
            fclose ($devnull);

I think it will have no impact on the outcome... other than
gettin' rid of the error you are experiencing.

 
Huebli

Joined: 2004-06-08
Posts: 11
Posted: Wed, 2006-05-10 20:03

I commented out these lines and indeed, an almost correct file is produced. The only problem is that the URL is not generated correctly. Here is an extract:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.0">
<Folder>
<name>gps test</name><Placemark><name>SkanderborgTrip_151</name>
<description><![CDATA[<a href="main.php?g2_itemId=15563">
<img src="main.php?g2_view=core.DownloadItem&g2_itemId=15564&g2_serialNumber=2"></a>]]></description>
<LookAt><longitude>9.935349</longitude><latitude>56.046424</latitude><range>300</range><tilt>45</tilt><heading>47.796584629396</heading></LookAt>
<styleUrl>root://styleMaps#default+nicon=0x307+hicon=0x317</styleUrl><Style><IconStyle><Icon><href>root://icons/palette-4.png</href><x>192</x><y>96</y><w>32</w><h>32</h></Icon></IconStyle></Style>
<Point><extrude>0</extrude>
<tessellate>0</tessellate>
<altitudeMode>clampToGround</altitudeMode>
<coordinates>9.935349,56.046424,0</coordinates>
</Point>
</Placemark>

Instead of just "main.php?..." it should prodcue "http://www.brics.dk/~chris/gallery2/main.php?..."
I could resolve this by manually add the correct URL into the GoogleEarthAlbum.inc file, but I guess this is not the way it should be done in general...

 
Huebli

Joined: 2004-06-08
Posts: 11
Posted: Wed, 2006-05-10 20:05

Hi Termite

I'd like to know what curl_init() is good for and am certaintly interested if there's a solution around.

Thx a lot!
Chris

 
galmoid

Joined: 2005-11-07
Posts: 364
Posted: Wed, 2006-05-10 21:12

curl_init - probably something (I'm not sure); but, since this works
without it . . .
solution - get and install curl on your system :-)

URL - try this change (I have not tried it on the original file that
you are probably using; but it might work):

current code (with line numbers that might be accurate):

    125             echo $urlGenerator->generateUrl (array (
    126   'view' => 'core.ShowItem', 'itemId' => $child->getId()), false);
    127             echo "\">\r\n<img src=\"" . str_replace('&amp;', '&', $urlGenerator->generateUrl (array (
    128   'view' => 'core.DownloadItem', 'itemId' => $source[$child->getId()]->getId(),
    129               'serialNumber' => $source[$child->getId()]->getSerialNumber()),
    130               false));

changed code:

    125             echo $urlGenerator->generateUrl (array (
    126   'view' => 'core.ShowItem', 'itemId' => $child->getId()), array('forceFullUrl' => true));
    127             echo "\">\r\n<img src=\"" . str_replace('&amp;', '&', $urlGenerator->generateUrl (array (
    128   'view' => 'core.DownloadItem', 'itemId' => $source[$child->getId()]->getId(),
    129               'serialNumber' => $source[$child->getId()]->getSerialNumber()),
    130               array('forceFullUrl' => true)));
 
Termitenshort
Termitenshort's picture

Joined: 2005-10-09
Posts: 1894
Posted: Wed, 2006-05-10 21:37

I have not created that code persoannly, it was a separate module at first and we decided to merge them both to propose a complete solution.

I have to say that the Google Earth part of the module has gotten a lot less attention and I can honestly say that I have not tested it and i'm not sure how it works :-)

What I can say is that CURL (Client URL) is a php library that let you communicate with servers in different protocols ... other than that I would need to look at the code in more details to understand what's it trying to do :-)

Galmoid seems to have a better grip than me....

Sorry about that !
-------------------------
The Termite :-)

 
Huebli

Joined: 2004-06-08
Posts: 11
Posted: Wed, 2006-05-10 21:39

Very nice! Thanks a lot for the support, Galmoid! Works perfectly now.

also to Termite: I hope these points will incorporated into the next release of the module.

 
Termitenshort
Termitenshort's picture

Joined: 2005-10-09
Posts: 1894
Posted: Wed, 2006-05-10 21:57
Huebli wrote:
also to Termite: I hope these points will incorporated into the next release of the module.

They are not, but it's just a matter of minutes. I will add those changes before releasing tonight ;-)

 
galmoid

Joined: 2005-11-07
Posts: 364
Posted: Wed, 2006-05-10 22:10

Termite,
Remove the curl stuff and we will no longer need to try and
explain anything about it (which we don't know anyway). :-)

 
Termitenshort
Termitenshort's picture

Joined: 2005-10-09
Posts: 1894
Posted: Thu, 2006-05-11 00:25

Well for some strange reason I already have Curl crap removed ....

I'm not gonna wonder and just go on with releasing :-)
-------------------------
The Termite :-)

 
Huebli

Joined: 2004-06-08
Posts: 11
Posted: Thu, 2006-05-11 08:02

Just had a quick glance at the new new release 0.5.1a.
The GoogleEarthAlbum.inc changed quite a bit to the last version, but is, again, not working properly. The export-URLs are fixed to http://www.eansk.com/esgallery/
Probably someone else who hacked around the bug in the same way as I did.

I also experienced problems uploading the GPS data, the result is not satisfying, the coordinates are wrong.

I recommend using the GoogleEarthAlbum.inc from the last release with the changes indicated by galmoid in this thread.

 
Termitenshort
Termitenshort's picture

Joined: 2005-10-09
Posts: 1894
Posted: Thu, 2006-05-11 13:06

I guess I should have looked further when I realized that the changes were already "done" ... as it turn out I had put a new file sent to me with corrections at the time but I still have no way to test this so I just "assume" it was correct ...

Well, it will be time for "b" versions :)

See you !
-------------------------
The Termite :-)

 
galmoid

Joined: 2005-11-07
Posts: 364
Posted: Thu, 2006-05-11 13:10

:-):-):-)

I am curious... did you try to upload a gpx file? Was the gpx file used?
Please answer that question if you can. I believe the gpx file might
match gpx timestamps to pic timestamps... so in the final kml file pics
that do not have coodinates assigned in the database but have matching
timestamps would be plotted.

I think a version of this file that was being attempted which would allow
for it's use without the need for a gpx file managed to find it's way
past our rigorous testing and release procedures. I assure you, our pre-release
manager will be... nevermind.

All, I think, pretty easy to deal with. I'll try.

Have you tried using the old file with the new release?

 
Huebli

Joined: 2004-06-08
Posts: 11
Posted: Thu, 2006-05-11 14:34

just a quick answer before i do further tests tonight.

Using the old GoogleEarthAlbum.inc with the changes you suggested worked fine!

 
galmoid

Joined: 2005-11-07
Posts: 364
Posted: Thu, 2006-05-11 19:09

I am still curious to know the answers to the question(s) I posed; but,
here is another GoogleEarthAlbum.inc file to try out (since you're in
a testing mood :-))

EDIT: Deleted the attacment. See newer post below for this file.

 
Huebli

Joined: 2004-06-08
Posts: 11
Posted: Thu, 2006-05-11 21:03
galmoid wrote:
:-):-):-)

I am curious... did you try to upload a gpx file? Was the gpx file used?
Please answer that question if you can. I believe the gpx file might
match gpx timestamps to pic timestamps... so in the final kml file pics
that do not have coodinates assigned in the database but have matching
timestamps would be plotted.

OK, I've tested three versions of GoogleEarthAlbum.inc, the outputs are attached.

1. the old version from release 0.5.0g with the changes you indicated above works fine.
2. the new version from release 0.5.1a produces incorrect urls, but seems to work fine combining the gps data with the time stamps of the pictures
3. the version you've send me corrects this problem but mixes up longitudes and latitudes. Exchanging the two variables on lines 88 and 89 solves this problems and makes this the preferable version of the file!

Thanks a lot, Galmoid and Termite! :)

AttachmentSize
0.5.1galmoid.kml.txt2.45 KB
0.5.1a.kml.txt2.42 KB
0.5.0g.kml.txt2.63 KB
 
Termitenshort
Termitenshort's picture

Joined: 2005-10-09
Posts: 1894
Posted: Thu, 2006-05-11 21:58

So which version should be put in the module, I'm all confused :-)

The version sent by Galmoid + change to invert the coordinates ?
-------------------------
The Termite :-)

 
Huebli

Joined: 2004-06-08
Posts: 11
Posted: Thu, 2006-05-11 22:07

Yes, if you ask me, but Galmoid should have the final word.

 
galmoid

Joined: 2005-11-07
Posts: 364
Posted: Thu, 2006-05-11 22:27

OK. I made the correction for the reversed coordinates (Thank You).
New file attached here.

Huebli, please make sure it works for us before Termite goes ahead with it's incorporation. Thank You.

AttachmentSize
GoogleEarthAlbum.zip2.6 KB
 
Huebli

Joined: 2004-06-08
Posts: 11
Posted: Thu, 2006-05-11 23:01

seems to work fine with me!

Thank you all!

 
Termitenshort
Termitenshort's picture

Joined: 2005-10-09
Posts: 1894
Posted: Fri, 2006-05-12 00:27

Great so that I will put the new files in the 0.5.1b & 0.4.11b :-)
-------------------------
The Termite :-)