Description of GIS outsourcing in China Science and Technology Park 1 ----- openlayers calls WMS Service

Source: Internet
Author: User
Tags ranges

Openlayers calls WMS





Openlayers is an open-source JS framework used to implement Map Browsing effects and basic zoom and Pan functions in your browser. The map sources supported by openlayers include WMS, GoogleMap, kamap, and msvirtualearth. You can also use simple images as the source. openlayers provides many options.

WMS service:


1 OGC organization and its open specifications

To enable interoperability and integration of heterogeneous geospatial information and GIS processing functions, OGC (Open GIS Consortium) has been committed to finding a way, GIS interoperability on distributed heterogeneous platforms is achieved by effectively combining geographic information system technology, distributed processing technology, object-oriented technology, database design, and real-time information processing methods. OGC develops open geographic information interoperability standards (ogis), and tries to achieve interoperability through the Common Open geographic data model (OGM) and ogis Reference Model (ORM. The purpose is to propose a scalable framework based on various standards that can seamlessly integrate various online space processing and location services, this allows the distributed space processing system to interact with each other through XML and HTTP technologies, and provides various online space data resources, information from sensors, space processing services and location services, and web-based discovery, access, integration, analysis, utilization, and visualization provide an interoperability framework [3].

The central topic of OGC is to share information and provide services. There are 17 topics in the abstract specification of OGC. Topic 12 is the Open Web Services spatial information service framework []. it contains a series of abstract and implementation specifications. In summary, OGC OpenGIS Web Services (ows) includes three major geographic information services: Web Map Service (WMS) and Web Feature Service (WFS) and Web Coverage Service (WCS ). In addition, it also includes simple feature specillcation (SFS) and Geography Markup Language (GML.

2 WMS specifications and implementation process

2. 1 WMS Specification

Ogc wms is an OGC graphical expression service that uses data with geospatial location information to create a map. In the WMS specification, a map is defined as a visualized representation of geographical data. WMS does not return map data, but map images. The WMS Specification defines three operations [6]:

● The getcapabilities operation returns the service-level metadata, which is a description of the service information content and request parameters. The metadata is expressed in XML format.

● The getmap operation is performed on the server based on the request parameters sent by the client. The server returns a map image whose geospatial parameters and size parameters are clearly defined, the returned map image can be in GIF, JPEG, PNG, or SVG format.

● The getfeaturelnfo operation returns information about some special elements on the map based on the X and Y coordinates requested by the user or the layer of interest. The information is displayed in HTML, GML, or ASCII format.

2. 2 the specific implementation process of WMS

  In the three WMS operations, getcapabilities and getmap must be implemented, while getfeaturelnfo is optional. The following describes the specific implementation process of these three operations.

WMS requests and responses are implemented on the client and server. The client can be either a common browser or an application system or component. Figure 1 shows the interaction between the client and the server in the UML sequence diagram.

The client sends requests to the server over HTTP and visualizes the spatial data. The server must respond to three URL-based requests, namely getcapablilties, getmap, and getfeaturelnfo. The client receives GIF, JPEG, and PNG image files, XML format metadata files, and GML files.



Figure 1 interaction between the client and the server

Fig. 1 process of interaction between client and server

Before requesting a Web Map Service, the client must understand the map information that the WMS server can provide. This information is contained in the map metadata file. In the ogcwms specification, you can send a getcapabilities request to obtain the metadata that describes the services that the server can provide. For example, you can use a browser to send the following requests to obtain XML documents:

Http: // localhost: 8080/query capabilities? Requ est = getcapabilities & version = version & service = WMS.

Metadata is returned in the form of an XML document. The information provided in the XML document includes the list of all functional interfaces supported by the WMS server, the available image formats, and the list of available spatial references for transferring map data from the server; A list of all exceptions returned from the server; A list of dedicated metadata for modifying and controlling features of the WMS server of a specific software vendor; a list of available layers and optional attributes of a WMS server; whether the WMS supports optional getfeaturelnfo operations.

The client parses the metadata description file, retrieves the required information from it, and then sends the getmap request in the following format: http // localhost: 8080/deegeewms? Servic
E = WMS & request = getmap & layers = Layers & styles = styles & format = format & SRS = coordinate-System & bBox = bounding_box & width = width & Height = height

The WMS server processes user requests and obtains the required data by accessing a database or file. The requested map is returned as an image in the format of JPEG, PNG, GIF, or SVG.

Each getmap request returns one or more layers of the corresponding map. Multiple layers may overwrite each other when forming a new map. The solution is to make them transparent. You can not only request multiple layers on a single WMS server, but also send requests to multiple WMS servers. Because each server has a different metadata description file, the client needs to send a get captilities request to each WMS server to obtain different metadata descriptions. When the layers selected are located on different WMS servers, each server returns one or more layers. These layers may use different coordinate references, display ranges, and other parameters. Only layers with the same parameters can be superimposed.

When you select a point on the map, you can get more detailed information about the region by sending the getfeaturelnfo request. The WMS server's response will be in one of the following formats, GML format, text format, and HTML file. Because GML is based on XML, the client can parse the GML file through programming and convert it to the SVG vector format that can be displayed on the browser.

3. WMS-based architecture and implementation process



Figure 2 WMS application instance architecture framework

Fig. 2 The Architecture of WMS instance

Since the WMS Specification defines in detail the operation interfaces provided by the WMS server to the customer program from the semantic and syntax perspectives, it provides the ability to standardize the network space information system. All servers that comply with this specification can be accessed by clients. Like all web-based applications, the ogcwms specification can be implemented in multiple ways. The layer-3 or multi-layer architecture logically and physically separates the display layer, business logic layer, and data layer to facilitate system maintenance and upgrade, minimizing inter-system coupling has become the first choice for building a web-based application system. This article designs a three-tier WMS application framework based on open-source WMS servers, namely, WMS client, WMS server, and data source. The architecture is shown in figure 2.

Openlayers calls the WMS service:

Image loading is a spiral loading. First, create a stack for the entire IMG matrix clockwise from the top right corner. The essence is an array designed based on the stack's advanced ideas, then, the raster images are loaded from the middle of the window in a clockwise order based on the position in the stack.

The entire IMG matrix forms a grid. When a map is moved, the range of the grid [that is, the bound value] cannot contain the window bound, or when the display ratio of the map changes, the system will request data from the server again. Otherwise, the system will only move the positions of IMG to make the windows within the grid.

The number of IMG used by the client for raster graph display is calculated. The DIV used for display by the user is used as a window. The window size is divided by the length and width of each IMG to obtain an M * n matrix, which indicates the minimum number of IMG required to fill the entire window in the long and wide direction, then cache the IMG in both the long and wide directions to obtain a matrix (m + 2) * (N + 2), that is, the number of IMG clients. The default cache is two cells, of course, we can also pass in the cache number as a parameter to change the default cache buffer, then the modified matrix is (m + buffer) * (N + buffer ).

When moving, take the coordinate value in the upper left corner of the tile in the upper left corner of the grid, that is, grid [0] [0] is the reference point, when the coordinates of this point exceed the threshold, the positions of each node in the grid are moved.

Here, IMG has been encapsulated into a tile class in openlayers, and this layer has a div as a container. Each image has a div to wrap it. tilesize is defined in advance according to the openlayers. tile_whith and openlayers. tile_height constants, indicating the size of each tile instance.

Raster Graphic Display provides standard WMS-based calls, that is, as long as the server provides the standard WMS service, the client can call it. Since the spiral Loading Function of openlayers is separated from the bottom layer, we can extend our raster map calling class at the bottom layer, that is, let our class inherit from openlayers. layer. grid: refactor the geturl method in our own class. However, this also has a drawback, that is, we still inherit the openlayers raster call method to a large extent. This method has high reusability and is very conducive to expansion, but it may not necessarily bring high efficiency.

For example, we need our own call method. The raster map pyramid provided by the server has a total of 17 levels, and the entire display range is-180,-90,180, 90, level 1: The span at the longitude and latitude directions of each raster is 18 degrees. As the level increases, the span at the longitude and latitude directions is halved compared to the previous level. The raster map uses grid coordinates, the coordinate origin is in the upper left corner. Some of our call methods are the same as those of WMS raster images. When the moving or scaling range exceeds the threshold, a request is sent to the server. the longitude and latitude coordinates of the center of the raster map are obtained based on the longitude and latitude ranges of each tile, based on the current longitude and latitude, you can know the server-side raster map matrix under the resolution, and then obtain the location of the tile on the server-side raster map based on the longitude and latitude span of the grid map under the resolution, to obtain the graph. The size of each Raster image from the server side is 256*256 pixels. I have re-written this process and basically inherited the core idea of WMS calling in openlayers. Of course, the efficiency will not be improved.

In fact, we can make our own raster display class inherit from openlayers directly. layer. In this way, the framework of openlayers layer operations is used to give up the mechanism of low efficiency brought by openlayers. After my own experiments, although this improvement was made, the final effect was not significantly improved, and the cause was analyzed later.

This section mainly contains four types:

Openlayers. layer, openlayers. layer. httprequest, openlayers. layer. Grid, openlayers. layer. WMS. Their Inheritance relationships:

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: 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.