HOW TO

Query raster layer information using the Java Connector

Last Published: April 25, 2020

Summary

ArcIMS 4.0 defines a new ArcXML request named GET_RASTER_INFO to retrieve pixel value information from an image layer in an Image or ArcMap service. The ArcIMS 4.0 Java Connector includes a JavaBeans Object Model Library and a custom JSP Tag Library that contain methods for retrieving raster information. However, only the Tag library reference includes detailed information on implementing a solution. This document provides additional information on the methods and properties included with the Java Connector JavaBeans Object Model Library to interact with raster layer information. Note that Java Connector documentation is included on the ArcIMS installation CD and can be found under $AIMSHOME\Documentation\Java_Connector. If the document was not installed, you must perform a custom install and select the Java Connector specifically from the available connectors.

Procedure



The com.esri.aims.mtier.model.map.layer.ImageLayer class represents a raster image layer in the Java Connector. An ImageLayer can be created or retrieved from a map component layer collection:

Code:
com.esri.aims.mtier.model.map.Layers layers = map.getLayers();
com.esri.aims.mtier.model.map.layer.ImageLayer imagelayer = (com.esri.aims.mtier.model.map.layer.ImageLayer) layers.getLayersCollection().get(0);

ImageLayer contains two methods used to query image pixel values: setRasterObject() and getRasterInfo(). The setRasterObject() method takes one argument, a com.esri.aims.mtier.model.map.layer.raster.Raster object. The Raster object uses the setX() and setY() methods to set a point value to be used when querying a pixel in an image layer.

Code:
com.esri.aims.mtier.model.map.layer.raster.Raster raster = new com.esri.aims.mtier.model.map.layer.raster.Raster();
raster.setX(-122.456);
raster.setY(45.432);
imagelayer.setRasterObject(raster);

Once the Raster object for an ImageLayer is set, the next refresh of the Map object which contains the ImageLayer will send a GET_RASTER_INFO ArcXML request. The ImageLayer's getRasterInfo() method will retrieve information in a RASTER_INFO response, including the queried pixel value. The getRasterInfo() method returns a com.esri.aims.mtier.model.map.layer.raster.RasterInfo object containing specific band information inherent to the queried image layer. The example code below assumes that the image layer contains three bands.

Code:
map.refresh();
com.esri.aims.mtier.model.map.layer.raster.RasterInfo rasterinfo = imagelayer.getRasterInfo();
com.esri.aims.mtier.model.map.layer.raster.Bands bands = rasterinfo.getBands(0);
com.esri.aims.mtier.model.map.layer.raster.Band band0 = bands.getBand(0);
com.esri.aims.mtier.model.map.layer.raster.Band band1 = bands.getBand(1);
com.esri.aims.mtier.model.map.layer.raster.Band band2 = bands.getBand(2);
String band0value = band0.getBandValue();
String band1value = band1.getBandValue();
String band2value = band2.getBandValue();

Before the next refresh of the Map object, the Raster object applied to the ImageLayer must be set to null, otherwise another GET_RASTER_INFO request will be sent to the ArcIMS service.

Code:
imagelayer.setRasterObject(null);

Article ID:000005783

Software:
  • Legacy Products

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic