I have a PostgreSQL database with circle shaped objects called 'spots'. Each of those objects has latitude, longitude and a variable radius, information that I need to define this circles. Given an specific coordinate, I select all the objects that contain that given point.
The thing is that I want to switch to PostGIS this stuff because of performance. I've started documenting about PostGIS but as a complete newbie I still have some doubts about data types.
What is the best way to store this kind of information in PostGIS? I don't need precision, because the radius can only have a limited lenght of 100km. I've thought about creating a polygon using
ST_Buffer and save this into a
geometry field in the 'spots' table. I also do not need an exact circle, a decagon is enough. The test code I'm using to know if this is meeting my needs is the following
create table spots (name varchar, geom geometry); -- Insert a 2500m radius polygon with center in given coordenates insert into spots values ( 'Test', ST_Buffer( ST_SetSRID(ST_MakePoint(39.63467934415986, 2.6308822631835938), 4326), 2500, 4 ) );
I have several doubts about this code. Once the geometric figure is created with
ST_Buffer, is it still preserving it's position? If I provide the SRID code with given lat-lon coordinates, do I need to use
ST_SetSRID or it's completely unnecessary?
The thing is that I've discovered that using
ST_Contains is always returning true, with no matter about the lat-lon values I'm providing to the function.