[Geoserver-users] KML from Geoserver to Openlayers

Hi,

I try to use KML produced by Geoserver (1.6.4) in OpenLayers (2.6) but the
XML generated is not accepted (silently alas). I checked the file and I
eventually found 2 'mistakes' in the KML. Here's 2 fragments where the
first (corrected) works while the second (directly from Geoserver) fails :

<kml xmlns="http://earth.google.com/kml/2.2&quot;&gt;
   <Document>
      <name>edfgeo:clientassoc</name>
      <Style id="GeoServerStyleclientassoc.nfm--730056c2_11c0891a30b_-21f4">
         <IconStyle>
            <color>ff33ffff</color>
            <colorMode>normal</colorMode>
            <Icon>
              
<href>http://maps.google.com/mapfiles/kml/pal4/icon25.png&lt;/href&gt;
            </Icon>
         </IconStyle>
    ...
    
and

<?xml version="1.0" encoding="UTF-8"?>
<kml >
   <Document>
      <name>edfgeo:clientassoc</name>
      <Style id="GeoServerStyleclientassoc.nfm--730056c2_11c0891a30b_-21f4">
          <IconStyle>
            <Icon/>
         </IconStyle>
         <IconStyle>
            <color>ff33ffff</color>
            <colorMode>normal</colorMode>
            <Icon>
              
<href>http://maps.google.com/mapfiles/kml/pal4/icon25.png&lt;/href&gt;
            </Icon>
         </IconStyle>
     ...
     
In the second fragment the default namespace is missing and a 'void'
IconStyle appears.

Has anybody got this problem before ?

Cheers

Laurent
--
View this message in context: http://www.nabble.com/KML-from-Geoserver-to-Openlayers-tp19199815p19199815.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

That does sound like a bug, could you report it? And include the data you're using if possible.

Could you try one thing though? It looks like GeoServer wasn't able to find a good id to use, so it's just automatically creating a pretty bad one. If you're using a database could you define a primary key for the table you're using? And let me know if that helps the problem at all. Even if it does fix it this is still a bug, we should be able to handle it, but I want to figure out if the problem is general or just specific to datasets without good ids.

best regards,

Chris

LaurentPierre wrote:

Hi,

I try to use KML produced by Geoserver (1.6.4) in OpenLayers (2.6) but the
XML generated is not accepted (silently alas). I checked the file and I
eventually found 2 'mistakes' in the KML. Here's 2 fragments where the
first (corrected) works while the second (directly from Geoserver) fails :

<kml xmlns="http://earth.google.com/kml/2.2&quot;&gt;
   <Document>
      <name>edfgeo:clientassoc</name>
      <Style id="GeoServerStyleclientassoc.nfm--730056c2_11c0891a30b_-21f4">
         <IconStyle>
            <color>ff33ffff</color>
            <colorMode>normal</colorMode>
            <Icon>
              <href>http://maps.google.com/mapfiles/kml/pal4/icon25.png&lt;/href&gt;
            </Icon>
         </IconStyle>
    ...
    
and

<?xml version="1.0" encoding="UTF-8"?>
<kml >
   <Document>
      <name>edfgeo:clientassoc</name>
      <Style id="GeoServerStyleclientassoc.nfm--730056c2_11c0891a30b_-21f4">
          <IconStyle>
            <Icon/>
         </IconStyle>
         <IconStyle>
            <color>ff33ffff</color>
            <colorMode>normal</colorMode>
            <Icon>
              <href>http://maps.google.com/mapfiles/kml/pal4/icon25.png&lt;/href&gt;
            </Icon>
         </IconStyle>
     ...
     In the second fragment the default namespace is missing and a 'void'
IconStyle appears.

Has anybody got this problem before ?

Cheers

Laurent

Hi Chris

Chris Holmes-4 wrote:

That does sound like a bug, could you report it? And include the data
you're using if possible.

I do it asap

Chris Holmes-4 wrote:

Could you try one thing though? It looks like GeoServer wasn't able to
find a good id to use, so it's just automatically creating a pretty bad
one. If you're using a database could you define a primary key for the
table you're using? And let me know if that helps the problem at all.
Even if it does fix it this is still a bug, we should be able to handle
it, but I want to figure out if the problem is general or just specific
to datasets without good ids.

I defined a pk on my table and if the generated id's are nicer the 2
problems in the KML remained the same :frowning:

<?xml version="1.0" encoding="UTF-8"?>
<kml>
   <Document>
      <name>edfgeo:clientassoc</name>
      <Style id="GeoServerStyleclientassoc.647">
         <IconStyle>
            <Icon/>
         </IconStyle>
         <IconStyle>
            <color>ffa34e98</color>
            <colorMode>normal</colorMode>
            <Icon>
              
<href>http://maps.google.com/mapfiles/kml/pal4/icon25.png&lt;/href&gt;
            </Icon>
         </IconStyle>
         <IconStyle>
            <colorMode>normal</colorMode>
            <Icon>
              
<href>http://maps.google.com/mapfiles/kml/pal4/icon25.png&lt;/href&gt;
            </Icon>
         </IconStyle>
      </Style>
      <Placemark id="clientassoc.647">
         <description><![CDATA[<table border='1'>

Cheers

Laurent
--
View this message in context: http://www.nabble.com/KML-from-Geoserver-to-Openlayers-tp19199815p19203398.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

I just checked Geoserver generated KML from another application and the XML
has the same flaws. I didn't remark it as it was used by GoogleMaps which
didn't complain as OpenLayers did.

Cheers

Laurent

--
View this message in context: http://www.nabble.com/KML-from-Geoserver-to-Openlayers-tp19199815p19203615.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

Darn. If you could include the sld you're using too that could be good. Though we should be including the namespace. And should also detect if a style is going to be empty and not use it in that case.

Also, in case you haven't found it, http://geoserver.org/display/GEOSDOC/1+Reporting+Issues has instructions on reporting things.

We also might consider reporting it on OpenLayers too, it would be good if they were more flexible on the KML they read, as there's a lot of bad KML out there that Google handles fine. Things like extra empty xml elements and lack of namespace I feel like it should be able to handle.

Thanks for bringing this to our attention.

Chris

LaurentPierre wrote:

Hi Chris

Chris Holmes-4 wrote:

That does sound like a bug, could you report it? And include the data you're using if possible.

I do it asap

Chris Holmes-4 wrote:

Could you try one thing though? It looks like GeoServer wasn't able to find a good id to use, so it's just automatically creating a pretty bad one. If you're using a database could you define a primary key for the table you're using? And let me know if that helps the problem at all. Even if it does fix it this is still a bug, we should be able to handle it, but I want to figure out if the problem is general or just specific to datasets without good ids.

I defined a pk on my table and if the generated id's are nicer the 2
problems in the KML remained the same :frowning:

<?xml version="1.0" encoding="UTF-8"?>
<kml>
   <Document>
      <name>edfgeo:clientassoc</name>
      <Style id="GeoServerStyleclientassoc.647">
         <IconStyle>
            <Icon/>
         </IconStyle>
         <IconStyle>
            <color>ffa34e98</color>
            <colorMode>normal</colorMode>
            <Icon>
              <href>http://maps.google.com/mapfiles/kml/pal4/icon25.png&lt;/href&gt;
            </Icon>
         </IconStyle>
         <IconStyle>
            <colorMode>normal</colorMode>
            <Icon>
              <href>http://maps.google.com/mapfiles/kml/pal4/icon25.png&lt;/href&gt;
            </Icon>
         </IconStyle>
      </Style>
      <Placemark id="clientassoc.647">
         <description><![CDATA[<table border='1'>

Cheers

Laurent

Chris Holmes-4 wrote:

Darn. If you could include the sld you're using too that could be good.
  Though we should be including the namespace. And should also detect
if a style is going to be empty and not use it in that case.

I changed from my style to a standard one in geoserver (poi) and it didn't
change anything

Chris Holmes-4 wrote:

Also, in case you haven't found it,
http://geoserver.org/display/GEOSDOC/1+Reporting+Issues has instructions
on reporting things.

I'll do it this we

Chris Holmes-4 wrote:

We also might consider reporting it on OpenLayers too, it would be good
if they were more flexible on the KML they read, as there's a lot of bad
KML out there that Google handles fine. Things like extra empty xml
elements and lack of namespace I feel like it should be able to handle.

Thanks for bringing this to our attention.

I reported to OpenLayers but I had no answers yet. But you're right they
should be more flexible : I'll tell them in the next post.

Cheers and thank you for your help

Laurent
--
View this message in context: http://www.nabble.com/KML-from-Geoserver-to-Openlayers-tp19199815p19204286.html
Sent from the GeoServer - User mailing list archive at Nabble.com.