R
R
Roma Zvarich2017-01-16 18:13:48
Cartography
Roma Zvarich, 2017-01-16 18:13:48

How to store information about the boundaries of the city in the database?

Hello.
There is a site catalog of sports facilities, which is still being developed (I'm not a programmer, I use the services of freelancers) I
plan to make a search for objects with the possibility of additional coverage of the territory around the city within the specified radius For example, as done on the
OLX.UA website ( screenshot )
at the moment there is a solution that I do NOT like myself (I repeat that I am not a programmer):

  1. Determine the coordinate of the city center
  2. Determine the coordinate of the farthest point of the border (it seems that you can pull it from OSM)
  3. Measure the distance between them and the reference point, calculate the radius from the center to the farthest point

The option is bad because cities do not have round borders.
I would like to consult, is there a better way to implement this functionality?
Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
freeExec, 2017-01-17
@freeExec

If you are not using a spatial database, then it's time to switch to it.
Compares two geometries and checks if they are closer than the specified number of units - postgis.net/docs/ST_DWithin.html

A
Alexander Taratin, 2017-01-16
@Taraflex

mysql check if point is in polygon

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question