I have two tables one in SRID 4326 (containing MULTIPOLYGON
) and the other in SRID 32188 (containing MULTILINESTRING
).
I am trying to select all polygons from t1
which are within 100 meters from any lines in t2
.
This is the query I am making:
SELECT * FROM table1 AS t1, table2 AS t2
WHERE ST_DWithin(
ST_Transform(t1.geom, 3857),
ST_Transform(t2.geom, 3857),
100);
Unfortunately, it doesn't work, and pgAdmin4 doesn't give me a useful error. Instead, it disconnects from the DB as soon as I run the query (so it's not a time out situation):
I also tried with two tables in the same SRID, but I still have the problem... What am I doing wrong here?
EDIT: In order to try an narrow down the problem, I took @JGH suggestion and adapted it to test ST_DWITHIN against a point instead of the multilinestrings of table2, and it works fine.
SELECT * FROM table1 t1
WHERE EXISTS (
SELECT FROM table2 t2
WHERE ST_DWithin(t1.geom, ST_MakePoint(-73.63,45.52)::geography,100)
);
However, I tested with table2 containing only one straight line (still a multilinestrings geometry though), and the client crashes. Could it bee related to this: https://gis.stackexchange.com/questions/31923/why-is-the-database-connection-lost-on-every-query ?