The GLG Map Server is a sophisticated GIS Map Server used to generate map images dynamically upon request. It is targeted towards a applications which display either static or dynamic information on top of a map, providing functionality for zooming and panning the map at run time. As the user zooms or pans to a different region, the Map Server generates a new map image to be displayed. The map images serve as a background which provides contextual information. Either static or dynamic icons may be placed on top of the images to provide real-time application-specific and interactive functionality.
Using the Map Server inside the GLG Drawing
The GLG Toolkit's resource-based interface and simple API provide a convenient way to interact with the GIS object in the drawing, shielding the user from the complexity of the Map Server and transparently handling zooming, panning, resizing, dynamic updates and user interaction. Dynamic GLG objects built with the GLG Graphics Builder may be used as dynamic or static icons displayed on top of the map, providing real-time data display and interactive capabilities.
When a drawing with the GIS Object is deployed in a C/C++ application (or an ActiveX control on Windows), the map server is deployed in the form of the map server library linked with the program executable.
In either deployment, the GIS Object transparently handles all details of the map sever interactions, letting the application concentrate on the application logic.
Using the Stand-Alone Map Server
The Map Server may also be used outside of the GLG Toolkit to create independent mapping applications or to serve maps to other applications. The Map Server may be used either in the form of a library linked into an application, or in the form of a cgi-bin executable which serves maps from a web server.
When deployed as a library, the GLG Map Server allows the user to setup and run a custom in-house map server which serves maps to applications and does not require any insecure connections to the Internet or rely on a third party server to be running in order to request and receive maps. When used as a cgi-bin executable, the Map Server provides map generating capabilities to remote clients and applications deployed in a web browser.
The GLG Map Server provides numerous features to efficiently handle the ever-changing needs of a modern application. It includes Orthographic projection to render maps on a globe, layering, alpha-blending, tiling, caching and decluttering for optimized performance. It provides the functionality to quickly render millions of points and lightweight polygons and text, as well as detailed images, making it ideal for applications which require rendering a large number of polygons, such as a map of an airfield or a detailed map of a city.
The Map Server has its own high-performance rendering engine which does not depend on any windowing system, so it can operate on a headless server. Since it runs independently of the graphical environment, the maps it generates are guaranteed to be identical across all platforms.
The GLG Map Server consists of the following parts
- The Map Server executable used to generate maps for web-based or command-line deployment.
- A library of functions (the API), used to incorporate the GLG Map server into an application as a library without any network connections.
- A set of command line utilities used to aid the user in setup and optimization of data for use with the GLG Map Server.
Since the GLG Map Server does not require any database tools to handle the data it uses, the Map Server is simple to set up and very flexible. The data and the description of the data lie in separate places, which results in tremendous flexibility. For example, if a user has obtained a newer, more accurate version of old data, and wishes to use the new data instead of the old, the data itself does not need to be altered and no database updated. Instead, the user simply specifies the location of the new data and the Map Server will automatically use it.
All descriptions of data, for example the width of the line to render roads in, is entered in a simple ASCII format text file. It is therefore not necessary to master any new tools for editing these informative descriptions, so as much as time as possible is left for development of mapping applications, not learning new tools.
The GLG Map Server uses the same object oriented approach as the GLG Toolkit. Although each polygon defined in a data file does not have its own attributes, polygons in the same data file, organized as a layer, can possess common attributes that are applied to them when they are rendered. This methodology is used to conserve space since the number of polygons the Map Server aims to render quickly is orders of magnitude higher than that which the GLG Toolkit is geared for. For example, if a data file contains polygons that describe roads, and a user wants to display the roads in red, although each individual polygon does not have a color associated with it, the user can control the color of all roads in that specific data file. The common object attributes of a layer in the Map Server have intuitive names and are almost identical to those present in GLG drawings, so the transition can be made with ease.
The following sections describe the components of the GLG Map Server in greater detail.
Map Server Executable
The Map Server executable may be used in a stand-alone mode to generate a single map image. In this mode, the Map Server is invoked with command line parameters which define the map image request. The generated map image is saved into a file defined by the command line parameters as well.
The Map Server executable may also be invoked in cgi-bin mode, which is used in a web/cgi environment to serve map images via a headless web server. In the cgi-bin mode, the Map Server takes map request parameters from cgi-bin environment variables and outputs the image with a proper HTML header into its stdout stream.
Both of the stand-alone and cgi-bin functionalities are accessible from the same executable via a command line switch. Also, they both comply with the OpenGIS standard for requesting maps.
The Map Server is designed as a map service and does not possess the capability to display the maps it generates. In the web environment, the images are naturally displayed by the client side web browser. In an application, GLG Toolkit's GIS object integrates the Map Server functionality into the GLG drawings and handles all aspects of displaying the maps and user interaction. The application may also display the images in any application-specific way without the use of the GLG Toolkit and GLG GIS object.
Tools and Utilities
The GLG Map Server includes several useful command line utilities to aid in setting up the data to be used by the Map Server. These include:
- an image tiling utility, which can split JPEG and TIFF formatted images into an arbitrary number of rectangular tiles,
- a vector splitting utility which can split polygons by number of points, according to a specific attribute, or rectangular tiling based on coordinates, and
- a utility to traverse directory structures and generate descriptions of all data found in that hierarchy to later use with the Map Server.
All utilities reside in the same Map Server executable and are invoked using utilities' command line option switches.
Library Programming Interface
When a C/C++ application requires the use of an integrated map display functionality, it may use the Map Server in the form of a C/C++ library instead of invoking a separate executable to generate maps. Not only does this method provide easier integration but it is also much faster and more flexible, as it allows the user to utilize such features as caching of data between map requests and creation of multiple maps.
There are two options available to deploy the Map Server as a library:
- Using the Map Server Library API directly from a program, in which case the program is responsible for displaying the generated image in an application-specific way.
1.2 Using the Map Server: Logical Steps
Map Server Input: Managing Data
Regardless of the form the Map Server is used in (executable, library or GLG GIS object), the Map Server uses raster or vector GIS data to generate map images. The Map Server reads the data, processes them by applying the requested projection and generates a map image.
The Map Server is optimized to read only the data for the requested layers and process only the data for the requested area. Huge datasets may be optimized by splitting the data into tiles, so that only the tiles covering the requested area need to be read and processed. The data may also be split in a hierarchical way (for example states and counties), and the Map Server provides utilities for efficient setup and processing of such data.
The Server Dataset File (.sdf) serves as a top-level data descriptor for a GIS dataset. It contains a list of available layers and the path to the Layer Description Files (.lif) which contain attributes of the layer and location of the data. The SDF file also contains information about available fonts.
After the data has been setup, the Map Server needs to know where the data it will be utilizing resides. This is accomplished by specifying the SDF file: through a command line option for the Map Server executable, GIS object attribute in a GLG drawing or by using the Map Server API when used in a library form.
When used in the form of the Library API, functions of the API can also be used to specify locations of all data used by the mapping application. Additionally, these functions can be used to create multiple maps and manage multiple datasets at once, as well as dynamically change layer attributes.
In order to generate a map, the Map Server needs to know the region of which it is to generate a map and what features to display. This information is provided through the map request parameters of the Map Server executable, through the GIS object attributes or the Map Server API if the library is used.
The Map Server executable has the -dataset option to specify the SDF file and the -oGISreq option that specifies all parameters of the map request (requested layers, area, projection, etc.) as a request string.
When the GIS object is used, the GISDataFile, GISCenter and GISExtent, GISLayers, GISProjection and other attributes may be used to control the map.
When using the Map Server in the library form, the Map Server API provides an intuitive Get/Set Resource mechanism very similar to that used by the GLG Toolkit. A handful of functions can specify the parameters for a specific map request and generate the request image.
Map Server Output: Displaying a Map
Since the Map Server is designed as a map service and provides no direct way to display the maps it generates, there are several options for using and displaying map images to choose from.
GLG GIS Object
The GLG Toolkit provides a way to seamlessly integrate the GLG Map Server into graphical applications created with the GLG Toolkit. The GIS object can be added into a GLG drawing just like any other graphical object and, and an application can control its resources to display dynamic maps and handle user interaction.
The GIS object automatically handles damage repair, resizing, zooming and panning, making it easy to embed dynamic maps into the GLG drawings. When the user resizes the drawing or uses pan and zoom keys, the GIS object automatically generates a new map request and sends it to the Map Server, displaying the new map in the drawing. The GIS object also provides the benefit of not needing to regenerate the map image every time dynamic icons are updated on top of it.
The GIS object also provides coordinate conversion utilities to convert between latitude/longitude and GLG coordinates, providing a simple interface to position dynamic and interactive GLG icons on top of the map.
For more information on the GLG GIS object, see the GLG User's Guide and Builder Reference.
When using the Map Server executable in the command line form, the standard way to display generated map images is to output them to a file. The output file is controlled via a command line option. The GLG Map Server API also provides an interface to writing generate maps into a file. The only file output option is the JPEG file format. The images may then be viewed using a web browser or any image viewer.
When using the executable in the CGI or FastCGI mode, the image is outputted as a JPEG file to the standard output with the proper HTML headers, so that the image can be displayed in a browser on the client side.
Map Server API
Finally, if the user desires neither to use the GIS object nor output generated map images to a file, or wants to invoke the Map Server from a program, he/she can use some of the advanced features of the API to access the raw bitmap information of the resulting map image and then display the image in an application-specific way.
Generic Logic, Inc.