I am new to the GIS world but I have experience in programming. I am trying to build an app where users draw circles on a leaflet map and it returns the zipcodes "touched", but I think the right term is overlapped, by the circles. I have a table in PostGIS where I have uploaded the US census zipcodes; the column to query is a geometry type which return something like this when transformed as GeoJSON:
{"type":"MultiPolygon","crs":{"type":"name","properties":{"name":"EPSG:4269"}},"coordinates":[[[[-64.903808,17.679739],[-64.903804,17.679763],[-64.903799,17.679801],[-64.903796,17.67988],[-64.903793,17.679919],[-64.903788,17.679997],[-64.90377,17.680077],[-64.903756,17.680154],[-64.903744,17.680199],[-64.903729,17.68024],[-64.9037,17.68031]...}
And this is an example of the map with a circle drawn where I console log its radius and center coordinates (lat, lng):
So far I have tried this query:
SELECT *
FROM tl_2019_us_zcta510 AS b
WHERE ST_DWithin(b.geom,
ST_Transform(
ST_SetSrid(
ST_MakePoint(lat_from_leaflet,lng_from_leaflet)
,4269)
,4269)
,radius_from_leaflet);
This isn't returning the correct zipcodes because when I try with a small circle, for example, it doesn't return any row, but I am expecting at least one row.