Answer the question
In order to leave comments, you need to log in
How to select objects from the database by geo coordinate with the condition that the coordinate is included in the object polygons?
I have a list of objects - city hospitals. Each hospital is assigned one or more service regions. Each region is a polygon described by geographic coordinates.
There are several hundred such hospitals in the database.
Tell me which database is better to use (PostgreSQL, Elasticsearch, etc.) and how to build a query to select and recommend to a person only those hospitals that belong to his region?
I specified postgre and elastic because I see that both have functionality for working with geodata, but I can’t figure out how to store data and how to make such a selection request.
Answer the question
In order to leave comments, you need to log in
PostgreSQL + PostGIS
PostGIS has its own extremely simple syntax, for example, you save objects as polygons and you can select all objects that contain the desired point with one command.
Region polygons can be taken from OSM, then a simple
SELECT
I can say for elasticsearch, there is a geoshape data type https://www.elastic.co/guide/en/elasticsearch/refe... everything is quite simple and fast. But with postgresql it will probably be easier, after all, this is a database, not a search engine, and it’s more expensive to keep a cluster for elastic from at least three machines.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question