0

我正在尝试在边界框中测试一个点。它不断返回 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);
4

1 回答 1

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);
于 2013-01-29T22:07:13.273 回答