当前位置:网站首页>GeoServer automatically uploads shapefiles
GeoServer automatically uploads shapefiles
2022-07-24 05:33:00 【DoYouKnowArcgis】
geosever Provides a rest Interface , Some functions can be realized through this interface , Then through the relevant code , It can realize the automation of some functions .
Here are shapefile Several methods of data upload Automation .
official API https://docs.geoserver.org/stable/en/user/rest/stores.html
(1) upload ZIP, To publish Services
Parsing code :
pro.zip( The uploaded shp Compressed files , This file will directly shp Data compressed into files , Don't put it under a folder and compress it !)
curl -v -u admin:geoserver // user name password
-XPUT -H "Content-type: application/zip" // file type
--data-binary @C:\Users\111111\Desktop\shapefile_test\pro.zip // File path
http://localhost:8888/geoserver/rest/workspaces/HZP/datastores/pro/file.shp?charset=GBKcurl operational demo
curl -v -u admin:geoserver -XPUT -H "Content-type: application/zip" --data-binary @C:\Users\111111\Desktop\shapefile_test\pro.zip http://localhost:8888/geoserver/rest/workspaces/HZP/datastores/pro/file.shp?charset=GBKIt's written in java Form to call Curl Release
String filePath;
String fileName;
String workspaceName;
// Get the file name , Users upload their local zip, You need to know the file first
// The address of , namely filepath, Right again filepath Handle
// obtain filename
/*File tempFile =new File( filepath.trim());
/*String fileName = tempFile.getName();
String CurlDOS = "curl -v -u admin:geoserver -XPUT -H \"Content-type: application/zip\" --data-binary @"+filePath+" http://localhost:8888/geoserver/rest/workspaces/"+workspaceName+"/datastores/"+fileName+"/file.shp?charset=GBK"(2) By calling XML Methods to achieve publishing services .
( Publish vector data in the specified folder )
//2 Medium workspace Need and 4 In the same ,
//4 Medium datastores The following parameters need to be consistent with XML Medium name Agreement .
//4 Medium <featureType><name> The corresponding is uploaded shp The name of the file .Curl Direct manipulation demo:
// Execute first 2
curl -u admin:geoserver -XPOST -H "Content-type:text/xml" -d @C:\Users\111111\Desktop\shapefile_test\pro.xml http://localhost:8888/geoserver/rest/workspaces/HZP/datastores.xml
// Re execution 4
curl -u admin:geoserver -XPOST -H "Content-type:text/xml" -d "<featureType><name>pro</name></featureType>" http://localhost:8888/geoserver/rest/workspaces/HZP/datastores/pro/featuretypesXML
<dataStore>
<name>pro</name> // Here name Refers to the name of the storage space
<type>Shapefile</type>
<enabled>true</enabled>
<connectionParameters>
<entry key="url">file:/C:/Users/111111/Desktop/shapefile_test/pro</entry>
<entry key="charset">GBK</entry>
</connectionParameters>
<__default>false</__default>
</dataStore>Reference Edition XML
<dataStore>
<name>pro</name>
<description>tiger counties created from REST</description>
<!-- Upload the type of data storage -->
<type>Shapefile</type>
<!-- Whether the data storage is available -->
<enabled>true</enabled>
<connectionParameters>
<!-- Use memory mapped buffers -->
<entry key="memory mapped buffer">false</entry>
<!-- If the spatial index is missing or out of date , Rebuild spatial index -->
<entry key="create spatial index">true</entry>
<!-- DBF Character set for -->
<entry key="charset">GBK</entry>
<!-- Data file type -->
<entry key="filetype">shapefile</entry>
<!-- If the spatial index is missing or out of date , Rebuild spatial index -->
<entry key="cache and reuse memory maps">true</entry>
<!-- The path to upload the data file -->
<entry key="url">C:\Users\111111\Desktop\shapefile_test\pro\pro.shp</entry>
<entry key="namespace">http://HZP</entry>
</connectionParameters>
<__default>false</__default>
</dataStore>

(3) Use curl Complete the data Postgis Release of data in
Method 1 ( Failure )
1. New workspace
curl -v -u admin:geoserver -XPOST -H "Content-type: text/xml" -d "<namespace><prefix>PostGis_test</prefix><uri>http://localhost:8888/POSTGIS</uri></namespace>" http://localhost:8888/geoserver/rest/namespacesMethod 2 :
1. First define the uploaded database .
2. After data change , Add more data .
name For the file name .
curl -u admin:geoserver -XPOST -H "Content-type:text/xml" -d "<featureType><name>50m_admin_0_countries</name></featureType>" http://localhost:8888/geoserver/rest/workspaces/PostGis_pro/datastores/postgis/featuretypes
边栏推荐
- 函数_this关键字
- mapboxgl + geoserver 配置本地地图教程
- New grammar 01_ ES6 new syntax
- WIX 路径中带空格
- Latex learning notes (I) - installation configuration
- OPENGL在屏幕上绘制2个点,右边一个蓝色的点,采用反走样技术,左边一个红色的点,不采用反走样技术。比较两个点的区别。
- 7. Draw a Bezier curve on the screen and smooth the curve with anti aliasing technology.
- 字符串_方法_01match方法
- 随意写写 cookie,sessionStorage,localStorage和session
- JS链表中的快慢指针
猜你喜欢

自定义MVC 2.0

special effects - 鼠标移动,出现泡泡拖尾

数据类型概括

Pure white tutorial using Druid database connection pool in idea

Variables and constants in C language

AttributeError: ‘NoneType‘ object has no attribute ‘shape‘

select_ Render small phenomena

Install pytoch+anaconda+cuda+cudnn

Station B video comment crawling - take the blade of ghost destruction as an example (and store it in CSV)

关于作为行业人从业人员的一点思考
随机推荐
LaTeX学习笔记(一)——安装配置
设计一个函数print打印字符串,如果只传string型参数s,则字符串长度跟10比较,大于10,打印前10个字符,小于10,全部输出s;如果传string型参数s和int型n,则字符串长度跟n比
special effects - 鼠标点击,出现随机设置的文字
canvas - Bezier 贝塞尔曲线
Install pytoch+anaconda+cuda+cudnn
函数多种类型
libevent多线程服务端+客户端源码
Cmake笔记
special effects - 鼠标移动,出现自定义的表情拖尾
新建 umi 项目,Error: Rendered more hooks 或者 Rendered fewer hooks
函数闭包
移动软件开发-iso简易微信
special effects - 鼠标点击,自定义 DOM 跟随移动
Function_ generalization
Latex learning notes (I) - installation configuration
select_渲染小现象
总结Browser对象
随意写写 cookie,sessionStorage,localStorage和session
node连接mysql,使用navicat可视化
动画 效果