network link / postgis / php

71 views
Skip to first unread message

goutosig

unread,
Jan 26, 2007, 9:18:06 AM1/26/07
to KML Discussions
hi all,

I am trying to render my postgis database into GE (the latest release contains an "askml()" function), but it seems like I have some trouble with my php code. here are my kml and php:

networkLink.kml:
Code:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
<Document>
<NetworkLink id="colza">
<!-- inherited from Feature element -->
<name>Colza</name> <!-- string -->
<visibility>1</visibility> <!-- boolean -->
<open>1</open> <!-- boolean -->

<description>Colza U-PSUD geographical Database</description> <!-- string -->
<Link>
<href>http://127.0.0.1/pgis2ge/colza2ge.php</href>
</Link>
<refreshVisibility>0</refreshVisibility> <!-- boolean -->
<flyToView>1</flyToView> <!-- boolean -->
</NetworkLink>
</Document>
</kml>



php file:

Code:
<?php

$con = pg_connect("host=localhost port=5432 dbname=colza user=xxx pasword=xxx");
$req = "SELECT id_pop,champ,asKml(geom) FROM populations where geom is not null and numpoints(geom)<=5";

$kml="";

foreach ($res as $row){

if ($row["champ"]=="t")
$type_pop = "Champ";
else
$type_pop = "Population hors champ";

$kml .= "<Placemark><name>id_pop ".$row["id_pop"]."</name><description>".$type_pop."</description>".$row["askml"]."</Placemark>";
}

$kml .= "</Document></kml>";
echo $kml;

pg_close($con);


?>



The askml() SQL returns something like this:
Code:
 
<LineString><coordinates>1.24424554235467,47.7351038733263,0 1.24424554235467,47.7351038733263,0</coordinates></LineString>



when I launch the kml file, GE returns this error: (traduced from french, sorry if the message is not very right)

extracting networlink failed
missing or erroneous file root element

Can anyone see what is wrong?
thanks in advance.

Guiguite.

ManoM

unread,
Jan 26, 2007, 11:26:41 AM1/26/07
to KML Discussions
Hi goutosig,

<LineString> is not a valid root element for your KML document. <LineString> must be wrapped in a Placemark, which ideally is wrapped in a KML element. So, what askml() should be returning is this:
Code:

<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
<Placemark>

<LineString>
<coordinates>1.24424554235467,47.7351038733263,0
1.24424554235467,47.7351038733263,0</coordinates>
</LineString>
  </Placemark>
</kml>



ManoM

ManoM

unread,
Jan 26, 2007, 11:31:28 AM1/26/07
to KML Discussions
I see that you've added another thread as a continuation of this one, so I'll answer on this thread:
http://bbs.keyhole.com/ubb/showthreaded.php/Cat/0/Number/771015/an/0/page/0#771015

Carlos Allingham

unread,
Feb 24, 2014, 12:17:39 PM2/24/14
to kml-support-g...@googlegroups.com
Hi Mano

I exactly have the same problem. and the link you provided here does not exist anymore. Would you kindly post the answer here as well?

Thanks!
C.A.
Reply all
Reply to author
Forward
0 new messages