• No results found

CHAPTER 2 LITERATURE SURVEY

3.3. System Framework and Web-Service Components

3.3.2. Web Map Service

3.3.2.2. GetMap Services

The getMap service interface allows the retrieval of maps. Maps are provided in different various formats based on user-defined parameters and layer attributes. All the supported formats for map-image layers and corresponding layer specific attributes and constraints are defined in WMS Capabilities document. Before invoking getMap service interface, clients first obtain capabilities document by invoking getCapabilities service interfaces (see Chapter 3.3.2.1). The image is returned back to the WMS Client as an attachment to SOAP message. If the WMS encounters any problem during handling of the request, it sends an exception message in SOAP back to the WMS Client.

The major operation steps to produce maps are illustrated in Figure 6. GetMap request schema to create valid requests is given in Figure 7.

Figure 6: GetMap operation steps.

WMS first parses the request and gets the parameter values. WMS first determines what layers are requested, in which bounding box, in which form, and so forth. After determining all the request parameters, it communicates with WFS services providing requested feature data by using their getFeature service interfaces and requested feature data in GML format. If the parameter defining returned image format in

getMap request is Scalable Vector Graphics (SVG) (Bowler et al., 2001), then WMS creates SVG from returned feature data by using its geometry elements. If the requested image is not in SVG format, we first create the SVG image and then convert it into the desired image formats (such as PNG, GIF, or JPEG). Apache Batik provides libraries for this conversion. Batik is a Java(tm) technology based toolkit for applications or applets that use images in the SVG format for various purposes, such as viewing, generation or manipulation. By using these schema files we derive geometry elements from the GML file to visualize the feature data. These geometry elements in GML are basically Point, Polygon, LineString, LinearRing, MultiPoint, MultiPolygon, MultiGeometry, etc.

To create the images from the features returned from the WFS, we have used Java Graphics2D and Java AWT libraries. For each layer we create a different graphics object. If you assign each layer to different graphics object than Java libraries allow you to overlay these graphic objects in various combinations.

Alternatively, WMS can use SVG conversion to create map-image layers. When this way is used, WMS uses its internally defined XSL file to convert standard GML files into SVG by using XSLT machine. We developed standard XSL (see Figure 13) file to convert XML coded GML feature collections into SVG files. After having SVG, these image objects then converted into any image format such as JPEG, TIFF, PNG etc. (Sayar, Pierce, & Fox, 2005b).

Figure 7 : GetMap Request Schema. See Appendix A for an instance of this request schema

Below is the sample code fragment showing how to extract geometry elements from GML and overlay it on a raster map image as a separate layer. In this simple pseudo-code, the raster data comes from an HTTP Servlet based WMS server (defined in URL), and the other data represented as features are coming from our implementation of WFS. Using a layer from some other WMS is defined in OGC specifications and is

known as cascading. WMS behaving as a client to another WMS is called cascading WMS, and the layer used is called cascaded layer. We will exploit and extend cascading in our federation approach.

URL url = new URL(

Wmsaddress+”?request=GetMap&width=" + width + "&height=" + heigth +

"&layers="+layername+ ”&styles=&srs=EPSG:4326&format=”+format+”&bbox=" + bbox); BufferedImage im = ImageIO.read(url); Graphics2D g = im.createGraphics(); … if(istherePoint)

String[] points = getPointsFromFeatureData(); if(isthereLineString)

String [] LineStrings = getLineStringFromFeatureData(); if(isthereLineRing)

String [] LineRings = getLineRingFromFeatureData(); if(istherePolygon)

String [] polygons = getPolygonsFromFeatureData(); …

if(polygons!=NULL){

for(int i=0; i<polygons. length; i++){

int [][] xypoints = wm.getXYpoints(polygons[i]); g.setColor(Color.darkGray);

g.drawPolygon(xypoints[0], xypoints[1], xypoints[0].length); }

}

if(LineRings!=NULL){

for(int i=0; i< LineStrings. length; i++){

int [][] xypoints = wm.getLinesInStr(LineStrings[i]); g.setColor(Color.darkGray);

g.drawPolyline(xypoints[0], xypoints[1], xypoints[0].length); }

}

Check all the geometry

elements in GML for a queried region of the map .Point, LineString Polygon etc.

If you find any geometry data above such as Points, LineStrings, convert the numbers in the GML file for the feature data into appropriate format to draw shapes for representing these geometry elements and display them by using graphics2D object. If you use the same grpahics2D data the layers will be overlaid.

g.dispose();

Figure 8: Sample output of the above map images generating code

How to send binary map images with SOAP messages (in JAVA): 1. Server side:

Sample JAVA client code below shows how to attach a map image to SOAP message in response to getMap request. We assume map image name is maimage.jpeg. The WMS server first creates a data handler from the image and casts it as an object, and then returns.

Object map = file2DataHandlerObject (APPLPATH+"/mapimage.jpeg"); public Object file2DataHandlerObject(String filePath) {

try {

DataHandler dhSource = new DataHandler(new FileDataSource(filePath));

return (Object) dhSource; } catch (Exception ex) { ex.printStackTrace(); return null;

}

2. Client side:

Client has client stubs for WMS services created earlier from WMS‟s Web Service Description File (WSDL). It uses its client stubs to get the map as an attachment

to SOAP message. It first extracts the attachment and then data handler from the attachment. It created map images as byte array through data handler.

java.lang.Object value = null; value = binding.getMap(request); byte[] bs = null;

Object[] attachments = binding.getAttachments(); for (int i = 0; i < attachments.length; i++) {

AttachmentPart att = (AttachmentPart) attachments[i]; DataHandler dh = att.getActivationDataHandler();

BufferedInputStream bis = new BufferedInputStream(dh.getInputStream()); bs = new byte[bis.available()];

bis.read(bs, 0, bs.length); bis.close();