i would like to create a GML using openlayers to send it to Geoserver to insert a new feature: After the end of draw i'm getting my feature

import GML3 from 'ol/format/GML3';

          function (this: any, e: any) {
            this.myFeature = e.feature;
            if (this.myFeature) {
           var geometry = this.myFeature.getGeometry();
           var coord = geometry.getCoordinates();

           var format = new GML3({
              featureType: 'p_bus_ndv',
              srsName: 'http://www.opengis.net/gml/srs/epsg.xml#2154',
              featureNS: "http://localhost:8080/SNCF"

          console.log('format', format);

            var gml3 = format.writeGeometry(geometryy, {
              featureProjection: 'urn:ogc:def:crs:EPSG::2154',
            console.log('gml3', gml3)


the first console.Log('format', format) gives me :

GML3 {dataProjection: undefined, defaultFeatureProjection: undefined, supportedMediaTypes: Array(1), xmlSerializer_: XMLSerializer, featureType: 'p_bus_ndv', …}
FEATURE_COLLECTION_PARSERS: {http://www.opengis.net/gml: {…}}
curve_: false
dataProjection: undefined
defaultFeatureProjection: undefined
featureNS: "http://localhost:8080/SNCF"
featureType: "p_bus_ndv"
hasZ: false
multiCurve_: true
multiSurface_: true
schemaLocation: "http://www.opengis.net/gml http://schemas.opengis.net/gml/3.1.1/profiles/gmlsfProfile/1.0.0/gmlsf.xsd"
srsName: "http://www.opengis.net/gml/srs/epsg.xml#2154"
supportedMediaTypes: ['application/gml+xml']
surface_: false
xmlSerializer_: XMLSerializer {}
[[Prototype]]: GMLBase

the second one console.log('gml3', gml3) gives me an error :

core.mjs:6494 ERROR TypeError: Cannot read properties of null (reading 'getAxisOrientation')
    at GML3.writePos_ (GML3.js:359:44)
    at GML3.writePoint (GML3.js:435:1)
    at GML3.<anonymous> (xml.js:224:1)
    at serialize (xml.js:402:1)
    at pushSerializeAndPop (xml.js:432:1)
    at GML3.writeGeometryElement (GML3.js:661:28)
    at GML3.writeGeometryNode (GML3.js:803:1)
    at XMLFeature.writeGeometry (XMLFeature.js:275:1)
    at HTMLButtonElement.<anonymous> (carte.component.ts:988:31)
    at _ZoneDelegate.invokeTask (zone.js:406:1)

i tried to give to the writeGeometry() the coords : i gote that :

<geom xmlns="http://www.opengis.net/gml"><Envelope srsName="http://www.opengis.net/gml/srs/epsg.xml#2154"><lowerCorner>158052.0133948687 5744845.11468696</lowerCorner><upperCorner>undefined undefined</upperCorner></Envelope></geom>

BUT what i'm looking for is something like that :

  <gml:Point srsName="http://www.opengis.net/gml/srs/epsg.xml#2154">+
          <gml:coordinates  decimal="." cs="," 

I changed the srs like that :

var format = new GML3({
              featureType: 'p_bus_ndv',
              srsName: 'http://www.opengis.net/gml/srs/epsg.xml#3857',
              featureNS: "http://localhost:8080/SNCF"

var gml3 = format.writeGeometry(geometryy, {
              featureProjection: 'urn:ogc:def:crs:EPSG::3857',

and i'm not geting the error of : Cannot read properties of null (reading 'getAxisOrientation')

but what i get when i do console.log('gml3', gml3):

<geom xmlns="http://www.opengis.net/gml"><Point srsName="http://www.opengis.net/gml/srs/epsg.xml#3857"><pos srsDimension="2">497808.297136346 6188369.461558701</pos></Point></geom>

BUT it's not what i'm looking for ; i'm looking for a gml fomat

  • You will need to define http://www.opengis.net/gml/srs/epsg.xml#2154 as equivalent to EPSG:2154 (which should also be defined via proj4 if necessary) see github.com/openlayers/openlayers/issues/…
    – Mike
    Jun 24 at 13:21
  • @Mike, i updated my question , can you take a look please
    – work
    Jun 24 at 13:47


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.