[postgis-users] Broken Casting In Spatial Query

adam at spatialsystems.org adam at spatialsystems.org
Sat Dec 27 07:23:49 PST 2008


I have a spatial query where casting is working and one that doesn't. 
In the first example "ec" is being cast to double precision from
varchar.  In the second example I'm trying to do the same thing but I
get this error: ERROR: invalid input syntax for type double precision: "
"  SQL state: 22P02  

What could the problem be?

Works here:
SELECT
  max(ec::double precision) as max_ec,
FROM
  best_ec
WHERE
  location
  && SetSRID( 'BOX3D( $long_min $lat_min, $long_max $lat_max )'::box3d,
4326) AND
  distance_spheroid(
    location,
    SetSRID( MakePoint( $long, $lat ), 4326 ),
    'SPHEROID[\"WGS_1984\",6378137,298.257223563]'
    ) < 300 ");


Doesn't work here:
SELECT
  X(drive_test_data.grid) AS x,
  Y(drive_test_data.grid) AS y,
  max(drive_test_data.rssi::double precision) AS max_rssi,
  count(drive_test_data.rssi) AS rssi_count
FROM
  (
    SELECT
      SnapToGrid(best_ec.location, 0.0002) AS grid,
      best_ec.ec as rssi
    FROM
      best_ec
  ) AS drive_test_data
GROUP BY
  x,
  y;









More information about the postgis-users mailing list