1

I retrieve a response from the wfs_gnde from BKG in Germany using the following URL and request.

http : // sg.geodatenzentrum.de / wfs_gnde

<GetFeature
 version='1.1.0'
 service='WFS'
 traverseXlinkDepth='*'
 traveserXlinkExpiry='0' 
 outputFormat="text/xml; subtype=gml/2.1.2"
 xmlns:wfs='http://www.opengis.net/wfs'
 xmlns:ogc='http://www.opengis.net/ogc'
 xmlns:gml='http://www.opengis.net/gml'
 xmlns:gn='http://www.geodatenzentrum.de/gnde'
 xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
 xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd http://www.geodatenzentrum.de/gnde">
 <wfs:Query typeName="gn:GnObjekt" srsName='EPSG:25832'>
  <ogc:Filter>
   <ogc:PropertyIsEqualTo>
    <ogc:PropertyName>gn:hatRs/gn:Rs/gn:rs</ogc:PropertyName>
    <ogc:Literal>09</ogc:Literal>
   </ogc:PropertyIsEqualTo>
  </ogc:Filter>
 </wfs:Query>
</GetFeature>

The response contains a large polygon for the country Bavaria minus a hole around the Austrian enclave Jungholz.

...
                            <gn:geom>
                                <!--Inlined geometry 'Dlm_DEBKGDL20000E5HO_GN_GEOM'-->
                                <gml:Polygon gid="Dlm_DEBKGDL20000E5HO_GN_GEOM" srsName="EPSG:25832">
                                    <gml:outerBoundaryIs>
                                        <gml:LinearRing srsName="EPSG:25832">
                                            <gml:coordinates decimal="." cs="," ts=" ">609423.316,5267949.300 
...
609423.316,5267949.300</gml:coordinates>
                                        </gml:LinearRing>
                                    </gml:outerBoundaryIs>
                                    <gml:innerBoundaryIs>
                                        <gml:LinearRing srsName="EPSG:25832">
                                            <gml:coordinates decimal="." cs="," ts=" ">609423.316,5267949.300 609508.419,5267990.905 609581.849,5268140.369 609699.671,5268380.194 609799.205,5268501.992 609857.511,5268603.574 609883.278,5268648.465 609935.938,5268690.781 610138.041,5268853.183 610215.606,5269011.808 610292.370,5269172.901 610313.600,5269225.619 610354.391,5269303.056 610448.533,5269355.096 610497.659,5269411.550 610558.972,5269521.101 610637.263,5269572.834 610703.263,5269576.754 610766.979,5269562.129 610792.629,5269613.058 610804.361,5269679.146 610792.566,5269742.352 610748.708,5269823.438 610749.868,5269900.109 610722.016,5269973.576 610688.470,5270068.077 610660.669,5270138.902 610651.261,5270215.369 610618.124,5270288.733 610581.783,5270391.110 610579.789,5270494.151 610578.869,5270541.709 610590.290,5270634.437 610709.804,5270610.868 610773.361,5270598.334 611016.484,5270692.610 611199.917,5270763.740 611282.878,5270916.188 611395.367,5271143.131 611417.484,5271187.513 611274.937,5271176.302 611155.838,5271184.570 611065.955,5271185.474 611002.187,5271202.742 610946.651,5271204.311 610882.832,5271224.221 610845.842,5271223.505 610790.767,5271201.294 610740.618,5271197.681 610713.890,5271213.022 610697.015,5271265.557 610695.839,5271326.326 610702.692,5271381.964 610725.237,5271443.839 610589.158,5271455.191 610453.524,5271443.575 610296.082,5271371.599 610200.991,5271329.800 610095.050,5271280.798 610046.061,5271282.847 609941.152,5271283.813 609880.278,5271235.488 609818.924,5271128.048 609693.976,5271028.892 609511.054,5270950.824 609358.154,5270953.857 609212.795,5270981.514 609073.745,5270990.305 609035.586,5271000.555 608978.981,5271086.368 608874.266,5271077.347 608652.871,5271058.074 608526.225,5271046.630 608469.399,5271027.507 608401.489,5271053.944 608344.054,5271017.150 608302.155,5271065.235 608217.505,5271068.881 608176.220,5271085.261 608109.027,5271074.708 608053.261,5271088.165 608026.031,5271061.206 607941.664,5271050.321 607899.954,5271020.439 607882.534,5270964.597 607846.544,5270912.359 607838.013,5270875.191 607803.974,5270858.673 607751.321,5270779.682 607792.156,5270718.362 607854.654,5270698.428 607921.074,5270612.494 607934.397,5270538.747 607840.808,5270526.361 607723.979,5270485.773 607682.960,5270420.223 607599.444,5270385.160 607507.151,5270291.121 607544.009,5270247.395 607591.089,5270209.684 607636.275,5270170.004 607660.339,5270124.122 607678.685,5270074.267 607704.530,5270036.144 607827.665,5269824.367 607838.509,5269799.272 607823.477,5269777.738 607779.450,5269757.573 607747.044,5269735.702 607741.963,5269698.911 607756.599,5269641.259 607781.036,5269576.072 607813.120,5269514.896 607842.135,5269490.002 607897.140,5269464.382 607922.759,5269437.842 607935.202,5269393.666 607936.250,5269339.613 607963.657,5269250.347 608194.820,5269229.120 608404.653,5269226.191 608624.531,5269220.461 608697.484,5269218.877 608774.273,5268967.633 608824.435,5268801.782 608956.041,5268453.704 609035.528,5268269.442 609068.194,5268156.992 609073.010,5268139.308 609101.865,5268041.971 609120.039,5267980.390 609135.024,5267928.736 609146.839,5267886.010 609167.146,5267817.478 609387.581,5267930.912 609423.316,5267949.300</gml:coordinates>
                                        </gml:LinearRing>
                                    </gml:innerBoundaryIs>
                                </gml:Polygon>
                            </gn:geom>
...

I try to read the resulting GML2 to retrieve a feature object using the GMLFilterDocument.java class from the org.geotools.gml Package.

Other results from BKG wfs_gnde are parsed correctly using GMLFilterDocument but this specific geometry fails in SubHandlerPolygon.class with "Topology Error building polygon".

What is wrong with the Polygon, as QGIS can not find any errors and I can only spot the fact that both LinearRing structures (outerBoundaryIs and innerBoundaryIs) start and end with the same tangent point (being the peak of Sorgschrofen at 1636m) ?

polygon start and end with hole

  • 2
    I found the following Explanation from 2006 regarding Polygons Re: [Geotools-gt2-users] Poligon with hole ... Please helpme sourceforge.net/p/geotools/mailman/message/11050679 which refers to the OGC Simple Feature Specification for SQL Rev 1.1 portal.opengeospatial.org/files/?artifact_id=829 2.1.10 Polygon 3. No two rings in the boundary cross, the rings in the boundary of a Polygon may intersect at a Point but only as a tangent : ∀ P ∈ Polygon, ∀ c1, c2 ∈ P.Boundary(), c1 ≠ c2, ∀ p, q ∈ Point, p, q ∈ c1, p ≠ q, [ p ∈ c2 ⇒ q ∉ c2] – stefan123t Jun 25 at 9:50
  • I would probably use the WFSDatastore rather than hand rolling your own stack. Likely issue is with the two rings touching - can't be sure with out the actual polygon – Ian Turton Jun 25 at 10:17
  • Ian thanks but I am maintaining a grown application, where only the results for that state has changed recently and now produce the given Topology error. – stefan123t Jun 25 at 11:28
  • I wonder if I should normalize the LinearRings before creating the Geometry object while parsing ? – stefan123t Jun 25 at 12:07
  • can you add the relevant parts of the polygon? – Ian Turton Jun 25 at 12:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.