I'm trying to use the data that is retuned from the nomatim API to perform a simple geospatial search. The users search for a place, i.e Leeds, and this returns simple info, including the following bounding box:
"boundingbox": [
"53.6983747",
"53.9458558",
"-1.8004213",
"-1.2903452"
],
Using this, I should be able to create a bounding box using the Postgis function:
geometry ST_MakeEnvelope(double precision xmin, double precision ymin, double precision xmax, double precision ymax, integer srid=unknown);
However, when I do this, I am unable to get correct geometries that I can then use, and plug into another function wherein I check if a point is within that geometry.
As far as I can tell, the SRID for the OSM data is 3857. When I perform the following:
ST_MakeEnvelope(53.6983747,-1.8004213,53.9458558,-1.2903452, 3857);
And then perform a search on this, I have to add 500000 metres to the ST_DWithin to be able to get a point which is right in the centre.
Does anyone know If there is a better way to approach this, or spot any mistakes in this? I have tried a couple different approaches and I cannot find any more accurate than this one.
For reference, this is the search I've been performing:
Select * from geometries
where ST_DWithin(ST_Transform(geom,27700),ST_Transform(ST_SetSRID(ST_MakePoint(1.546033, 53.798075),3857),27700), 70)
at 75 I get the Newcastle box, and at 80 I get the Leeds box, and that point is in Leeds. I am very confused.