-1

I am trying to access a point and get the inpsectors name for it . The query by it`s self works fine but I need the Longitude and Latitude to be variables as the Lng and Lat will change .

This is what I have

DO $$
DECLARE
   longitude text := -4.323966436509;
   latitiude text := 51.857052145748;
BEGIN 
    --RAISE NOTICE '% %', longitude, latitiude;
    SELECT inspectors_name as Name  
    FROM ccc_transport_streets."Inspectors_Areas_polygon" 
    WHERE ST_Contains(geom, ST_Transform (ST_GeometryFromText('POINT(lonitude latitiude)',4326), 27700));
END $$;

However I get the error :-

ERROR: parse error - invalid geometry HINT: "POINT(lo" <-- parse error at position 8 within geometry

I have changed the data type to float too. Any ideas pretty new Postgresql .

0

1 Answer 1

1

To create point use st_makepoint() function. Then set SRID for point and then check if polygon contains that point.

DO $$
    DECLARE
       longitude numeric := -4.323966436509;
       latitiude numeric := 51.857052145748;
    BEGIN 
        --RAISE NOTICE '% %', longitude, latitiude;
        SELECT inspectors_name as Name  
        FROM ccc_transport_streets."Inspectors_Areas_polygon" 
        WHERE ST_Contains(geom, ST_setSRID (st_makePOINT (longitude, latitiude),4326)
);
    END $$;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.