我正试图在边界框中测试一个点。它一直以null而不是0或1返回,我正在做什么错了?
SET @g1 = GEOMFROMTEXT('POLYGON(
(-34.139468536232 18.303737037571,-34.139468536232 18.653342962429
,-33.849613463768 18.303737037571,-33.849613463768 18.653342962429))');
SET @g2 = GEOMFROMTEXT('POINT(-33.994541 18.478540)');
SELECT MBRCONTAINS(@g1,@g2);
答案 0 :(得分:1)
在你的多边形中,如果我在末尾再次重复第一个点(以包围多边形),它可以工作:
请参阅此SQLfiddle:http://sqlfiddle.com/#!2/d41d8/6663
SET @g1 = GEOMFROMTEXT('POLYGON(
(-34.139468536232 18.303737037571,-34.139468536232 18.653342962429
,-33.849613463768 18.303737037571,-33.849613463768 18.653342962429, -34.139468536232 18.303737037571))');
SET @g2 = GEOMFROMTEXT('POINT(-33.994541 18.478540)');
SELECT MBRCONTAINS(@g1,@g2);