I've just used osm2pgsql to import osm data to a pgsql database, using lat long option to store it in WGS84  projection, however i would like to use ST_Dwithin to select nodes close to a random point, and for some reason when i try that directly on the WGS84 data it will return wrong results, but will work if i reproject it in web mercator, what am i missing to avoid the reprojection?


    select ST_AsText(way),
    ST_X(ST_AsText(way)) as X, 
    ST_Y(ST_AsText(way)) as Y,
    railway
    from planet_osm_point 
    where railway IS NOT NULL 
    and ST_DWithin(ST_Transform(way,3785),ST_Transform(ST_SetSRID( ST_MakePoint(-1.631560, 48.107485), 4326),3785), 500)
    limit 1000

[![Mercator projection output][1]][1]

    select ST_AsText(way),
    ST_X(ST_AsText(way)) as X, 
    ST_Y(ST_AsText(way)) as Y,
    railway
    from planet_osm_point 
    where railway IS NOT NULL 
    and ST_DWithin(way,ST_SetSRID( ST_MakePoint(-1.631560, 48.107485), 4326), 500)
    limit 1000

[![WGS84 projection output][2]][2]

As you can see the outputs from WGS84 projection aren't even close to the point i'm lookin at, and i can't figure out why when i am using the same geometry type for st_DWIthin, is there a step i'm missing?
(also i am not showing all of the results here, the mercator projection gets me about 154 results, while WGS84 projection goes beyond 1000)

  [1]: https://i.sstatic.net/7sJxi.png
  [2]: https://i.sstatic.net/Fdhu7.png