ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

postgresql数据库中存储经纬度或电子围栏

2021-10-27 11:04:31  阅读:61  来源: 互联网

标签:set postgresql 经纬度 GeomFromText update 围栏 shape device id


在postgresql数据库中,如果字段类型是geometry或者是(Type),我们要更新该字段为经纬度(坐标),可以尝试采取以下脚本:

1.存经纬度

update device set shape = ST_GeomFromText(‘POINT(108.658463 34.1437)’, 4610) where id=‘a6a2c56a-5f7d-48a9-a213-f2c4360e4f3b’

如需展示轮廓,则获取一组几何坐标

update building set shape = ST_GeomFromText(‘POLYGON((121.415703 31.172893,121.415805 31.172664,121.416127 31.172751,121.41603 31.172976,121.415703 31.172893))’,4610) where objectid = 81

2.存空间信息

update device set shape = st_GeomFromText('[["13540590.2738545,3488536.66830615","13540666.5189164,3488577.10006504","13540730.989878,3488491.09500687","13540637.9626006,3488450.56659938","13540630.8489416,3488453.01866445","13540590.2738545,3488536.66830615"]',3857) where id=‘a6a2c56a-5f7d-48a9-a213-f2c4360e4f3b’

存储后:0106000020110F00000100000001030000000100000005000000226078DDA33B6841D2E096074D674441141DEA27765B6841418B152B406544413F4E50775F5E6841F78D4FC2C54C44410B5670C6EB3968410BEC19DB343D4441226078DDA33B6841D2E096074D674441

页面展现:

 

 

3.查看

 select id,st_astext(shape ) from  device  

参考文章:https://blog.csdn.net/rosejeck/article/details/82962511

标签:set,postgresql,经纬度,GeomFromText,update,围栏,shape,device,id
来源: https://www.cnblogs.com/haoliyou/p/15469480.html

专注分享技术,共同学习,共同进步。侵权联系[admin#icode9.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有