CREATE TABLE geom_table (id bigserial, geom geometry(polygon, 4326)); insert into geom_table (geom) values (ST_GeomFromText('POLYGON((170 40, -170 40, -170 30, 170 30, 170 40))', 4326)); insert into geom_table (geom) values (ST_GeomFromText('POLYGON((170 40, 190 40, 190 30, 170 30, 170 40))', 4326)); insert into geom_table (geom) values (ST_GeomFromText('POLYGON((-190 40, -170 40, -170 30, -190 30, -190 40))', 4326));
# SELECT id, ST_AsText(geom) as area from geom_table; id | area ----+---------------------------------------------------- 1 | POLYGON((170 40,-170 40,-170 30,170 30,170 40)) 2 | POLYGON((170 40,190 40,190 30,170 30,170 40)) 3 | POLYGON((-190 40,-170 40,-170 30,-190 30,-190 40)) (3 rows)
SELECT id, ST_AsText(geom) as area, ST_Distance(geom, ST_GeomFromText('Point(175 35)', 4326)) as distance from geom_table; id | area | distance ----+----------------------------------------------------+---------- 1 | POLYGON((170 40,-170 40,-170 30,170 30,170 40)) | 5 2 | POLYGON((170 40,190 40,190 30,170 30,170 40)) | 0 3 | POLYGON((-190 40,-170 40,-170 30,-190 30,-190 40)) | 345 (3 rows)
SELECT id, ST_AsText(geom) as area, ST_Distance(geom, ST_GeomFromText('Point(185 35)', 4326)) as distance from geom_table; id | area | distance ----+----------------------------------------------------+---------- 1 | POLYGON((170 40,-170 40,-170 30,170 30,170 40)) | 15 2 | POLYGON((170 40,190 40,190 30,170 30,170 40)) | 0 3 | POLYGON((-190 40,-170 40,-170 30,-190 30,-190 40)) | 355 (3 rows)
SELECT id, ST_AsText(geom) as area, ST_Distance(geom, ST_GeomFromText('Point(-185 35)', 4326)) as distance from geom_table; id | area | distance ----+----------------------------------------------------+---------- 1 | POLYGON((170 40,-170 40,-170 30,170 30,170 40)) | 15 2 | POLYGON((170 40,190 40,190 30,170 30,170 40)) | 355 3 | POLYGON((-190 40,-170 40,-170 30,-190 30,-190 40)) | 0 (3 rows)
SELECT id, ST_AsText(geom) as area, ST_Distance(geom, ST_GeomFromText('Point(-175 35)', 4326)) as distance from geom_table; id | area | distance ----+----------------------------------------------------+---------- 1 | POLYGON((170 40,-170 40,-170 30,170 30,170 40)) | 5 2 | POLYGON((170 40,190 40,190 30,170 30,170 40)) | 345 3 | POLYGON((-190 40,-170 40,-170 30,-190 30,-190 40)) | 0 (3 rows)
N35E175 | N35E185 | N35W175 | N35W185 | |
¡ | ☓ | ☓ | ☓ | ☓ |
¢ | ¡û | ¡û | ☓ | ☓ |
£ | ☓ | ☓ | ¡û | ¡û |
# SELECT id, ST_AsText(geom) as area, ST_Distance(geom, ST_GeomFromText('Polygon((175 35,185 35,185 30,175 30,175 35))', 4326)) as distance from geom_table; id | area | distance ----+----------------------------------------------------+---------- 1 | POLYGON((170 40,-170 40,-170 30,170 30,170 40)) | 5 2 | POLYGON((170 40,190 40,190 30,170 30,170 40)) | 0 3 | POLYGON((-190 40,-170 40,-170 30,-190 30,-190 40)) | 345 (3 rows)
CREATE TABLE geom2_table (id bigserial, geom geometry(multipolygon, 4326)); insert into geom2_table (geom) values (ST_GeomFromText('MULTIPOLYGON( ((170 40, 180 40, 180 30, 170 30, 170 40)), ((-180 40, -170 40, -170 30, -180 30, -180 40)))' , 4326));
SELECT id, ST_AsText(geom) as area, ST_Distance(geom, ST_GeomFromText('Point(-175 35)', 4326)) as distance from geom2_table; id | area | distance ----+--------------------------------------------------------------------------------------------------+---------- 1 | MULTIPOLYGON(((170 40,180 40,180 30,170 30,170 40)),((-180 40,-170 40,-170 30,-180 30,-180 40))) | 0 (1 row)
SELECT id, ST_AsText(geom) as area, ST_Distance(geom, ST_GeomFromText('Point(175 35)', 4326)) as distance from geom2_table; id | area | distance ----+--------------------------------------------------------------------------------------------------+---------- 1 | MULTIPOLYGON(((170 40,180 40,180 30,170 30,170 40)),((-180 40,-170 40,-170 30,-180 30,-180 40))) | 0 (1 row)
SELECT id, ST_AsText(geom) as area, ST_Distance(geom, ST_GeomFromText('Point(180 35)', 4326)) as distance from geom2_table; id | area | distance ----+--------------------------------------------------------------------------------------------------+---------- 1 | MULTIPOLYGON(((170 40,180 40,180 30,170 30,170 40)),((-180 40,-170 40,-170 30,-180 30,-180 40))) | 0 (1 row)ÆüÉÕÊѹ¹Àþ¾å¤ÎÅÀ¤â¶ë·Á¤Ë´Þ¤Þ¤ì¤ë(µ÷Î¥0)¤Èǧ¼±¤µ¤ì¤ë
insert into geom2_table (geom) values (ST_GeomFromText('MULTIPOLYGON( ((170 40, 190 40, 190 30, 170 30, 170 40)), ((-190 40, -170 40, -170 30, -190 30, -190 40)) , 4326));
SELECT id, ST_AsText(geom) as area, ST_Distance(geom, ST_GeomFromText('Point(-175 35)', 4326)) as distance from geom2_table; id | area | distance ----+--------------------------------------------------------------------------------------------------+---------- 1 | MULTIPOLYGON(((170 40,180 40,180 30,170 30,170 40)),((-180 40,-170 40,-170 30,-180 30,-180 40))) | 0 2 | MULTIPOLYGON(((170 40,190 40,190 30,170 30,170 40)),((-190 40,-170 40,-170 30,-190 30,-190 40))) | 0 (2 rows)
SELECT id, ST_AsText(geom) as area, ST_Distance(geom, ST_GeomFromText('Point(175 35)', 4326)) as distance from geom2_table; id | area | distance ----+--------------------------------------------------------------------------------------------------+---------- 1 | MULTIPOLYGON(((170 40,180 40,180 30,170 30,170 40)),((-180 40,-170 40,-170 30,-180 30,-180 40))) | 0 2 | MULTIPOLYGON(((170 40,190 40,190 30,170 30,170 40)),((-190 40,-170 40,-170 30,-190 30,-190 40))) | 0 (2 rows)
SELECT id, ST_AsText(geom) as area, ST_Distance(geom, ST_GeomFromText('Point(180 35)', 4326)) as distance from geom2_table; id | area | distance ----+--------------------------------------------------------------------------------------------------+---------- 1 | MULTIPOLYGON(((170 40,180 40,180 30,170 30,170 40)),((-180 40,-170 40,-170 30,-180 30,-180 40))) | 0 2 | MULTIPOLYGON(((170 40,190 40,190 30,170 30,170 40)),((-190 40,-170 40,-170 30,-190 30,-190 40))) | 0 (2 rows)¤¤Á¤ó¤Èʬ³ä¤·¤Æ¤â¡¢¤¤¤¤²Ã¸º¤Ëʬ³ä¤·¤Æ¤âƱ¤¸
insert into geom_table (geom) values ( ST_GeomFromText('POLYGON((-20 20, 20 20, 20 -20, -20 -20, -20 20),(-10 10, 10 10, 10 -10, -10 -10, -10 10))', 4326));
SELECT id, ST_AsText(geom) as area from geom_table where ST_Distance(geom, ST_GeomFromText('Point(-15 0)', 4326)) = 0; id | area ----+------------------------------------------------------------------------------------ 4 | POLYGON((-20 20,20 20,20 -20,-20 -20,-20 20),(-10 10,10 10,10 -10,-10 -10,-10 10)) (1 row)
SELECT id, ST_AsText(geom) as area from geom_table where ST_Distance(geom, ST_GeomFromText('Point(15 0)', 4326)) = 0; id | area ----+------------------------------------------------------------------------------------ 4 | POLYGON((-20 20,20 20,20 -20,-20 -20,-20 20),(-10 10,10 10,10 -10,-10 -10,-10 10)) (1 row)
SELECT id, ST_AsText(geom) as area from geom_table where ST_Distance(geom, ST_GeomFromText('Point(0 0)', 4326)) = 0; id | area ----+------ (0 rows)