我有这样的几何:
多边形:
01030000000100000030000000D041678234D45740EEC0A6315C3116405B320FC43FD45740A4488BCC38311640585A0D7048D457407F0AE62919311640D5CAA3944CD4574065351BC70D3116409133CA8D53D457408222038C00311640075AA14D58D45740ABA34807F0301640D79A2C7A5DD4574016355E4ADC30164049F67E1D5FD457401046214CD53016401BDE70FD61D4574039DF5741BE301640DF05296564D45740D2AA2F7EAB3016407E21844668D45740667C4B1D9C301640F1EB7EC76AD45740DE9A80DB97301640BFDF36FB6DD4574016EDDEDC92301640234AC97E71D457405641CAF294301640748831F872D457404CEBC16999301640B2C7F66874D457405E9EA3CCA7301640A4F36C387BD457408F41C6341D311640766B9BEC7BD4574019117F1E32311640E0C6A4437CD45740970B56AD3A311640B0EED3577CD457408A8930088F311640D89C02347DD45740E4DF1AD086321640BA52A8997DD457400BD1F61AF1321640F4E52FF17DD4574057EAB6895D331640D5AC735D7ED457406295BF1FD5331640BDCC4CCD7ED45740C921B9FE68341640912A0D997ED457402EFDB90174341640BD0537E175D4574013280731DB341640CF33C0096ED4574058E7A7C138351640D19B93536AD45740B8132D825D351640BD7A3FBA65D457406134DF9B763516404F362EB65ED 457401BE7FC7B93351640761A496B58D457404FA99894B3351640EC6C3C0752D45740B53D80E1D1351640002EC83F4FD457405759CE5BE13516404FE043B94ED457406C5BFB06EE351640BA6271AB4DD4574027420994F63516407651531448D457409D7B4FC20F361640524748E942D457401B3F7E0D26361640D6DF9E313FD457403BCA49FD35361640DEC4C4793DD45740D3D9C901393616407D5D6FB03CD457402B9EF3EC1F36164054FCEA0238D4574056015D8F2A3516401AA0D9C035D45740C531FBC29D34164062C23D1832D4574091D3DF8DC0331640579BF0382ED45740D8BEC6AFCF321640FAB9B7E028D45740B11DE7CB81311640DDA802A333D4574056D885EB5E311640D041678234D45740EEC0A6315C311640
点:
01010000005B78497D523416408ECC54B36BD45740
我的Postgre数据库脚本:
select ST_Contains(ST_AsText('01030000000100000030000000D041678234D45740EEC0A6315C
3116405B320FC43FD45740A4488BCC38311640585A0D7048D457407F0AE62919311640D5CAA
3944CD4574065351BC70D3116409133CA8D53D457408222038C00311640075AA14D58D45740
ABA34807F0301640D79A2C7A5DD4574016355E4ADC30164049F67E1D5FD457401046214CD53
016401BDE70FD61D4574039DF5741BE301640DF05296564D45740D2AA2F7EAB3016407E2184
4668D45740667C4B1D9C301640F1EB7EC76AD45740DE9A80DB97301640BFDF36FB6DD457401
6EDDEDC92301640234AC97E71D457405641CAF294301640748831F872D457404CEBC1699930
1640B2C7F66874D457405E9EA3CCA7301640A4F36C387BD457408F41C6341D311640766B9BE
C7BD4574019117F1E32311640E0C6A4437CD45740970B56AD3A311640B0EED3577CD457408A
8930088F311640D89C02347DD45740E4DF1AD086321640BA52A8997DD457400BD1F61AF1321
640F4E52FF17DD4574057EAB6895D331640D5AC735D7ED457406295BF1FD5331640BDCC4CCD
7ED45740C921B9FE68341640912A0D997ED457402EFDB90174341640BD0537E175D45740132
80731DB341640CF33C0096ED4574058E7A7C138351640D19B93536AD45740B8132D825D3516
40BD7A3FBA65D457406134DF9B763516404F362EB65ED457401BE7FC7B93351640761A496B5
8D457404FA99894B3351640EC6C3C0752D45740B53D80E1D1351640002EC83F4FD457405759
CE5BE13516404FE043B94ED457406C5BFB06EE351640BA6271AB4DD4574027420994F635164
07651531448D457409D7B4FC20F361640524748E942D457401B3F7E0D26361640D6DF9E313F
D457403BCA49FD35361640DEC4C4793DD45740D3D9C901393616407D5D6FB03CD457402B9EF
3EC1F36164054FCEA0238D4574056015D8F2A3516401AA0D9C035D45740C531FBC29D341640
62C23D1832D4574091D3DF8DC0331640579BF0382ED45740D8BEC6AFCF321640FAB9B7E028D
45740B11DE7CB81311640DDA802A333D4574056D885EB5E311640D041678234D45740EEC0A6
315C311640'),geometri) As smallinsmall, nama_file,geometri from table_survey.
结果始终为false。这应该是真的,因为我的观点是在(包含在)多边形中。
答案 0 :(得分:1)
根据ST_Contains
API reference,它需要两个几何作为输入。但在你的情况下,你传递的是文本和几何。
ST_Contains(ST_AsText(...),geometri)
相反,您需要使用ST_GeomFromText
进行一次转换,如下所示:
ST_Contains(ST_GeomFromText(ST_AsText(...)),geometri)
因此,最终查询可能如下所示:
select ST_Contains(ST_GeomFromText(ST_AsText('<replace_with_your_value>')),geometri) As smallinsmall, nama_file,geometri from table_survey;
答案 1 :(得分:0)
你的查询在语法上是错误的,如@learningloop所说,但你的坐标也是错误的。该点有坐标:
POINT(5.55109592209746 95.3190735176197)
但多边形有
POLYGON((95.3157049187059 5.54820325451167,95.3163919590383 5.54806823349114.......
当您构建多边形或点时,显然会反转坐标。
我不知道,如果多边形是错误的还是点,但是如果你反转点的坐标那么:
POINT(95.3190735176197 5.55109592209746)
ST_contains查询返回true:
SELECT ST_contains('01030000000100000030000000D041678234D45740EEC0A6315C3116405B320FC43FD45740A4488BCC38311640585A0D7048D457407F0AE62919311640D5CAA3944CD4574065351BC70D3116409133CA8D53D457408222038C00311640075AA14D58D45740ABA34807F0301640D79A2C7A5DD4574016355E4ADC30164049F67E1D5FD457401046214CD53016401BDE70FD61D4574039DF5741BE301640DF05296564D45740D2AA2F7EAB3016407E21844668D45740667C4B1D9C301640F1EB7EC76AD45740DE9A80DB97301640BFDF36FB6DD4574016EDDEDC92301640234AC97E71D457405641CAF294301640748831F872D457404CEBC16999301640B2C7F66874D457405E9EA3CCA7301640A4F36C387BD457408F41C6341D311640766B9BEC7BD4574019117F1E32311640E0C6A4437CD45740970B56AD3A311640B0EED3577CD457408A8930088F311640D89C02347DD45740E4DF1AD086321640BA52A8997DD457400BD1F61AF1321640F4E52FF17DD4574057EAB6895D331640D5AC735D7ED457406295BF1FD5331640BDCC4CCD7ED45740C921B9FE68341640912A0D997ED457402EFDB90174341640BD0537E175D4574013280731DB341640CF33C0096ED4574058E7A7C138351640D19B93536AD45740B8132D825D351640BD7A3FBA65D457406134DF9B763516404F362EB65ED457401BE7FC7B93351640761A496B58D457404FA99894B3351640EC6C3C0752D45740B53D80E1D1351640002EC83F4FD457405759CE5BE13516404FE043B94ED457406C5BFB06EE351640BA6271AB4DD4574027420994F63516407651531448D457409D7B4FC20F361640524748E942D457401B3F7E0D26361640D6DF9E313FD457403BCA49FD35361640DEC4C4793DD45740D3D9C901393616407D5D6FB03CD457402B9EF3EC1F36164054FCEA0238D4574056015D8F2A3516401AA0D9C035D45740C531FBC29D34164062C23D1832D4574091D3DF8DC0331640579BF0382ED45740D8BEC6AFCF321640FAB9B7E028D45740B11DE7CB81311640DDA802A333D4574056D885EB5E311640D041678234D45740EEC0A6315C311640',ST_geomfromtext('POINT(95.3190735176197 5.55109592209746)',0));