1

I'm trying to paint parcels retrieved from Spanish land register by their API (as described here, PDF Spanish only!). It's an WFS service (complying INSPIRE) and offers the information as GML versión 3.2.1 files.

Here an example response (using this call) to retrieve parcels by their cadaster reference:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!--Parcela Catastral de la D.G. del Catastro.-->
<!--La precisión es la que corresponde nominalmente a la escala de captura de la cartografía-->
<FeatureCollection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:cp="http://inspire.ec.europa.eu/schemas/cp/4.0" xmlns:gmd="http://www.isotc211.org/2005/gmd" xsi:schemaLocation="http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd http://inspire.ec.europa.eu/schemas/cp/4.0 http://inspire.ec.europa.eu/schemas/cp/4.0/CadastralParcels.xsd" xmlns="http://www.opengis.net/wfs/2.0" timeStamp="2022-08-30T19:29:52" numberMatched="1" numberReturned="1">
  <member>
    <cp:CadastralParcel gml:id="ES.SDGC.CP.3662001TF3136S">
      <cp:areaValue uom="m2">3814</cp:areaValue>
      <cp:beginLifespanVersion>2021-06-09T00:00:00</cp:beginLifespanVersion>
      <cp:endLifespanVersion xsi:nil="true" nilReason="http://inspire.ec.europa.eu/codelist/VoidReasonValue/Unpopulated"></cp:endLifespanVersion>
      <cp:geometry>
        <gml:MultiSurface gml:id="MultiSurface_ES.SDGC.CP.3662001TF3136S" srsName="http://www.opengis.net/def/crs/EPSG/0/25830">
          <gml:surfaceMember>
            <gml:Surface gml:id="Surface_ES.SDGC.CP.3662001TF3136S.1" srsName="http://www.opengis.net/def/crs/EPSG/0/25830">
              <gml:patches>
                <gml:PolygonPatch>
                <gml:exterior>
                    <gml:LinearRing>
                      <gml:posList srsDimension="2" count="68">233565.81 4016077.37 233581.88 4016079.67 233582.39 4016079.64 233582.41 4016079.64 233582.93 4016079.61 233582.95 4016079.79 233584.21 4016095.89 233590.37 4016086.81 233608.95 4016076.64 233622.4 4016059.04 233634.4 4016039.96 233635.42 4016038.33 233637.7 4016034.42 233639.69 4016030.68 233639.92 4016030.24 233641.36 4016028.14 233641.81 4016027.47 233643.7 4016024.87 233644.86 4016023.27 233646.95 4016020.39 233645.01 4016006.5 233655.45 4015995.96 233655.14 4015995.64 233651.48 4015991.83 233650.44 4015990.75 233648.45 4015992.4 233640.59 4015999.13 233639.85 4015999.81 233639.12 4016000.48 233637.69 4016001.88 233636.31 4016003.33 233634.97 4016004.81 233633.68 4016006.34 233633.17 4016006.97 233628.43 4016014.77 233626.25 4016018.35 233623.19 4016023.38 233623.04 4016023.63 233619.94 4016026.88 233615.37 4016031.67 233614.08 4016033.01 233613.46 4016033.66 233610.82 4016035.98 233602.71 4016043.12 233600.17 4016045.28 233596.47 4016048.66 233591.23 4016053.38 233589.87 4016052.05 233584.62 4016052.25 233584.33 4016052.26 233581.97 4016049.04 233578.37 4016045.27 233576.52 4016043.93 233574.11 4016042.19 233569.38 4016039.9 233564.32 4016038.46 233559.09 4016037.93 233553.84 4016038.31 233548.39 4016039.75 233543.94 4016041.75 233537.63 4016037.54 233535.81 4016033.81 233535.16 4016033.58 233530.41 4016023.48 233532.15 4016035.61 233543.76 4016066.93 233552.15 4016070.9 233565.81 4016077.37</gml:posList>
                    </gml:LinearRing>
                </gml:exterior>
                </gml:PolygonPatch>
              </gml:patches>
            </gml:Surface>
          </gml:surfaceMember>
        </gml:MultiSurface>
      </cp:geometry>
      <cp:inspireId>
        <Identifier xmlns="http://inspire.ec.europa.eu/schemas/base/3.3">
          <localId>3662001TF3136S</localId>
          <namespace>ES.SDGC.CP</namespace>
        </Identifier>
      </cp:inspireId>
      <cp:label>01</cp:label>
      <cp:nationalCadastralReference>3662001TF3136S</cp:nationalCadastralReference>
      <cp:referencePoint>
        <gml:Point gml:id="ReferencePoint_ES.SDGC.CP.3662001TF3136S" srsName="http://www.opengis.net/def/crs/EPSG/0/25830"> 
          <gml:pos>233584.35 4016065.6</gml:pos>
        </gml:Point>
      </cp:referencePoint>
    </cp:CadastralParcel>
  </member>
</FeatureCollection>

Right now I manually parse the XML file and make a vector feature, but would be more elegant to make the feature from GML32 format. To do so, I tried to get the parcel geometry from GML, but without success:

const parser = new ol.format.GML32({
    featureNS: 'http://inspire.ec.europa.eu/schemas/cp',
    featureType: 'CadastralParcel'
});
console.log(parser.readFeature(wfsCPxml));

I also tried using WFS format, but same null result (after changing manually surfaceMember to featureMember as mentioned here):

const wfs = new ol.format.WFS({
  gmlFormat: new ol.format.GML32({
    featureNS: 'http://inspire.ec.europa.eu/schemas/cp',
    featureType: 'CadastralParcel'
  })
});
console.log(parser.readFeature(wfsCPfeaturexml));

Here is the related jsfiddle, any idea what I'm doing wrong?

3
  • surprised your example request works, as it doesn't follow WFS syntax. It should be: http://ovc.catastro.meh.es/INSPIRE/wfsCP.aspx?service=WFS&version=2.0.0&request=GetFeature&STOREDQUERY_ID=GetParcel&REFCAT=3662001TF3136S&SRSNAME=urn:ogc:def:crs:EPSG::25830
    – nmtoken
    Sep 5, 2022 at 15:18
  • I assume the answer as to why GML 3.2.1 can't be parsed by ol.format.GML32 doesn't work for you will be based on the fact that cp:CadastralParcel is a complex feature, and OpenLayers is expecting simple features
    – nmtoken
    Sep 5, 2022 at 15:28
  • The example request is copied from the docs and does work (it had an typo so). I don't know which map server they are using, GetCapabilities doesn't give any hint on that. Reading the docs on GML32 it's not clear to me if complex features aren't supported (I just opened an issue on that).
    – geraldo
    Sep 5, 2022 at 19:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.