SQL query for point-in-polygon using PostgreSQL

后端 未结 2 1056
无人共我
无人共我 2020-12-16 00:33

I have the following simple table:

CREATE TABLE tbl_test
(
  id serial NOT NULL,
  poly polygon NOT NULL
)
WITH (OIDS=FALSE);

I then try to

2条回答
  •  抹茶落季
    2020-12-16 01:17

    Ok, weird, I found out the following much simpler syntax works:

    insert into tbl_test (poly) values ('(0,0),(0,10),(10, 10), (0, 0)')
    
    select * from tbl_test where poly @> '(2, 8)'
    

    But I'm struggling to figure out the difference between these sets of functions and operators. Does this shorter syntax (which isn't really OpenGIS compliant) take advantage of the same spatial indexes, etc.?

提交回复
热议问题