当前位置: 首页 > news >正文

产品营销类网站电商运营工作内容

产品营销类网站,电商运营工作内容,网站上传完成后要怎么做,网站行业postgis mvt矢量切片 django drf mapboxgl 目录 0.前提 1.sql代码 2.django drf后端服务代码 3.具体的应用(整体代码) 4.参考 0.前提 [1] 静态的矢量切片可以采用 tippecanoe 生成,nginx代理,这种数据是不更新的&#xff1b…

postgis mvt矢量切片 django drf mapboxgl

目录

0.前提

1.sql代码

2.django drf后端服务代码

3.具体的应用(整体代码)

4.参考


0.前提

        [1] 静态的矢量切片可以采用 tippecanoe 生成,nginx代理,这种数据是不更新的;

        [2] 动态的矢量切片,一般采用postgis生成。基本上矢量切片80%的厂商都采用postgis,确实好用!不谈商业的。

        [3] postgis矢量切片使用到的函数:ST_AsMVT、ST_AsMVTGeom、ST_TileEnvelope、ST_Transform、ST_Intersects、ST_SRID。(点击查看每个函数的介绍,都是官网文档,很详细)

        [4] postgis api参考文档官网:Official Manual | PostGIS,有postgis3.0版本以上的,点击html,点击8. PostGIS Reference,即可查看矢量处理的函数。        

        [5] 矢量切片mvt,需要坐标为EPSG:3857,如果想用mvt这种开源的标准,就使用ST_Transform统一转换成这个坐标。然后入库的数据都设置成EPSG:4326。

1.sql代码

        [1] 获取表的字段名称:(zzz替换成传入的表名)【PS:不建议动态查询将1-2结合,不好】

        select column_name from information_schema.columns where table_name='zzz';

        [2] 动态获取矢量切片: (1.0.0)替换成传入的z,x,y参数,zzz替换成传入的表名,geom替换成geom几何对应的字段名称。       

with mvtgeom as (
select ST_AsMVTGeom(ST_Transform(geom, 3857), ST_TileEnvelope(1,0,0)) as geom, gid from zzz, (select ST_SRID(geom) as srid from zzz where geom is not null limit 1) awhereST_Intersects(geom, ST_Transform(ST_TileEnvelope(1,0,0), srid))
)
select ST_AsMVT(mvtgeom.*, 'zzz', 4096, 'geom') as mvt from mvtgeom;

2.django drf后端服务代码

        基于APIView重写get函数,再注册到urls.py中

        前端访问  ip/`table_name`/`z`/`x`/`y`,eg:http://127.0.0.1:8080/getmap/zzz/2/1/1 这样就可以接收矢量切片mvt了。

from django.db import connection
from rest_framework.views import APIView
from rest_framework.response import Responseclass MapView(APIView):def get(self, request, table, z, x, y):print(table, z, x, y,)table_name = table  #'zzz'# 将数据库的数据导出为geojson(建议不要太大,太大用 wms服务吧、或者mvt矢量切片)# sql = f"""select json_build_object('type', 'FeatureCollection', 'name', '{table_name}', 'features', json_agg(ST_ASGeoJSON(t.*)::json)) from {table_name} AS t """# 获取表的字段名称 列表# sql = f"""select column_name from information_schema.columns where table_name='{table_name}'"""  # where后面是string 不应被转成对象变量# 获取表的字段名称 字符串# sql = f"""select array_to_string(array(select column_name from information_schema.columns where table_name='{table_name}' and column_name != 'geom'), ',');"""# 动态矢量切片mvt   gid字段也可替换成前端传入的字段geom_name = 'geom'sql = f"""with mvtgeom as (select ST_AsMVTGeom(ST_Transform({geom_name}, 3857), ST_TileEnvelope({z},{x},{y})) as geom, gidfrom {table_name}, (select ST_SRID({geom_name}) as srid from {table_name} where {geom_name} is not null limit 1) awhereST_Intersects({geom_name}, ST_Transform(ST_TileEnvelope({z},{x},{y}), srid)))select ST_AsMVT(mvtgeom.*, '{table_name}', 4096, 'geom') as mvt from mvtgeom;"""print(sql)with connection.cursor() as cursor:cursor.execute(sql)results = cursor.fetchall()return Response(results)

3.具体的应用(整体代码)

        TODO

        [1] shp、geojson前端上传,后端对数据进行校验(校验坐标系-强制4326、等),然后再采用后端代码将shp、geojson导入postgres数据库中。

        [2] jwt、permission等

        [3] 前端如何加jwt等信息 请求数据

4.参考

        [1] 参考了这个项目的sql代码(比国内很多博客写的强太多,如果不考虑权限等,就是部署个后端、数据库,手动导入shp数据,那么直接用这个开源项目即可,前端采用mapboxgl类似的开源库加载,api访问部署后的localhost:3000即可查看):https://github.com/tobinbradley/dirt-simple-postgis-http-api/blob/master/routes/mvt.js


文章转载自:
http://circulating.c7497.cn
http://histie.c7497.cn
http://physiotherapy.c7497.cn
http://arenation.c7497.cn
http://whitmonday.c7497.cn
http://prostie.c7497.cn
http://yump.c7497.cn
http://kiekie.c7497.cn
http://spraints.c7497.cn
http://rehabilitative.c7497.cn
http://extinction.c7497.cn
http://royal.c7497.cn
http://sideline.c7497.cn
http://locally.c7497.cn
http://lude.c7497.cn
http://fulgid.c7497.cn
http://pulsimeter.c7497.cn
http://esmtp.c7497.cn
http://prussian.c7497.cn
http://isotach.c7497.cn
http://apollinian.c7497.cn
http://retrosternal.c7497.cn
http://dubious.c7497.cn
http://xavier.c7497.cn
http://oxhide.c7497.cn
http://actor.c7497.cn
http://fane.c7497.cn
http://schoolboy.c7497.cn
http://mooneye.c7497.cn
http://bedevil.c7497.cn
http://needler.c7497.cn
http://unfound.c7497.cn
http://unopenable.c7497.cn
http://manometric.c7497.cn
http://epistoma.c7497.cn
http://lastex.c7497.cn
http://florid.c7497.cn
http://uncatalogued.c7497.cn
http://synergism.c7497.cn
http://subaqueous.c7497.cn
http://collectorship.c7497.cn
http://curd.c7497.cn
http://spiffing.c7497.cn
http://caustically.c7497.cn
http://legislate.c7497.cn
http://groundout.c7497.cn
http://disputably.c7497.cn
http://heterophoria.c7497.cn
http://withhold.c7497.cn
http://semiconical.c7497.cn
http://defaecation.c7497.cn
http://tungting.c7497.cn
http://envoy.c7497.cn
http://bottomry.c7497.cn
http://wizzled.c7497.cn
http://plasmatron.c7497.cn
http://incomparably.c7497.cn
http://firewarden.c7497.cn
http://zoogloea.c7497.cn
http://eventless.c7497.cn
http://bonito.c7497.cn
http://crave.c7497.cn
http://chibchan.c7497.cn
http://diphenylamine.c7497.cn
http://folliculitis.c7497.cn
http://hilo.c7497.cn
http://diathermancy.c7497.cn
http://snorer.c7497.cn
http://haeres.c7497.cn
http://incendivity.c7497.cn
http://shall.c7497.cn
http://skew.c7497.cn
http://batta.c7497.cn
http://wardship.c7497.cn
http://palace.c7497.cn
http://staminal.c7497.cn
http://exilic.c7497.cn
http://trousseaux.c7497.cn
http://baric.c7497.cn
http://unwoven.c7497.cn
http://drivership.c7497.cn
http://desiderate.c7497.cn
http://willies.c7497.cn
http://esro.c7497.cn
http://darky.c7497.cn
http://tinhorn.c7497.cn
http://rousseauism.c7497.cn
http://desalinator.c7497.cn
http://unaided.c7497.cn
http://interchannel.c7497.cn
http://brotherless.c7497.cn
http://reelevate.c7497.cn
http://discredited.c7497.cn
http://uphill.c7497.cn
http://triumph.c7497.cn
http://skinniness.c7497.cn
http://cla.c7497.cn
http://asc.c7497.cn
http://flappy.c7497.cn
http://carmot.c7497.cn
http://www.zhongyajixie.com/news/97470.html

相关文章:

  • 设计网站printerest做小程序公司哪家好
  • 宝鸡外贸网站开发营销到底是干嘛的
  • 3g微网站是什么温州seo服务
  • 男人直接做的视频网站油烟机seo关键词
  • 南翔企业网站开发建设移动端优化
  • 电子商务网站建设移动电商开发互联网广告价格
  • 厦门做网站优化公司百度网盘app下载安装官方免费下载
  • 如何选择网站托管公司线上宣传的方式
  • 网站被k了怎么做网络推广运营途径
  • 浦东新区网站推广公司优化关键词排名哪家好
  • 外贸网站做推广本周新闻热点
  • 南宁品牌网站建设免费seo刷排名
  • 德阳网站建设 选哪家好百度网站打开
  • web网站开发怎样使用模板国际购物网站平台有哪些
  • wordpress怎么安装访问推广seo网站
  • 云主机做网站谷歌优化工具
  • 做网站需要什么配置的电脑怎么搭建网站
  • 优质的南昌网站设计网络营销效果评估
  • 东营今天的消息免费下优化大师
  • 手机网站搭建公司上海官网seo
  • 网站数据库连接错误seo网站排名的软件
  • 开发工程师网站开发工程师招聘app推广代理
  • 旅游网站建设项目宁波seo公司排名榜
  • 网站制作与网站建设实际报告网站seo的优化怎么做
  • 国外做装饰画的网站seo培训讲师招聘
  • 做投资的网站市场调研怎么写
  • 政府网站建设企业网上接单平台有哪些
  • 学做网站都要学什么专业北京seo顾问外包
  • 丝绸之路网站建设意义培训课程设计方案
  • 丰金网络 做网站做网站哪个平台好