In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
What is the method for Sqlview to dynamically publish map layers? I believe many inexperienced people don't know what to do about it. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
Introduction to 1.SQL Views
Geoserver+postgresql+openlayers (leaflet) is the mainstream gis development tool at present. Postgresql is used to store map data, geoserver is used to publish map data, and openlayers or leaflet is used to access published maps. Normally, when the data in shapefile format is imported into the postgresql database, we need to publish all the data through geoserver so that we can access it. Normally, there is no problem with this mode of operation, because the map, as a basic service, will not change once it is released. But not for indoor maps. If a mall has five floors and each floor has five map layers, such a mall needs to publish all 25 map layers in geoserver to access all the maps of the mall. If you can stand publishing 25 layers of this mall, can you stand publishing maps of thousands of malls? If you can't stand it, you have to find a way to solve it. Since publishing maps is a mechanical and repetitive task, can we think of some ways to help us with these tasks? This is when our sqlView comes out.
First of all, let's introduce sql View. Through SQLViews, you can do the following:
(1) the database view can be published as exactly the same table in geoserver, while the SQLViews of geoserver can not only publish a simple query, but also input parameters as the condition of query view.
(2) SQLViews can publish stored procedures or function of the database to perform more complex logical operations and queries.
(3) SQL Views queries can be parameterized by string substitution, parameter values can be used in wms and wfs requests, and input values can be verified by set regular expressions to eliminate the risk of SQL injection attacks.
(4) SQLViews is a result of database operation and query. You cannot use wfs_t to operate it, but wfs,wms can request or query normally.
two。 Create a SQL Views view with query criteria:
(1) Log in to geoserver, click the layer, select the workspace, and create a new layer.
(2) create a new SQL Views view layer and publish it.
Here, a view is created to publish the incoming table name data.
The default value of tbl is set to the table that will always exist in the database, and the regular expression is set to allow only alphanumeric and underscores.
The type and coordinate system of the output result are set in the attribute value.
(3) layer access
When you get the map through wms, you only need to pass the value of tbl through viewparams.
Http://10.20.135.14/geoserver/parking/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=parking%3AvTingchewei&CRS=EPSG%3A4326&STYLES=&WIDTH=2700&HEIGHT=1200&BBOX=20.02708134918213%2C110.33805803565978%2C20.03351865081787%2C110.3525419643402&viewparams=tbl%3Awanghaiguojia_b2_tingchewei
The viewparams format is usually viewparams=p1:v1;p2:v2;. Several parameters can be added. Separated by different parameters, a single parameter is a key-value pair, that is, p1 is the parameter name and v1 is the parameter value.
The view method to access the publication through wms is as follows:
Var params= {LAYERS:'parking:vTingchewei',FORMAT:'image/png'}; varviewparams = ['tbl:wanghaiguojia_b2_tingchewei']; params.viewparams= viewparams;varvTingchewei = new ol.layer.Image ({source:new ol.source.ImageWMS ({url:' http://10.20.135.14/geoserver/parking/wms', params:params,serverType:'geoserver',})})
In this way, more shopping malls only need to publish the view five times in geoserver, and the code of the released view can be pre-written into geoserver and packaged. In this way, there is no need to publish maps when the system is used in any shopping mall.
3. Create a SQL View view that contains function
After solving the problem of layer publishing, you can finally breathe a sigh of relief. However, I did not expect that the thorny problem still lies ahead. The leader asked to do indoor navigation function. Just do it. We're miserable programmers. Then how to do indoor navigation? before we do this function, we still have to plan it. First of all, we need to write the shortest path query algorithm; then we only need to input the location of the starting point and end point into the algorithm query when querying the path; finally, the query results are obtained by wms or wfs and displayed on the map.
The inputs we need when writing the shortest path planning algorithm are: the name of the road on the user's floor, the location of the starting point and the end point, and then we snort and fight for three days and three nights, done.
Then query, easy to do, put it directly according to the above, and publish a result path view of the five floors of the mall based on the corresponding floor, isn't it? NO,NO,NO! I just don't know how to think about things. At this time, it must be necessary to change a new method to write the shortest path planning algorithm as a Function and embed it into the postgresql database. The input parameters of the function are: the user's floor, the starting point and the end point, and the output parameters are the point coordinates through which the starting point and the end point pass directly.
The shortest path result can be obtained by wms or wfs.
The above-mentioned realization of the editor to introduce to you the Sqlview dynamic release of map layers, I hope to help you!
After reading the above, have you mastered the method of dynamically publishing map layers by Sqlview? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.