PostgreSQL 地图两点之间,经纬度距离计算, PostGIS方式计算, 电子围栏功能实现;PostgreSQL空间数据存储扩展 PostGIS

PostGIS在对象关系型数据库PostgreSQL上增加了存储管理空间数据的能力,相当于Oracle的spatial部分。PostGIS最大的特点是符合并且实现了OpenGIS的一些规范,是最著名的开源GIS数据库。

PostGIS的版权被纳入到GNU的GPL中,也就是说任何人可以自由得到PostGIS的源码并对其做研究和改进。正是由于这一点,PostGIS得到了迅速的发展,越来越多的爱好者和研究机构参与到PostGIS的应用开发和完善当中。

PostGIS是由Refractions Research
Inc开发的,Refractions是一家GIS和数据库咨询公司,Refraction公司最初是在PostgreSQL的基础上研究空间数据库的实
现,由于PostgreSQL所提供的空间数据类型和功能远远不能满足GIS的需求,研究工作经常陷入到进退维谷的境地,最终的结果往往是耗费了大量的人
力物力,而产品却极其复杂并且性能低下。这些原因直接或间接促成PostGIS项目的实施。

PostGIS介绍 - PostgreSQL空间数据存储扩展 PostGIS

PostGIS在对象关系型数据库PostgreSQL上增加了存储管理空间数据的能力,相当于Oracle的spatial部分。PostGIS最大的特点是符合并且实现了OpenGIS的一些规范,是最著名的开源GIS数据库。

PostGIS的版权被纳入到GNU的GPL中,也就是说任何人可以自由得到PostGIS的源码并对其做研究和改进。正是由于这一点,PostGIS得到了迅速的发展,越来越多的爱好者和研究机构参与到PostGIS的应用开发和完善当中。

PostGIS是由Refractions Research Inc开发的,Refractions是一家GIS和数据库咨询公司,Refraction公司最初是在PostgreSQL的基础上研究空间数据库的实 现,由于PostgreSQL所提供的空间数据类型和功能远远不能满足GIS的需求,研究工作经常陷入到进退维谷的境地,最终的结果往往是耗费了大量的人 力物力,而产品却极其复杂并且性能低下。这些原因直接或间接促成PostGIS项目的实施。

安装插件PostGIS

1、导入repo(导入过程省略)

2、安装pg-10(安装过程省略)

3、检查插件

yum search postgis

在这里插入图片描述

# yum search postgis

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
================================================ N/S matched: postgis =================================================
postgis-docs.x86_64 : Extra documentation for PostGIS
postgis-utils.x86_64 : The utils for PostGIS
postgis23_10-client.x86_64 : Client tools and their libraries of PostGIS
postgis23_10-devel.x86_64 : Development headers and libraries for PostGIS
postgis23_10-docs.x86_64 : Extra documentation for PostGIS
postgis23_10-utils.x86_64 : The utils for PostGIS
postgis24_10-client.x86_64 : Client tools and their libraries of PostGIS
postgis24_10-devel.x86_64 : Development headers and libraries for PostGIS
postgis24_10-docs.x86_64 : Extra documentation for PostGIS
postgis24_10-gui.x86_64 : GUI for PostGIS
postgis24_10-utils.x86_64 : The utils for PostGIS
postgis25_10-client.x86_64 : Client tools and their libraries of PostGIS
postgis25_10-devel.x86_64 : Development headers and libraries for PostGIS
postgis25_10-docs.x86_64 : Extra documentation for PostGIS
postgis25_10-gui.x86_64 : GUI for PostGIS
postgis25_10-utils.x86_64 : The utils for PostGIS
postgis25_12-client.x86_64 : Client tools and their libraries of PostGIS
postgis25_12-devel.x86_64 : Development headers and libraries for PostGIS
postgis25_12-docs.x86_64 : Extra documentation for PostGIS
postgis25_12-gui.x86_64 : GUI for PostGIS
postgis25_12-utils.x86_64 : The utils for PostGIS
postgis30_10-client.x86_64 : Client tools and their libraries of PostGIS
postgis30_10-devel.x86_64 : Development headers and libraries for PostGIS
postgis30_10-docs.x86_64 : Extra documentation for PostGIS
postgis30_10-gui.x86_64 : GUI for PostGIS
postgis30_10-utils.x86_64 : The utils for PostGIS
postgis30_12-client.x86_64 : Client tools and their libraries of PostGIS
postgis30_12-devel.x86_64 : Development headers and libraries for PostGIS
postgis30_12-docs.x86_64 : Extra documentation for PostGIS
postgis30_12-gui.x86_64 : GUI for PostGIS
postgis30_12-utils.x86_64 : The utils for PostGIS
SFCGAL.x86_64 : C++ wrapper library around CGAL for PostGIS
pgrouting_10.x86_64 : Routing functionality for PostGIS
pgrouting_12.x86_64 : Routing functionality for PostGIS
postgis.x86_64 : Geographic Information Systems Extensions to PostgreSQL
postgis23_10.x86_64 : Geographic Information Systems Extensions to PostgreSQL
postgis24_10.x86_64 : Geographic Information Systems Extensions to PostgreSQL
postgis25_10.x86_64 : Geographic Information Systems Extensions to PostgreSQL
postgis25_12.x86_64 : Geographic Information Systems Extensions to PostgreSQL
postgis30_10.x86_64 : Geographic Information Systems Extensions to PostgreSQL
postgis30_12.x86_64 : Geographic Information Systems Extensions to PostgreSQL

  Name and summary matches only, use "search all" for everything.

4、安装插件

yum install postgis.x86_64 postgis24_10.x86_64 -y --skip-broken 

等待插件安装完成即可
在这里插入图片描述

在数据库中启用插件

-- 添加空间插件
CREATE EXTENSION postgis;
CREATE EXTENSION postgis_topology;

在这里插入图片描述

启用插件之后,public下会新增一个表spatial_ref_sys
在这里插入图片描述

坐标点相关函数使用

坐标系 AddGeometryColumn

POINT数据类型支持
AddGeometryColumn函数使用 https://postgis.net/docs/AddGeometryColumn.html

Synopsis
text AddGeometryColumn(varchar table_name, varchar column_name, integer srid, varchar type, integer dimension, boolean use_typmod=true);

text AddGeometryColumn(varchar schema_name, varchar table_name, varchar column_name, integer srid, varchar type, integer dimension, boolean use_typmod=true);

text AddGeometryColumn(varchar catalog_name, varchar schema_name, varchar table_name, varchar column_name, integer srid, varchar type, integer dimension, boolean use_typmod=true);

在这里插入图片描述
函数测试示例

-- Create schema to hold data
CREATE SCHEMA my_schema;
-- Create a new simple PostgreSQL table
CREATE TABLE my_schema.my_spatial_table (id serial);

-- Describing the table shows a simple table with a single "id" column.
postgis=# \d my_schema.my_spatial_table
							 Table "my_schema.my_spatial_table"
 Column |  Type   |                                Modifiers
--------+---------+-------------------------------------------------------------------------
 id     | integer | not null default nextval('my_schema.my_spatial_table_id_seq'::regclass)

-- Add a spatial column to the table
SELECT AddGeometryColumn ('my_schema','my_spatial_table','geom',4326,'POINT',2);

-- Add a point using the old constraint based behavior
SELECT AddGeometryColumn ('my_schema','my_spatial_table','geom_c',4326,'POINT',
离线地图_openstreetmap_postgresql_瓦片 离线地图_openstreetmap_postgresql_postgis_mapnik_osm2pgsql_osm数据 写于20150414 关于软件地址 事先说明这其实就是我全部放到百度网盘空间里了。 所以万一一不小心我手抖删了,请mail我。 haibinzhagncn@qq.com 软件包括 leaflet osm里面中国和台湾的数据 openlayers geoserver mabox_studio mapnik 和生成瓦片工具需要的前置包等 postgresql osm2pgsql postgis python 一次只能上传一份那我就少点多几份吧: 介绍(免积分) http://download.csdn.net/detail/a137015127302/8594877 如果懒得自己慢慢找,我想你不介意花点积分的吧。 1.postgreSql_1.&postgis_install http://download.csdn.net/detail/a137015127302/8594903 2.postgreSql_2.mapnik&python_install http://download.csdn.net/detail/a137015127302/8594915 3.postgreSql_3.环境变量配置_osm数据导入 http://download.csdn.net/detail/a137015127302/8594919 4.postgreSql_4.生成图片瓦片byMapnik http://download.csdn.net/detail/a137015127302/8594921 其他:postgreSql_psql_乱码问题 http://download.csdn.net/detail/a137015127302/8594937 上传什么的好烦-- 我再试一次要是还是不能上传我就不玩了。切~ 核心内容(英文版公开资料):http://wiki.openstreetmap.org/wiki/Creating_your_own_tiles 以下本人写的中文版本的核心:只要注意这个基本上就没什么大问题了。 当然你要是懒得自己一步一步走,我想你应该也不介意多花点积分的。 摘录 首先版本请用 postgresql-9.3.6-2-windows.exe + postgis-bundle-pg93x32-setup-2.1.5-1.exe 因为至少如果是 postgresql-9.4.1-3-windows.exe + postgis-bundle-pg94x32-setup-2.1.7-1.exe 存在sample数据库无法创建问题。 同时32位下中文客户端提示信息异常问题,你只能改为英文显示,但是又会有warn信息提示你与本地不符(很烦不是么) 所以结论最新的未必就是最好的。 而且貌似他们已经开始放弃32位了。 还有这个2.1.7貌似是赶工出来的,因为提示信息写的是支援9.3而事实是否定的。 以上是我重装了n多遍的结论。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值