In order to have a fully interactive map, I would like to be able to save some drawn features (in a second step with some attributes that may be grabbed through an input mask form or pop-up) on a Leaflet map to a PostgreSQL (PostGIS) database table.
I am using Lighttpd as webserver + geoserver (based on jetty) to serve my base vector layer on which I'd want to write the new features.
What I have read and tried:
Based on this code : https://bl.ocks.org/danswick/d30c44b081be31aea483 it is possible to "export" the features as a GeoJson string to a local file.
Related resources that I've tried but doesn't work:
Leaflet.draw: add attributes and save to file
And with this, I'm able to print out to the console a GeoJSON string that is ready to be written in a database field but I do not know how to technically communicate it to the database:
Related to the Geoserver documentation (the "demo" menu on the left column), it is not possible to write a GeoJson string to the connected PostgreSQL database: WFS-T only allows to write features using the GML format...
I remember (long time ago, so it is blurry in my mind) some functions with OpenLayer that could do some parsing on a GeoJson string to make it "GML ready" but I can not find any equivalent within Leaflet.
Am I stuck or is there an elegant way to store drawn vector features from a Leaflet map into a PostgreSQL database (based, or not, on Geoserver)?
If not possible, which other (light) techniques would be nice to use?
The raw code example:
The answer given in the thread on which this question was marked as duplicate ( How to add Geoserver WFS to Leaflet JS Application ) is to use the Leaflet-WFST plugin: https://github.com/Flexberry/Leaflet-WFST.
When I tried the first command:
npm i leaflet-wfst --save
I get an error "command not found". So it doesn't work in my really simple case where I use Geoserver. What I would like to find is a small function that converts a geojson object (which I already have!) to a GML one (which is the only format available with Geoserver WFST protocol).