【发布时间】:2013-07-20 19:41:53
【问题描述】:
我是 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 页面中执行的那个
请问我哪里出错了。
【问题讨论】:
-
你看到的十六进制代码叫做Well-known binary (WKB)
标签: php postgresql postgis pgadmin