<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[postrges如何查询当前位置是否在gis的围栏中]]></title><description><![CDATA[<p dir="auto">1、安装postgres扩展postgis</p>
<pre><code>$ sudo apt-get install postgis 
</code></pre>
<p dir="auto">2、进入数据库</p>
<pre><code>$ sudo -u postgres psql 
</code></pre>
<p dir="auto">3、数据库添加扩展</p>
<pre><code># 添加空间插件
CREATE EXTENSION postgis;
CREATE EXTENSION postgis_topology;
</code></pre>
<p dir="auto">4、sql方法使用</p>
<pre><code>SELECT  ST_Contains( ST_MakePolygon(ST_GeomFromText('LINESTRING ( 121.312350 30.971457 , 121.156783 31.092221 , 121.353250 31.278195 , 121.509125 31.157431 , 121.312350 30.971457 ) ')) ,st_point(121.632378,31.07106) );
</code></pre>
<p dir="auto">5、例子</p>
<pre><code>select * from	table where 
ST_Contains( ST_MakePolygon(ST_GeomFromText('LINESTRING (121.312350 30.971457 , 121.156783 31.092221 , 121.353250 31.278195 , 121.509125 31.157431 , 121.312350 30.971457) ')),st_point(CAST(mobile_message_intro.position::json-&gt;&gt;0 as DECIMAL(10,2)),CAST(mobile_message_intro.position::json-&gt;&gt;1 as DECIMAL(10,2))) )=true
</code></pre>
]]></description><link>http://an.forum.genostack.com/topic/78/postrges如何查询当前位置是否在gis的围栏中</link><generator>RSS for Node</generator><lastBuildDate>Sat, 13 Jun 2026 14:28:34 GMT</lastBuildDate><atom:link href="http://an.forum.genostack.com/topic/78.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 01 Sep 2020 03:08:48 GMT</pubDate><ttl>60</ttl></channel></rss>