3

I'm using a PostGIS View as a layer to join multiple lookup tables.
I published this view through Geoserver to edit using WFS-T.

My first question is that this is right strategy using a VIEW as a layer for Geoserver's WFS-T or not?
Is there any way to serve normal table as a layer using some alternatives to lookup tables?

Second question, if I have to use view as a Geoserver's layer in this case, is it possible to edit this view using WFS-T?

  • you may need to write triggers for insert and update to view definition but it should work – simplexio May 16 '16 at 7:01
  • thanks simplexio! Yes, you were right. I used triggers, now it works! – Kims May 23 '16 at 3:29
5

While it's possible and common to publish views in GeoServer WFS, the access is limited to read-only usage, you won't be able to edit them.

GeoServer normally marks views as read only because it cannot find a primary key in them (pk is mandatory to generate the gml:id and to support featureid filters). To make the view editable, assuming you can find a truly unique column combination in it, you can setup the primary key metadata table: http://docs.geoserver.org/latest/en/user/data/database/primarykey.html

I've never tried to do so in PostGIS, so no guarantees, but in theory once you have that pk metadata table working, and you have add the insert and update triggers on the view, the view should become editable.

  • Thanks, Andrea. Even though I struggled few days with primary key metadata table, I could manage it. So, now it works. Actually, the problem was that I needed to define which metadata table i'm gonna use when I define datastore. – Kims May 23 '16 at 3:29
  • Could you please elaborate on "the insert and update triggers on the view"? I'm having the same problem that my WFS layer is read only and I don't really understand your solution. I have primary keys on my tables – Luffydude Jun 1 '16 at 15:39
  • Luffydude, you can reference to legitimatesounding.com/blog/…. It is about how to update view of postgresql. Before you apply this, you need to define metadata table in postgis and geoserver. – Kims Jun 29 '16 at 9:26

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.