Enable PostGIS
(Moved from https://github.com/openstreetmap/operations/issues/1317).
As part of the conversation at https://github.com/openstreetmap/openstreetmap-website/issues/6512, I would like PostGIS to be enabled in the OSM website.
Currently the absence of PostGIS has led to some features being implemented with ugly workarounds, sometimes not functional at all. These are some examples that have been mentioned, although whether PostGIS is appropriate for all of them is still being debated:
- https://github.com/openstreetmap/openstreetmap-website/issues/2396
- https://github.com/openstreetmap/openstreetmap-website/issues/6567
- https://github.com/openstreetmap/openstreetmap-website/issues/6568
- List of nearby users.
To clarify: this is not about using PostGIS generally for everything in OSM. It's for use in small, ancillary features, which over time can be expanded.
nearby changesets (to the user's profile location) are slow and often time out.
I wouldn't use PostGIS just for this. Bounding boxes can be handled reasonably well without postgis. Do you have an link to the timeout issue?
Anti-vandalism restrictions are a better use-case as a point-in-polygon check is difficult to do in the DB without postgis. I do wonder if checking every geom and child geom for each object edit is a good idea. A relation edit can easily have tens of thousands of nodes as descendants.
I recommend staying away from computing any distances with PostGIS. It runs into all sorts of projection problems unless you only have points, and even the point one is a problem because can't be indexed easily.
I do wonder if checking every geom and child geom for each object edit is a good idea. A relation edit can easily have tens of thousands of nodes as descendants.
I'm also expecting abysmal performance in that case, in particular for our worst case candidates with 15k ways and almost 500k nodes (Lake Huron). Maybe we need to move some of the more expensive anti-vandalism checks to an asynchronous background job, rather than blocking the upload for minutes. Like I mentioned in https://github.com/openstreetmap/openstreetmap-website/issues/6568#issuecomment-3587441347 this all highly depends on the actual requirements.
That's good to know 👍 Happy to discard the idea of diving into the component objects of relations. Or at least discard doing synchronously. Perhaps a background job is suitable, but that can be discussed at a later date in a relevant issue (probably https://github.com/openstreetmap/openstreetmap-website/issues/6568).
I have split the examples a bit more in the description, and added the caveat that the suitability of PostGIS for each case is still being discussed. This included linking related issues.
Specifically now, I want to focus on the anti-vandalism features. The first one is https://github.com/openstreetmap/openstreetmap-website/issues/6567, which I understand should be suitable for implementation with PostGIS as it's a point-in-polygon problem.
Strategically, if we get a first, localised feature out, we'll start seeing real-world use and getting a better idea of what is possible. From there, we can start considering features that were out of the question before, or simplify existing ones.