Following the pgRouting workshop here, I have the routing query below:
$sql = "SELECT gid, start_id AS source, end_id AS target, the_geom,
distance(the_geom, GeometryFromText(
'POINT(".$lonlat[0]." ".$lonlat[1].")', 4326)) AS dist
FROM ".TABLE."
WHERE the_geom && setsrid(
'BOX3D(".($lonlat[0]-0.1)."
".($lonlat[1]-0.1).",
".($lonlat[0]+0.1)."
".($lonlat[1]+0.1).")'::box3d, 4326)
ORDER BY dist LIMIT 1";
This query fails with the error: Query failed: ERROR: Operation on two geometries with different SRIDs
. Now, I've been looking around and came across this. I've tried the suggestions on this post, but the error persists. Any idea on how to fix this will be appreciated.
UPDATE:
Running SELECT st_srid(the_geom) FROM table_name
against my database table returns -1
. In my query and map, the assumed external projection is EPSG:4326
. Is changing this value likely to help? Is there any harm in changing the srid value directly in the database? How can I go about changing the srid value in the database if it doesn't present any risk?
UPDATE:
I had to change the srid of the column from the UNKNOWN
indicator of -1
to 4326
. The answer at this StackOverflow post was very helpful in this. Also, the question in this SE GIS post was instrumental in helping me in the right direction.