<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Ah, thanks a lot! That sounds great!<div><br></div><div>However, when inserting the function and executing this:</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">      </span>SELECT askml('my_title', 'description', collect(the_geom)) FROM (SELECT c.the_geom FROM countries_view AS c) AS foo</div><div><br></div><div>I get this error:</div><div><span class="Apple-style-span" style="font-family: arial, tahoma, verdana, helvetica, sans-serif, fantasy; font-size: 11px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><pre class="data" style="font-size: 11px; font-family: arial, tahoma, verdana, helvetica, sans-serif, serif; "><span class="Apple-tab-span" style="white-space:pre">  </span>ERROR:  geometry_to_kml: 'GeometryCollection' geometry type not supported by Google Earth
<span class="Apple-tab-span" style="white-space:pre"> </span>CONTEXT:  SQL function "askml" statement 1
<span class="Apple-tab-span" style="white-space:pre"> </span>PL/pgSQL function "askml" line 21 at assignment</pre></span></div><div>If I understand it correctly from <a href="http://code.google.com/p/postexperiments/issues/detail?id=2">this</a> conversation, I'd need the latest version of Postgis to solve that issue, right?</div><div><br></div><div>Thanks for your valuable help,</div><div><br></div><div>Stefan </div><div><br><div><div>On Jul 14, 2009, at 5:50 PM, Kevin Neufeld wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>As you've seen, there is the ST_AsKML command (<a href="http://postgis.refractions.net/documentation/manual-svn/ST_AsKML.html">http://postgis.refractions.net/documentation/manual-svn/ST_AsKML.html</a>) that will convert a single geometry to KML.<br><br>All you need to do is add some xml tags before the export geometry tag and again after, closing the document.<br><br>Here's an example of a simple wrapper that does this inside the database, though you'd probably want to do this in PHP:<br><a href="http://lists.refractions.net/pipermail/postgis-users/attachments/20070914/7a02d424/askml.sql">http://lists.refractions.net/pipermail/postgis-users/attachments/20070914/7a02d424/askml.sql</a><br><br>Example use case:<br>SELECT askml('my_title', 'description', collect(the_geom))<br>FROM my_spatial_table<br>WHERE ....<br><br>yields something like:<br><?xml version='1.0' encoding='UTF-8'?><br><kml xmlns='http://earth.google.com/kml/2.1'><br><Document><br><name>'my_title'</name><br><description>'description'</description><br><br><Style id='defaultStyle'><br>  <LineStyle><br>    <color>ff00ff00</color><br>    <width>1</width><br>  </LineStyle><br>  <PolyStyle><br>    <color>5f00ff00</color><br>  </PolyStyle><br></Style><br><br><Placemark><br>  <styleUrl>#defaultStyle</styleUrl><br>  <MultiGeometry><br>    <Point><br>      <coordinates>-122.319,47.164</coordinates><br>    </Point><br>    <Point><br>      <coordinates>-122.272,47.067</coordinates><br>    </Point><br>  </MultiGeometry><br></Placemark><br><br></Document><br></kml><br><br>Cheers,<br>Kevin<br><br><br><br>Stefan Schwarzer wrote:<br><blockquote type="cite">Hi there,<br></blockquote><blockquote type="cite">I made a tour on Google to look around if there exist some KML export tool. I've seen the Set_AsKML command; I've seen this <http://postgis.refractions.net/pipermail/postgis-users/2007-September/017070.html> dicussion; and have found that someone wrote a script <http://postgis3d.blogspot.com/2007/12/googleearth-export.html> for postgis; and a phyton script <http://dev.riverchange.org/google_earth/genshi_template.kml>. But it seems that there is no easy-way-to-go export/wrapper script, enabling for example the execution of pgsql2kml...<br></blockquote><blockquote type="cite">Or can someone give be a hint how to develop a KML export for a PHP based Data Portal?<br></blockquote><blockquote type="cite">Thanks for any help,<br></blockquote><blockquote type="cite">Stef<br></blockquote><blockquote type="cite">------------------------------------------------------------------------<br></blockquote><blockquote type="cite">_______________________________________________<br></blockquote><blockquote type="cite">postgis-users mailing list<br></blockquote><blockquote type="cite">postgis-users@postgis.refractions.net<br></blockquote><blockquote type="cite">http://postgis.refractions.net/mailman/listinfo/postgis-users<br></blockquote>_______________________________________________<br>postgis-users mailing list<br>postgis-users@postgis.refractions.net<br>http://postgis.refractions.net/mailman/listinfo/postgis-users<br></div></blockquote></div><br></div></body></html>