我尝试了以下SQL命令:
CREATE TABLE places(
lat_lng geography(Point,4326),
place_name varchar(50)
);
CREATE INDEX places_lat_lng_idx ON places USING gist(lat_lng);
INSERT INTO places values ('POINT(-126.4 45.32)', 'Food Bar1');
INSERT INTO places values ('POINT(-126.4 47.32)', 'Food Bar2');
INSERT INTO places values ('POINT(-125.4 47.42)', 'Food Bar3');
SELECT place_name, ST_AsText(lat_lng) as point
FROM places WHERE places.lat_lng &&
ST_MakeEnvelope(-130.0, 44.0,
-100.0, 46.7, 4326);
结果是:
place_name | point
------------+---------------------
Food Bar1 | POINT(-126.4 45.32)
Food Bar2 | POINT(-126.4 47.32)
Food Bar3 | POINT(-125.4 47.42)
我觉得这里有问题,因为ymax的值是46.7,但是"Food Bar2"和"Food Bar3"的ymax分别是47.32和47.42。问题出在哪里呢?