0

I am pretty new to WFS/WFS-T and need help with some suggestions on how the following requirement can be implemented. We have a need to insert a feature into a PostGIS database based on the following condition.

The user provides a geometry along with other data to be inserted. But before doing so:

1.Check if there is any existing feature in the table whose geometry intersects with the one that is provided. 2.If there is any, throw an exception/error. 3.If successful, then insert record and return success message.

I read that OGC Filters can be used to query intersections, and WFS-T can be used to insert features, but I do not know how to implement query and an insert together. Can some one shed some light on how this can be done?

0

WFS-T does not support such conditional transactions. Filters are used for selecting features which are fetched by GetFeature and they have the same effect as using WHERE in the SELECT statement in SQL. For reaching what you want you must do some additional operation either on the client of PostGIS side, or both. Here are some suggestions:

On the client side you could create a reference layer by reading the existing situation from WFS by making a GetFeature request with BBOX that covers the area of the new features. Before creating the Insert transaction you should analyze if new features intersect with features on the reference layer. However, with concurrent users that would not be totally reliable because someone may have inserted new features after the reference layer was created from WFS.

On the PostGIS side you can create a trigger that prevents inserts into the table if it would create intersection. For WFS-T this would mean that if your client is sending an Insert request with intersecting geometry the WFS server would try to save it into PostGIS. However, because of the trigger PostGIS will deny the insert and WFS server will send a message like <wfs:Message>Insert Action Failed</wfs:Message> back to client.

I would recommend to combine both two: the client side spatial analysis would find most intersections and inform user immediately so they could make edits and correct the input, and the trigger on the database would eliminate all remaining bad features.

| improve this answer | |

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.