src.dir=./src
dist.dir=./dist
build.dir=./build
proxy.host=[your proxy server name or IP address]
proxy.user=[your proxy user id]
proxy.password=[your proxy password]
log4j.properties=log4j.properties
axis.home=[location where axis is installed]
activation.lib=[location of activation.jar]
authentication.wsdl=http://arcweb.esri.com/services/v2/Authentication.WSDL
mapimage.wsdl=http://arcweb.esri.com/services/v2/MapImage.WSDL
Listing 1: Contents of build.properties
Listing 2: Contents of build.xml
Listing 3: The core ant task is used to define the conversion task.
etc.
Listing 4: Ant tag
package com.nstar.arcweb;
import java.util.Properties;
import org.apache.log4j.Logger;
import com.esri.arcweb.v2.CircleDescription;
import com.esri.arcweb.v2.IMapImage;
import com.esri.arcweb.v2.Layer;
import com.esri.arcweb.v2.MapImageInfo;
import com.esri.arcweb.v2.MapImageLocator;
import com.esri.arcweb.v2.MapImageOptions;
import com.esri.arcweb.v2.MapImageSize;
import com.esri.arcweb.v2.Point;
public class MapClient {
private static final Logger log = Logger.getLogger(MapClient.class);
/**
* @param args
*/
public static void main(String[] args) {
try{
// set the proxy server properties
Properties properties = System.getProperties();
properties.put("http.proxyHost", "your proxy server name or IP
address");
properties.put("http.proxyPort", "your proxy port");
properties.put("http.proxyUser", "your proxy user id");
properties.put("http.proxyPassword", "your proxy password");
Properties newprops = new Properties(properties);
System.setProperties(newprops);
// set esri global account information.
String username = "Esri Global Account username";
String password = "Esri Global Account Password";
//int expiration = 60; // in seconds
//set the data source
String dataSource = "Esri.Basemap.World";
//Locate Authentication Web services
com.esri.arcweb.v2.AuthenticationLocator loc = new
com.esri.arcweb.v2.AuthenticationLocator();
com.esri.arcweb.v2.IAuthentication auth =
loc.getIAuthentication();
//set the map size
MapImageSize miSize = new MapImageSize();
miSize.setHeight(400);
miSize.setWidth(600);
//set the point of interest
double cirRadius = 5.0;
String cirUnits = "Miles";
double cirX = -117.175;
double cirY = 34.055;
Point cirPoint = new Point();
cirPoint.setX(cirX);
cirPoint.setY(cirY);
CircleDescription circle[] = new CircleDescription[1];
CircleDescription circle1 = new CircleDescription();
circle1.setCenter(cirPoint);
circle1.setRadius(cirRadius);
circle1.setRadiusUnits(cirUnits);
circle[0] = circle1;
//Obtain a layers collection array.
MapImageLocator miLocator = new MapImageLocator();
IMapImage mi = miLocator.getIMapImage();
Layer[] layers = mi.getLayerInfo(dataSource);
//set map image options
MapImageOptions miOptions = new MapImageOptions();
miOptions.setDataSource(dataSource);
miOptions.setDisplayLayers(layers);
miOptions.setMapImageFormat("jpg");
miOptions.setMapImageSize(miSize);
miOptions.setReturnLegend(true);
miOptions.setCircles( circle);
//get the map url
MapImageInfo miInfo = mi.getBestMap(miOptions,
auth.getToken(username, password));
log.info(miInfo.getMapUrl());
log.info(miInfo.getLegendUrl());
}catch (Exception e){
log.warn(e);
e.printStackTrace();
}
}
}
Listing 5: Source code for MapClient.java
Properties properties = System.getProperties();
properties.put("http.proxyHost", [your proxy host name];
properties.put("http.proxyPort", "80");
properties.put("http.proxyUser", [your proxy account name];
properties.put("http.proxyPassword", [your proxy account password];
Properties newprops = new Properties(properties);
System.setProperties(newprops);
Figure 6: Properties settings for the proxy server
AuthenticationLocator loc = new AuthenticationLocator();
IAuthentication auth = loc.getIAuthentication();
String token = auth.getToken(username, password);
Figure 7:Obtaining a taken from the Authentication Web Service
MapImageSize miSize = new MapImageSize();
miSize.setHeight(400);
miSize.setWidth(600);
Point cirPoint = new Point();
cirPoint.setX(-117.199577);
cirPoint.setY(34.048364);
CircleDescription circle[] = new CircleDescription[1];
CircleDescription circle1 = new CircleDescription();
circle1.setCenter(cirPoint);
circle1.setRadius(5.0);
circle1.setRadiusUnits("Miles");
circle[0] = circle1;
Listing 8: Code for generating a map of Redlands within a five-mile radius of Esri
MapImageOptions miOptions = new MapImageOptions();
miOptions.setDataSource(dataSource);
miOptions.setDisplayLayers(layers);
miOptions.setMapImageFormat("jpg");
miOptions.setMapImageSize(miSize);
miOptions.setReturnLegend(true);
miOptions.setCircles( circle);
Listing 9: Using the MapImageOPtions object to communicate with the MapImage Web Service.
MapImageInfo miInfo = mi.getBestMap(miOptions, auth.getToken(username,
password));
log.info(miInfo.getMapUrl());
log.info(miInfo.getLegendUrl());
Listing 10: MapImageObject