select * from eploygon; select * from geometry_columns where f_table_name='eploygon'; ------------------------------------------------------------------------------------------------------------------------------------------------------- SELECT ST_GeomFromText('polygon ((117.812658 38.926816,117.813196 38.926622,117.812679 38.925415,117.812065 38.925792,117.812658 38.926816))', 4326 ); SELECT ST_AsText( ST_GeomFromText('polygon ((117.812658 38.926816,117.813196 38.926622,117.812679 38.925415,117.812065 38.925792,117.812658 38.926816))', 4326 ) ) SELECT gid,geom FROM public.eploygon s where ST_Intersects( ST_GeomFromText('polygon ((117.812658 38.926816,117.813196 38.926622,117.812679 38.925415,117.812065 38.925792,117.812658 38.926816))', 4326 ) , s.geom) ; SELECT ST_GeomFromGeoJSON('{"type":"LineString","coordinates":[[0,0],[1,1],[1,1],[2,2]]}'); select ST_GeomFromText(ST_AsText(ST_GeomFromGeoJSON('{"type":"LineString","coordinates":[[117.8136920928955,38.92978618569792],[117.81523704528809,38.926781511834875],[117.81620264053345,38.92432760043733],[117.81620264053345,38.92247459068792],[117.81620264053345,38.921489637879205],[117.81624555587769,38.92105558653837]]}')),4326); ------------------------------------------------------------------------------------------------------------------------------------------------------- --相交切割计算 SELECT ST_Intersection( ST_GeomFromText(ST_AsText(ST_GeomFromGeoJSON('{"type":"LineString","coordinates":[[117.8136920928955,38.92978618569792],[117.81523704528809,38.926781511834875],[117.81620264053345,38.92432760043733],[117.81620264053345,38.92247459068792],[117.81620264053345,38.921489637879205],[117.81624555587769,38.92105558653837]]}')),4326) , s.geom) FROM public.eploygon s where ST_Intersects( ST_GeomFromText(ST_AsText(ST_GeomFromGeoJSON('{"type":"LineString","coordinates":[[117.8136920928955,38.92978618569792],[117.81523704528809,38.926781511834875],[117.81620264053345,38.92432760043733],[117.81620264053345,38.92247459068792],[117.81620264053345,38.921489637879205],[117.81624555587769,38.92105558653837]]}')),4326) , s.geom) ; SELECT ST_Intersection( ST_GeomFromText(ST_AsText(ST_GeomFromGeoJSON('{"type":"Polygon","coordinates":[[[117.812658,38.926816],[117.813196,38.926622],[117.812679, 38.925415],[117.812065,38.925792],[117.812658,38.926816]]]}')),4326) , s.geom) FROM public.eploygon s where ST_Intersects( ST_GeomFromText(ST_AsText(ST_GeomFromGeoJSON('{"type":"Polygon","coordinates":[[[117.812658,38.926816],[117.813196,38.926622],[117.812679, 38.925415],[117.812065,38.925792],[117.812658,38.926816]]]}')),4326) , s.geom) ; SELECT ST_AsText(ST_Intersection( ST_GeomFromText(ST_AsText(ST_GeomFromGeoJSON('{"type":"Point","coordinates":[117.812658,38.926816]}')),4326) , s.geom)) as a FROM public.eploygon s; SELECT ST_Intersection( ST_GeomFromText(ST_AsText(ST_GeomFromGeoJSON('{"type":"Point","coordinates":[117.812658,38.926816]}')),4326) , s.geom) FROM public.eploygon s where ST_Intersects( ST_GeomFromText(ST_AsText(ST_GeomFromGeoJSON('{"type":"Point","coordinates":[117.812658,38.926816]}')),4326) , s.geom); ------------------------------------------------------------------------------------------------------------------------------------------------------- --相交计算 SELECT gid,geom FROM public.eploygon s where ST_Intersects( ST_GeomFromText(ST_AsText(ST_GeomFromGeoJSON('{"type":"LineString","coordinates":[[117.8136920928955,38.92978618569792],[117.81523704528809,38.926781511834875],[117.81620264053345,38.92432760043733],[117.81620264053345,38.92247459068792],[117.81620264053345,38.921489637879205],[117.81624555587769,38.92105558653837]]}')),4326) , s.geom) ; SELECT gid,geom FROM public.eploygon s where ST_Intersects( ST_GeomFromText(ST_AsText(ST_GeomFromGeoJSON('{"type":"Polygon","coordinates":[[[117.812658,38.926816],[117.813196,38.926622],[117.812679, 38.925415],[117.812065,38.925792],[117.812658,38.926816]]]}')),4326) , s.geom) ; SELECT gid,geom FROM public.eploygon s where ST_Intersects( ST_GeomFromText(ST_AsText(ST_GeomFromGeoJSON('{"type":"Point","coordinates":[117.812658,38.926816]}')),4326) , s.geom) ; ------------------------------------------------------------------------------------------------------------------------------------------------------- --相交计算测试输出 SELECT gid,geom FROM public.eploygon s where ST_Intersects( ST_GeomFromText(ST_AsText(ST_GeomFromGeoJSON('{"type":"LineString","coordinates":[[117.8136920928955,38.92978618569792],[117.81523704528809,38.926781511834875],[117.81620264053345,38.92432760043733],[117.81620264053345,38.92247459068792],[117.81620264053345,38.921489637879205],[117.81624555587769,38.92105558653837]]}')),4326) , s.geom) union select 111111 as gid,ST_GeomFromText(ST_AsText(ST_GeomFromGeoJSON('{"type":"LineString","coordinates":[[117.8136920928955,38.92978618569792],[117.81523704528809,38.926781511834875],[117.81620264053345,38.92432760043733],[117.81620264053345,38.92247459068792],[117.81620264053345,38.921489637879205],[117.81624555587769,38.92105558653837]]}')),4326); SELECT gid,geom FROM public.eploygon s where ST_Intersects( ST_GeomFromText(ST_AsText(ST_GeomFromGeoJSON('{"type":"Polygon","coordinates":[[[117.812658,38.926816],[117.813196,38.926622],[117.812679, 38.925415],[117.812065,38.925792],[117.812658,38.926816]]]}')),4326) , s.geom) union select 111111 as gid,ST_GeomFromText(ST_AsText(ST_GeomFromGeoJSON('{"type":"Polygon","coordinates":[[[117.812658,38.926816],[117.813196,38.926622],[117.812679, 38.925415],[117.812065,38.925792],[117.812658,38.926816]]]}')),4326) ; SELECT gid,geom FROM public.eploygon s where ST_Intersects( ST_GeomFromText(ST_AsText(ST_GeomFromGeoJSON('{"type":"Point","coordinates":[117.812658,38.926816]}')),4326) , s.geom) union select 111111 as gid,ST_GeomFromText(ST_AsText(ST_GeomFromGeoJSON('{"type":"Point","coordinates":[117.812658,38.926816]}')),4326);