Sqlview how to dynamically publish map layers _mssql

Source: Internet
Author: User
Tags postgresql sql injection

1.SQL views Introduction

Geoserver+postgresql+openlayers (leaflet) is the current mainstream GIS development tool. PostgreSQL is used to store map data, GeoServer is used to publish map data, openlayers or leaflet is used to access publishing maps. Normally when Shapefile format data is imported into the PostgreSQL database, we need to publish all of the data through geoserver so that we can access it. This is not a problem in the normal case, as the map serves as the basic service and will not change once it is released. But for the indoor map is not, if a shopping mall has 5 floors, each floor and layer has 5 map layers, for such a mall needs to put the 25 map layer in the GeoServer all released to access the mall's full map. If you could put up with 25 layers of this mall, would you be able to put up with a map of thousands of malls? If you can't stand it, you'll find a solution. Since publishing maps is a mechanical duplication of work, can we think of some ways to help us accomplish these tasks? This is our sqlview.

To introduce SQL View first, you can do the following things through Sqlviews:

(1) Database view can be geoserver as a table in the same way, and GeoServer sqlviews not only to achieve a simple query publishing, but also to enter parameters as a query view conditions.

(2) Sqlviews can publish the stored procedures or function of the database, and perform more complex logical operations and queries.

(3) SQL views queries can be parameterized by string substitution, parameter values can be used in both WMS and WFS requests, and input values can be validated by setting regular expressions to eliminate the risk of SQL injection attacks.

(4) Sqlviews is a result of the operation of the database and query, can not use wfs_t to operate it, but wfs,wms can be normal request or query.

2. Create an SQL views view with query criteria:

(1) Login geoserver, click on the layer, select workspace, new layer.

(2) New SQL views to view the chart layer, and publish.


This creates a view that publishes the incoming table name data.

The default value of the TBL is set to a table that will always exist in the database, and the regular expression is set to allow only alphanumeric and underscore entries.


The value of the property is set on the type and coordinate system of the output result.

(3) Layer access

When you get a map through WMS, you just have to pass the TBL value through the 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

Viewparams format is generally viewparams=p1:v1;p2:v2 .... You can add a few parameters. A single parameter is a key value pair, that is, the P1 is the parameter name, and the V1 is the parameter value.

The view methods for accessing publications via WMS are:

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, no amount of shopping malls only need to publish 5 views in the GeoServer, and the code for the publishing view can be written in GeoServer to be packaged in. This system does not need to publish a map in any store.

3. Create an SQL view view that contains function

Solve the issue of layer release, finally can breathe a sigh of relief. But it never occurred to me that the thorny issue was still behind me. Lead to do indoor navigation function. Do it, who let us is a bitter-forced code farmers. Then how to do indoor navigation, do this function, we still have to plan. First to write the shortest path query algorithm, and then query the path only need to start and end of the location input algorithm query can be, and finally the results of the query through the WMS or WFS way to obtain, displayed on the map.

Write the shortest path planning algorithm when we need to input: the user's floor of the road name, starting point and end of the location, and then we Chi Chi, the war 3 days, three nights, done.

Then query, good to do, directly according to the above put it, the mall's 5 floors are released a based on the corresponding floor of the results path view, wit? No,no,no! can't understand the brain. This time definitely need to change a new method, the shortest Path planning algorithm written a function embedded in the PostgreSQL database, the function of the input parameters: the user's floor, start position, end position, the output parameter is the starting point and end point of the direct pass through the coordinates.

Finally, we can obtain the shortest path result by WMS or WFS method.

The above implementation of the small series to introduce the Sqlview dynamic release map layer method, I hope to help!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.