我是 postGIS 的新手,在这些查询中打破了我的头脑......我需要一些帮助
我有两个表,第一个country(cid int,countryname text,coutrycoordinates geometry)
,另一个是state(sid int,statename text,statecoordinates geometry)
我必须使用ST_contains
国内的州写一个查询,但是我的查询不起作用
现在假设我已经插入
INSERT into country VALUES (
1,'country1',
'POLYGON ((1 5,4 5,4 7,1 7,1 5))');
INSERT into state VALUES (
1,'state1',
'POLYGON ((2 5,3 5,3 6,2 6,2 5))');
工作并被插入,但是为几何列存储的值是这种类型的
01030000000100000005000000000000000000F03F000000000000F03F000000000000F03F0000000000001040000000000000104000000000000010400000000000001040000000000000F03F000000000000F03F000000000000F03F for country and
010300000001000000050000000000000000000040000000000000004000000000000000400000000000000840000000000000084000000000000008400000000000000840000000000000004000000000000000400000000000000040 for state in the postreSQL db
我有一个带有 2 个文本字段的网页和一个带有和的下拉菜单,ST_Contains
单击 ST_Intersects
时的提交按钮应显示状态是否位于该国家/地区。
select c.cid from country as c, state as s where ST_Contains('POLYGON ((1 1,1 4,4 4,4 1,1 1))', 'POLYGON ((2 2,2 3, 3 3, 3 2, 2 2))')
以上工作,但选择了两个表中的所有行交叉连接,而不仅仅是那个c.cid.
select c.cid from country as c, state as s where ST_Contains(
01030000000100000005000000000000000000F03F000000000000F03F000000000000F03F0000000000001040000000000000104000000000000010400000000000001040000000000000F03F000000000000F03F000000000000F03F, 010300000001000000050000000000000000000040000000000000004000000000000000400000000000000840000000000000084000000000000008400000000000000840000000000000004000000000000000400000000000000040)
如果这是查询,则返回错误
NOTICE: identifier "f03f000000000000f03f000000000000f03f0000000000001040000000000000104000000000000010400000000000001040000000000000f03f000000000000f03f000000000000f03f" will be truncated to "f03f000000000000f03f000000000000f03f000000000000104000000000000"
ERROR: syntax error at or near "F03F000000000000F03F000000000000F03F0000000000001040000000000000104000000000000010400000000000001040000000000000F03F000000000000F03F000000000000F03F"
LINE 2: 01030000000100000005000000000000000000F03F000000000000F03F00...
^
这是在我编写此代码的 php 页面中执行的那个
我可以知道我哪里错了。