Opened 11 years ago

Closed 11 years ago

#5243 closed defect (invalid)

Java: Geometry from KML contains only one hole

Reported by: aschultz Owned by: warmerdam
Priority: normal Milestone:
Component: OGR_SF Version: 1.10.0
Severity: normal Keywords: libkml kml
Cc:

Description (last modified by Kyle Shannon)

  • usage from Java,
  • reading of Feature/ Geometry from KML/ KMZ,
  • KML contains one outerBoundaryIs and more than one innerBoundaryIs (holes)
  • retrieving Feature, getting Geometry from Feature:

Geometry geometry = layer.GetFeature(flaechenNum).GetGeometryRef() and

  • geometry.GetGeometryCount() never (!) returns > 2 (outerBoundaryIs plus one innerBoundaryIs)

Attachments (1)

dreiLochKML.kml (2.5 KB ) - added by aschultz 11 years ago.
KML with 3 holes within it

Download all attachments as: .zip

Change History (5)

by aschultz, 11 years ago

Attachment: dreiLochKML.kml added

KML with 3 holes within it

comment:1 by Kyle Shannon, 11 years ago

Description: modified (diff)

comment:2 by Kyle Shannon, 11 years ago

Cc: winkey added
Component: JavaBindingsOGR_SF
Keywords: libkml added; java holes removed
Owner: changed from Even Rouault to warmerdam
Priority: highnormal
Severity: criticalnormal

It appears this affects both the libkml driver and the kml driver, but differently. The kml driver does not count children within the innerBoundaryIs tag, taking only the first linear ring. I think this can be fixed. However the problem seems to be in libkml for the other issue. The return value from get_innerboundaryis_array_size() is returning 1, not 3. That doesn't explain to me why it is taking the last ring though. That is the behavior I am seeing, but I am not familiar with libkml. cc'ing winkey, the libkml driver maintainer.

comment:3 by Kyle Shannon, 11 years ago

I have a potential fix for the kml driver. I will try to get it checked in tonight. Are you using the LIBKML or the KML driver?

comment:4 by Kyle Shannon, 11 years ago

Cc: winkey removed
Resolution: invalid
Status: newclosed

Your kml is invalid. Each LinearRing should be enclosed in it's own InnerBoundaryIs tag:

<innerBoundaryIs>
                                <LinearRing>
                                        <coordinates>
                                                8.306647893041781,51.9283648788167,0 8.303301461380841,51.9279537734092,0 8.30369157623962,51.92698491446221,0 8.303005551623469,51.9258647427409,0 8.3054782324056,51.9236326185688,0 8.31431811845221,51.9235249518909,0 8.31388623625422,51.9241747127537,0 8.310283658683209,51.9251973184679,0 8.307906684525991,51.9273141449465,0 8.306647893041781,51.9283648788167,0
                                        </coordinates>
                                </LinearRing>
            </innerBoundaryIs>
            <innerBoundaryIs>
                                <LinearRing>
                                        <coordinates>
                                                8.301882403238089,51.92723511856389,0 8.2995786437591,51.9261198251423,0 8.300059663157031,51.9253399533129,0 8.2984435332139,51.9237358895736,0 8.304329151384129,51.92365482925289,0 8.302098026433249,51.9254245202705,0 8.3026814973786,51.92710939567449,0 8.301882403238089,51.92723511856389,0
                                        </coordinates>
                                </LinearRing>
            </innerBoundaryIs>
            <innerBoundaryIs>
                                <LinearRing>
                                        <coordinates>
                                                8.29681353015981,51.9260308792332,0 8.294073191306779,51.9243620601781,0 8.29715334525083,51.92378617992311,0 8.299101684320281,51.9251313279737,0 8.299148343277819,51.9251461005549,0 8.29681353015981,51.9260308792332,0
                                        </coordinates>
                                </LinearRing>
                        </innerBoundaryIs>

Even though google earth can read and parse this it is invalid. See:

https://developers.google.com/kml/documentation/kmlreference#innerboundaryis

Note: See TracTickets for help on using tickets.