Java code examples for proxy methods
This page contains Java code examples for ArcGIS Server SOAP proxy class methods and the value objects used for input and output types. The samples apply to both desktop and web applications.
Catalog
GetFolders
String serviceURL = "http://localhost:6080/arcgis/services";
ServiceCatalogBindingStub serviceCatalog = new ServiceCatalogBindingStub(serviceURL);
String[] folders = serviceCatalog.getFolders();
String folderName;
for (int index = 0; index < folders.length; index++){
folderName = folders[index];
System.out.println("Folder Name: " + folderName);
}
GetMessageFormats
String serviceURL = "http://localhost:6080/arcgis/services";
ServiceCatalogBindingStub serviceCatalog = new ServiceCatalogBindingStub(serviceURL);
System.out.println("Message Formats: " + serviceCatalog.getMessageFormats());
GetMessageVersion
String serviceURL = "http://localhost:6080/arcgis/services";
ServiceCatalogBindingStub serviceCatalog = new ServiceCatalogBindingStub(serviceURL);
System.out.println("Message Version: " + serviceCatalog.getMessageVersion());
GetServiceDescriptions
String serviceURL = "http://localhost:6080/arcgis/services";
ServiceCatalogBindingStub serviceCatalog = new ServiceCatalogBindingStub(serviceURL);
ServiceDescription[] sds = serviceCatalog.getServiceDescriptions();
for (int i = 0; i < sds.length; i++) {
ServiceDescription sd = sds[i];
System.out.println("Service Name: " + sd.getName());
System.out.println("Service Capabilities: " + sd.getCapabilities());
System.out.println("Service Type: " + sd.getType());
}
GetServiceDescriptionsEx
String serviceURL = "http://localhost:6080/arcgis/services";
ServiceCatalogBindingStub serviceCatalog = new ServiceCatalogBindingStub(serviceURL);
ServiceDescription[] sds = serviceCatalog.getServiceDescriptionsEx("SecureDirectory");
for (int i = 0; i < sds.length; i++) {
ServiceDescription sd = sds[i];
System.out.println("Service Name: " + sd.getName());
System.out.println("Service Capabilities: " + sd.getCapabilities());
System.out.println("Service Type: " + sd.getType());
System.out.println("Service Parent Type: " + sd.getParentType());
System.out.println("Service URL: " + sd.getUrl());
}
GetTokenServiceURL
String serviceURL = "http://localhost:6080/arcgis/services";
ServiceCatalogBindingStub serviceCatalog = new ServiceCatalogBindingStub(serviceURL);
if(serviceCatalog.requiresTokens()){
System.out.println ("TokenServiceURL: " + serviceCatalog.getTokenServiceURL());
}
RequiresTokens
String serviceURL = "http://localhost:6080/arcgis/services";
ServiceCatalogBindingStub serviceCatalog = new ServiceCatalogBindingStub(serviceURL);
System.out.println ("requiresTokens: " + serviceCatalog.requiresTokens());
MapServer
ComputeDistance
String serviceURL = "http://localhost:6080/arcgis/services/MapService/MapServer";
MapServerBindingStub mapService = new MapServerBindingStub(serviceURL);
String mapName = mapService.getDefaultMapName();
PointN pnt0 = new PointN();
pnt0.setX(-120.0);
pnt0.setY(30.0);
PointN pnt1 = new PointN();
pnt1.setX(-110.0);
pnt1.setY(35.0);
double distance = mapService.computeDistance(mapName, pnt0, pnt1, EsriUnits.esriMiles);
System.out.println("Distance: " + distance);
ComputeScale
String serviceURL = "http://localhost:6080/arcgis/services/MapService/MapServer";
MapServerBindingStub mapService = new MapServerBindingStub(serviceURL);
String mapName = mapService.getDefaultMapName();
MapServerInfo mapInfo = mapService.getServerInfo(mapName);
MapDescription mapDesc = mapInfo.getDefaultMapDescription();
ImageDisplay imgDisp = new ImageDisplay();
imgDisp.setImageHeight(500); //Height of the image in pixels
imgDisp.setImageWidth(500); //Width of the image in pixels
imgDisp.setImageDPI(96);
double scale = mapService.computeScale(mapDesc, imgDisp);
System.out.println("Scale: " + scale);
ExportMapImage
String serviceURL = "http://localhost:6080/arcgis/services/MapService/MapServer";
MapServerBindingStub mapService = new MapServerBindingStub(serviceURL);
String mapName = mapService.getDefaultMapName();
MapServerInfo mapInfo= mapService.getServerInfo(mapName);
MapDescription mapDesc = mapInfo.getDefaultMapDescription();
ImageType imgType = new ImageType();
imgType.setImageFormat(EsriImageFormat.esriImagePNG);
imgType.setImageReturnType(EsriImageReturnType.esriImageReturnURL);
ImageDisplay imgDisp = new ImageDisplay();
imgDisp.setImageHeight(500); //Height of the image in pixels
imgDisp.setImageWidth(500); //Width of the image in pixels
imgDisp.setImageDPI(96);
ImageDescription imgDesc = new ImageDescription();
imgDesc.setImageDisplay(imgDisp);
imgDesc.setImageType(imgType);
MapImage mapImg = mapService.exportMapImage(mapDesc, imgDesc);
System.out.println("Image URL: " + mapImg.getImageURL());
ExportScaleBar
String serviceURL = "http://localhost:6080/arcgis/services/MapService/MapServer";
MapServerBindingStub mapService = new MapServerBindingStub(serviceURL);
//Define scale bar properties
AlternatingScaleBar scaleBar = new AlternatingScaleBar();
scaleBar.setUnits(EsriUnits.esriMiles);
//Define Unit label
TextSymbol unitTextSymbol = new TextSymbol();
unitTextSymbol.setSize(20);
unitTextSymbol.setFontName("Arial");
unitTextSymbol.setText("Mile");
unitTextSymbol.setMaskStyle(EsriMaskStyle.esriMSNone);
unitTextSymbol.setTextDirection(EsriTextDirection.esriTDHorizontal);
unitTextSymbol.setTextCase(EsriTextCase.esriTCNormal);
unitTextSymbol.setTextPosition(EsriTextPosition.esriTPNormal);
unitTextSymbol.setHorizontalAlignment(EsriTextHorizontalAlignment.esriTHACenter);
unitTextSymbol.setVerticalAlignment(EsriTextVerticalAlignment.esriTVATop);
scaleBar.setUnitLabelSymbol(unitTextSymbol);
scaleBar.setUnitLabelPosition(EsriScaleBarPos.esriScaleBarAfterBar);
scaleBar.setUnitLabelGap(10.0);
//Define bar display
scaleBar.setBarHeight(8.0);
scaleBar.setDivision(4.0);
scaleBar.setDivisionMarkHeight(18.0);
scaleBar.setSubdivisions((short)10);
scaleBar.setMarkPosition(EsriVertPosEnum.esriBottom);
SimpleFillSymbol fillSymbol = new SimpleFillSymbol();
RgbColor fillColor = new RgbColor();
fillColor.setRed((short)255);
fillColor.setGreen((short)(0));
fillColor.setBlue((short)(0));
fillSymbol.setColor(fillColor);
fillSymbol.setStyle(EsriSimpleFillStyle.esriSFSSolid);
scaleBar.setFillSymbol1(fillSymbol);
//Define division labels
TextSymbol textSymbol = new TextSymbol();
textSymbol.setSize(20.0);
textSymbol.setFontName("Arial");
textSymbol.setTextDirection(EsriTextDirection.esriTDAngle);
textSymbol.setAngle(45.0);
textSymbol.setText("|");
textSymbol.setMaskStyle(EsriMaskStyle.esriMSNone);
textSymbol.setTextCase(EsriTextCase.esriTCNormal);
textSymbol.setTextPosition(EsriTextPosition.esriTPNormal);
textSymbol.setHorizontalAlignment(EsriTextHorizontalAlignment.esriTHACenter);
textSymbol.setVerticalAlignment(EsriTextVerticalAlignment.esriTVATop);
scaleBar.setLabelSymbol(textSymbol);
scaleBar.setLabelPosition(EsriVertPosEnum.esriAbove);
scaleBar.setLabelFrequency(EsriScaleBarFrequency.esriScaleBarDivisions);
//Define map properties (MapDescription and ImageDisplay)
String mapName = mapService.getDefaultMapName();
MapServerInfo mapInfo= mapService.getServerInfo(mapName);
MapDescription mapDesc = mapInfo.getDefaultMapDescription();
ImageDisplay imgDispMap = new ImageDisplay();
imgDispMap.setImageWidth(500); //Height of the image in pixels
imgDispMap.setImageHeight(500); //Width of the image in pixels
imgDispMap.setImageDPI(96);
//Define scale bar image properties (ImageDescription)
ImageType imgType = new ImageType();
imgType.setImageFormat(EsriImageFormat.esriImagePNG);
imgType.setImageReturnType(EsriImageReturnType.esriImageReturnURL);
ImageDisplay imgDispScalebar = new ImageDisplay();
imgDispScalebar.setImageHeight(75); //Height of the image in pixels
imgDispScalebar.setImageWidth(400); //Width of the image in pixels
ImageDescription imgDescScalebar = new ImageDescription();
imgDescScalebar.setImageDisplay(imgDispScalebar);
imgDescScalebar.setImageType(imgType);
//Define background color
RgbColor backColor = new RgbColor();
backColor.setRed((short)(255));
backColor.setGreen((short)(255));
backColor.setBlue((short)(255));
//Create scale bar image
ImageResult imgResult = mapService.exportScaleBar(scaleBar, mapDesc, imgDispMap, backColor, imgDescScalebar);
System.out.println("Image URL: " + imgResult.getImageURL());
Find
String serviceURL = "http://localhost:6080/arcgis/services/MapService/MapServer";
MapServerBindingStub mapService = new MapServerBindingStub(serviceURL);
String mapName = mapService.getDefaultMapName();
MapServerInfo mapInfo = mapService.getServerInfo(mapName);
MapDescription mapDesc = mapInfo.getDefaultMapDescription();
ImageDisplay imgDisp = new ImageDisplay();
imgDisp.setImageHeight(500); //Height of the image in pixels
imgDisp.setImageWidth(500); //Width of the image in pixels
imgDisp.setImageDPI(96);
String searchString = "Washington";
boolean containsSearchString = true;
String fieldName = ""; // all fields
EsriFindOption findOption = EsriFindOption.esriFindAllLayers;
LayerDescription[] layerDescriptions = mapDesc.getLayerDescriptions();
int[] layerIDs = new int[layerDescriptions.length];
for (int i=0; i< layerDescriptions.length; i++){
layerIDs[i] = layerDescriptions[i].getLayerID();
}
MapServerFindResult[] findResults = mapService.find(mapDesc, imgDisp, searchString, containsSearchString, fieldName, findOption, layerIDs);
System.out.println("Result Count: " + findresults.length);
FromMapPoints
String serviceURL = "http://localhost:6080/arcgis/services/MapService/MapServer";
MapServerBindingStub mapService = new MapServerBindingStub(serviceURL);
String mapName = mapService.getDefaultMapName();
MapServerInfo mapInfo = mapService.getServerInfo(mapName);
MapDescription mapDesc = mapInfo.getDefaultMapDescription();
ImageDisplay imgDisp = new ImageDisplay();
imgDisp.setImageHeight(500); //Height of the image in pixels
imgDisp.setImageWidth(500); //Width of the image in pixels
imgDisp.setImageDPI(96);
PointN[] points = new PointN[1];
PointN pnt0 = new PointN();
pnt0.setX(-120.0);
pnt0.setY(35.0);
points[0] = pnt0;
MultipointN multiPoint = new MultipointN();
multiPoint.setPointArray(points);
Holder<int[]> screenX = new Holder<int[]>();
Holder<int[]> screenY = new Holder<int[]>();
mapService.fromMapPoints(mapDesc, imgDisp, multiPoint, screenX, screenY);
System.out.println("ScreenX: " + screenx.value[0]);
System.out.println("ScreenY: " + screeny.value[0]);
GetCacheName
String serviceURL = "http://localhost:6080/arcgis/services/MapService/MapServer";
MapServerBindingStub mapService = new MapServerBindingStub(serviceURL);
String mapName = mapService.getDefaultMapName();
MapServerInfo mapInfo = mapService.getServerInfo(mapName);
MapDescription mapDesc = mapInfo.getDefaultMapDescription();
LayerDescription[] layerDescriptions = mapDesc.getLayerDescriptions();
for (LayerDescription layerDesc: layerDescriptions)
{
if (mapService.hasLayerCache(mapName, layerDesc.getLayerID()))
{
String layerCacheName = mapService.getCacheName(mapName, layerDesc.getLayerID());
System.out.println("Layer Cache Name: " + layerCacheName);
}
}
GetDefaultMapName
String serviceURL = "http://localhost:6080/arcgis/services/MapService/MapServer";
MapServerBindingStub mapService = new MapServerBindingStub(serviceURL);
String mapName = mapService.getDefaultMapName();
System.out.println("Default Map Name: " + mapname);
GetDocumentInfo
String serviceURL = "http://localhost:6080/arcgis/services/MapService/MapServer";
MapServerBindingStub mapService = new MapServerBindingStub(serviceURL);
PropertySet documentProperties = mapService.getDocumentInfo();
PropertySetProperty[] propertyArray = documentProperties.getPropertyArray();
for (PropertySetProperty documentProp : propertyArray)
{
String key = documentProp.getKey();
System.out.println("Property Name: " + key);
String value = documentProp.getValue().toString();
System.out.println("Property Value: " + value);
}
GetLayerTile
String serviceURL = "http://localhost:6080/arcgis/services/MapService/MapServer";
MapServerBindingStub mapService = new MapServerBindingStub(serviceURL);
String mapName = mapService.getDefaultMapName();
MapServerInfo mapInfo = mapService.getServerInfo(mapName);
MapDescription mapDesc = mapInfo.getDefaultMapDescription();
LayerDescription[] layerDescriptions = mapDesc.getLayerDescriptions();
int layerdescMaxindex = layerDescriptions.length - 1;
EnvelopeN mapExtent = (EnvelopeN)mapDesc.getMapArea().getExtent();
//Use map scale resolution (map units per pixel) to determine tile level
double mapResolution = Math.abs(mapExtent.getXMax() - mapExtent.getXMin()) / width;
//Iterate through layers bottom up. Polygons on bottom, then lines, then points.
for (int d = layerdescMaxindex; d >= 0; d--)
{
LayerDescription layerDesc = layerDescriptions[d];
if (mapService.hasLayerCache(mapName, layerDesc.getLayerID()))
{
TileCacheInfo tci = mapService.getTileCacheInfo(mapName);
LODInfo[] tcis = tci.getLODInfos();
//Map units per pixel
double tileResolution = 0;
//Scale level
int tileLevel = 0;
for (LODInfo ldi : tcis)
{
double ldiResolution = ldi.getResolution();
tileResolution = ldiResolution;
tileLevel = ldi.getLevelID();
if (mapResolution >= ldiResolution)
{
break;
}
}
//Measured from the origin
double minX = mapExtent.getXMin();
double minY = mapExtent.getYMin();
double maxX = mapExtent.getXMax();
double maxY = mapExtent.getYMax();
//Origin of the cache (upper left corner)
double xOrigin = ((PointN)tci.getTileOrigin()).getX();
double yOrigin = ((PointN)tci.getTileOrigin()).getY();
//Get minimum tile column
double minXTile = (minX - xOrigin) / (tci.getTileCols() * tileResolution);
//Get minimum tile row
//From the origin, maxY is minimum y
double minYTile = (yOrigin - maxY) / (tci.getTileRows() * tileResolution);
//Get maximum tile column
double maxXTile = (maxX - xOrigin) / (tci.getTileCols() * tileResolution);
//Get maximum tile row
//From the origin, minY is maximum y
double maxYTile = (yOrigin - minY) / (tci.getTileRows() * tileResolution);
//Return integer value for min and max, row and column
int minTileColumn = (int)Math.floor(minXTile);
int minTileRow = (int)Math.floor(minYTile);
int maxTileColumn = (int)Math.floor(maxXTile);
int maxTileRow = (int)Math.floor(maxYTile);
TileImageInfo tii = mapService.getTileImageInfo(mapName);
//for each row in the map extent
for (int row = minTileRow; row <= maxTileRow; row++)
{
//for each column in the row, in the map extent
for (int col = minTileColumn; col <= maxTileColumn; col++)
{
//Return the byte array of the tile image
byte[] tileByteArray = mapService.getLayerTile(mapName, layerDesc.getLayerID(), tileLevel, row, col, tii.getCacheTileFormat());
System.out.println("Tile Byte Array Length: " + tileByteArray.length);
}
}
}
}
GetLegendInfo
String serviceURL = "http://localhost:6080/arcgis/services/MapService/MapServer";
MapServerBindingStub mapService = new MapServerBindingStub(serviceURL);
String mapName = mapService.getDefaultMapName();
MapServerInfo mapInfo = mapService.getServerInfo(mapName);
MapDescription mapDesc = mapInfo.getDefaultMapDescription();
ImageType imgType = new ImageType();
imgType.setImageFormat(EsriImageFormat.esriImagePNG);
imgType.setImageReturnType(EsriImageReturnType.esriImageReturnURL);
LayerDescription[] layerDescriptions = mapDesc.getLayerDescriptions();
int[] layerIDs = new int[layerDescriptions.length];
int i = 0;
for(LayerDescription layerDesc:layerDescriptions)
{
layerIDs[i++]= layerDesc.getLayerID();
}
MapServerLegendPatch legendPatch = new MapServerLegendPatch();
legendPatch.setImageDPI(96);
legendPatch.setHeight(24);
legendPatch.setWidth(24);
MapServerLegendInfo[] legendInfo = mapService.getLegendInfo(mapName, layerIDs, legendPatch, imgType);
for (MapServerLegendInfo mapLegend : legendInfo) {
System.out.println("Layer ID: " + mapLegend.getLayerID());
System.out.println("Layer Name: " + mapLegend.getName());
}
GetMapCount
String serviceURL = "http://localhost:6080/arcgis/services/MapService/MapServer";
MapServerBindingStub mapService = new MapServerBindingStub(serviceURL);
int mapCount = mapService.getMapCount();
System.out.println("Map Count: " + mapCount);
GetMapName
String serviceURL = "http://localhost:6080/arcgis/services/MapService/MapServer";
MapServerBindingStub mapService = new MapServerBindingStub(serviceURL);
int mapCount = mapService.getMapCount();
for (int i = 0; i < mapCount; i++)
{
String mapName = mapService.getMapName(i);
System.out.println("Map Name: " + mapName);
}
GetMapTile
String serviceURL = "http://localhost:6080/arcgis/services/MapService/MapServer";
MapServerBindingStub mapService = new MapServerBindingStub(serviceURL);
String mapName = mapService.getDefaultMapName();
MapServerInfo mapInfo = mapService.getServerInfo(mapName);
MapDescription mapDesc = mapInfo.getDefaultMapDescription();
EnvelopeN mapExtent = (EnvelopeN)mapDesc.getMapArea().getExtent();
//Use map scale resolution (map units per pixel) to determine tile level
double mapResolution = Math.abs(mapExtent.getXMax() - mapExtent.getXMin()) / width;
if (mapService.hasSingleFusedMapCache(mapName))
{
TileCacheInfo tci = mapService.getTileCacheInfo(mapName);
LODInfo[] tcis = tci.getLODInfos();
//Map units per pixel
double tileResolution = 0;
//Scale level
int tileLevel = 0;
for (LODInfo ldi : tcis)
{
double ldiResolution = ldi.getResolution();
tileResolution = ldiResolution;
tileLevel = ldi.getLevelID();
if (mapResolution >= ldiResolution)
{
break;
}
}
//Measured from the origin
double minX = mapExtent.getXMin();
double minY = mapExtent.getYMin();
double maxX = mapExtent.getXMax();
double maxY = mapExtent.getYMax();
//Origin of the cache (upper left corner)
double xOrigin = ((PointN)tci.getTileOrigin()).getX();
double yOrigin = ((PointN)tci.getTileOrigin()).getY();
//Get minimum tile column
double minXTile = (minX - xOrigin) / (tci.getTileCols() * tileResolution);
//Get minimum tile row
//From the origin, maxY is minimum y
double minYTile = (yOrigin - maxY) / (tci.getTileRows() * tileResolution);
//Get maximum tile column
double maxXTile = (maxX - xOrigin) / (tci.getTileCols() * tileResolution);
//Get maximum tile row
//From the origin, minY is maximum y
double maxYTile = (yOrigin - minY) / (tci.getTileRows() * tileResolution);
//Return integer value for min and max, row and column
int minTileColumn = (int)Math.floor(minXTile);
int minTileRow = (int)Math.floor(minYTile);
int maxTileColumn = (int)Math.floor(maxXTile);
int maxTileRow = (int)Math.floor(maxYTile);
TileImageInfo tii = mapService.getTileImageInfo(mapName);
//for each row in the map extent
for (int row = minTileRow; row <= maxTileRow; row++)
{
//for each column in the row, in the map extent
for (int col = minTileColumn; col <= maxTileColumn; col++)
{
//Return the byte array of the tile image
byte[] tileByteArray = mapService.getMapTile(mapName, tileLevel, row, col, tii.getCacheTileFormat());
//If Tile was found, add it to the consolidated image graphic
if (tileByteArray != null)
{
String currentDir = System.getProperty("user.dir");
FileOutputStream newFile;
try {
newFile = new FileOutputStream(currentDir + "\\" + row + col + ".jpg");
newFile.write(tileByteArray);
newFile.close();
System.out.println("Tile Location: " + currentDir + "\\" + row + col + ".jpg");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}
}
}
GetServerInfo
String serviceURL = "http://localhost:6080/arcgis/services/MapService/MapServer";
MapServerBindingStub mapService = new MapServerBindingStub(serviceURL);
String mapName = mapService.getDefaultMapName();
MapServerInfo mapInfo = mapService.getServerInfo(mapName);
System.out.println("Map Name: " + mapInfo.getName());
GetServiceConfigurationInfo
String serviceURL = "http://localhost:6080/arcgis/services/MapService/MapServer";
MapServerBindingStub mapService = new MapServerBindingStub(serviceURL);
PropertySet serviceProperties = mapService.getServiceConfigurationInfo();
PropertySetProperty[] propertyArray = serviceProperties.getPropertyArray();
for (PropertySetProperty serviceProp : propertyArray)
{
String key = serviceProp.getKey();
System.out.println("Property Name: " + key);
String value = serviceProp.getValue().toString();
System.out.println("Property Value: " + value);
}
GetSQLSyntaxInfo
String serviceURL = "http://localhost:6080/arcgis/services/MapService/MapServer";
MapServerBindingStub mapService = new MapServerBindingStub(serviceURL);
String mapName = mapService.getDefaultMapName();
MapServerInfo mapInfo = mapService.getServerInfo(mapName);
MapDescription mapDesc = mapInfo.getDefaultMapDescription();
LayerDescription[] layerDescriptions = mapDesc.getLayerDescriptions();
for(LayerDescription layerDesc:layerDescriptions)
{
SQLSyntaxInfo sqlSyntaxInfo = mapService.getSQLSyntaxInfo(mapName, layerDesc.getLayerID());
String[] supportedClauses = sqlSyntaxInfo.getSupportedClauses();
for (String supportedClause : supportedClauses) {
System.out.println("Layer ID: " + layerDesc.getLayerID());
System.out.println("Supported Clause: " + supportedClause);
}
}
GetSupportedImageReturnTypes
String serviceURL = "http://localhost:6080/arcgis/services/MapService/MapServer";
MapServerBindingStub mapService = new MapServerBindingStub(serviceURL);
//Mime or Url
EsriImageReturnType imgReturnType = mapService.getSupportedImageReturnTypes();
System.out.println("Image Return Type: " + imgReturnType.getValue());
GetTileCacheInfo
String serviceURL = "http://localhost:6080/arcgis/services/MapService/MapServer";
MapServerBindingStub mapService = new MapServerBindingStub(serviceURL);
String mapName = mapService.getDefaultMapName();
if (mapService.hasSingleFusedMapCache(mapName))
{
TileCacheInfo tileCacheInfo = mapService.getTileCacheInfo(mapName);
System.out.println("Tile DPI: " + tileCacheInfo.getDPI());
}
GetTileImageInfo
String serviceURL = "http://localhost:6080/arcgis/services/MapService/MapServer";
MapServerBindingStub mapService = new MapServerBindingStub(serviceURL);
String mapName = mapService.getDefaultMapName();
if (mapService.hasSingleFusedMapCache(mapName))
{
TileImageInfo tileImageInfo = mapService.getTileImageInfo(mapName);
System.out.println("Compression Quality: " + tileImageInfo.getCompressionQuality());
System.out.println("Anti-Aliasing: " + tileImageInfo.getAntialiasing());
System.out.println("Cache Tile Format: " + tileImageInfo.getCacheTileFormat());
}
GetVirtualCacheDirectory
String serviceURL = "http://localhost:6080/arcgis/services/MapService/MapServer";
MapServerBindingStub mapService = new MapServerBindingStub(serviceURL);
String mapName = mapService.getDefaultMapName();
//Use -1 for fused caches
String virtualCacheDirectory = mapService.getVirtualCacheDirectory(mapName, -1);
System.out.println("Virtual Cache Directory: " + virtualCacheDirectory);
HasLayerCache
String serviceURL = "http://localhost:6080/arcgis/services/MapService/MapServer";
MapServerBindingStub mapService = new MapServerBindingStub(serviceURL);
String mapName = mapService.getDefaultMapName();
MapServerInfo mapInfo = mapService.getServerInfo(mapName);
MapDescription mapDesc = mapInfo.getDefaultMapDescription();
LayerDescription[] layerDescriptions = mapDesc.getLayerDescriptions();
for (LayerDescription layerDesc: layerDescriptions)
{
if (mapService.hasLayerCache(mapName, layerDesc.getLayerID()))
{
String layerCacheName = mapService.getCacheName(mapName, layerDesc.getLayerID());
System.out.println(layerCacheName);
}
}
HasSingleFusedMapCache
String serviceURL = "http://localhost:6080/arcgis/services/MapService/MapServer";
MapServerBindingStub mapService = new MapServerBindingStub(serviceURL);
String mapName = mapService.getDefaultMapName();
if (mapService.hasSingleFusedMapCache(mapName))
{
String fusedCacheName = mapService.getCacheName(mapName, -1);
System.out.println("Fused Cache Name: " + fusedCacheName);
}
Identify
String serviceURL = "http://localhost:6080/arcgis/services/MapService/MapServer";
MapServerBindingStub mapService = new MapServerBindingStub(serviceURL);
String mapName = mapService.getDefaultMapName();
MapServerInfo mapInfo = mapService.getServerInfo(mapName);
MapDescription mapDesc = mapInfo.getDefaultMapDescription();
ImageDisplay imgDisp = new ImageDisplay();
imgDisp.setImageHeight(500); //Height of the image in pixels
imgDisp.setImageWidth(500); //Width of the image in pixels
imgDisp.setImageDPI(96);
PointN inputPoint = new PointN();
inputPoint.setX(-110.0);
inputPoint.setY(35.0);
int tolerance = 3;
EsriIdentifyOption identifyOption = EsriIdentifyOption.esriIdentifyAllLayers;
LayerDescription[] layerDescriptions = mapDesc.getLayerDescriptions();
int[] layerIDs = new int[layerDescriptions.length];
int i = 0;
for(LayerDescription layerDesc:layerDescriptions)
{
layerIDs[i++]= layerDesc.getLayerID();
}
MapServerIdentifyResult[] identifyResults = mapService.identify(mapDesc, imgDisp, inputPoint, tolerance, identifyOption, layerIDs);
System.out.println("Result Count: " + identifyResults.length);
IsFixedScaleMap
String serviceURL = "http://localhost:6080/arcgis/services/MapService/MapServer";
MapServerBindingStub mapService = new MapServerBindingStub(serviceURL);
String mapName = mapService.getDefaultMapName();
if (mapService.isFixedScaleMap(mapName))
{
TileCacheInfo tileCacheInfo = mapService.getTileCacheInfo(mapName);
System.out.println("Tile DPI: " + tileCacheInfo.getDPI());
}
QueryFeatureCount
String serviceURL = "http://localhost:6080/arcgis/services/MapService/MapServer";
MapServerBindingStub mapService = new MapServerBindingStub(serviceURL);
String mapName = mapService.getDefaultMapName();
MapServerInfo mapInfo = mapService.getServerInfo(mapName);
MapLayerInfo[] mapLayerInfos = mapInfo.getMapLayerInfos();
int layerID = 0;
String geometryFieldName = "";
for (MapLayerInfo layerInfo : mapLayerInfos)
{
if (layerInfo.getName().equals("States"))
{
layerID = layerInfo.getLayerID();
Field[] fields = layerInfo.getFields().getFieldArray();
for (Field field : fields)
{
if (field.getType() == EsriFieldType.esriFieldTypeGeometry)
{
geometryFieldName = field.getName();
break;
}
}
}
}
EnvelopeN envelope = new EnvelopeN();
envelope.setXMin(-180.0);
envelope.setYMin(0.0);
envelope.setXMax(180.0);
envelope.setYMax(90.0);
SpatialFilter spatialFilter = new SpatialFilter();
spatialFilter.setFilterGeometry(envelope);
spatialFilter.setGeometryFieldName(geometryFieldName);
spatialFilter.setSpatialRel(EsriSpatialRelEnum.esriSpatialRelIntersects);
//'T***F****' - Does not touch the boundary and interiors intersect
spatialFilter.setSpatialRelDescription("T***F****");
spatialFilter.setWhereClause("POP1990 > 550043");
spatialFilter.setSearchOrder(EsriSearchOrder.esriSearchOrderAttribute);
int featureCount = mapService.queryFeatureCount(mapName, layerID, spatialFilter);
System.out.println("Feature Count: " + featureCount);
QueryFeatureData
String serviceURL = "http://localhost:6080/arcgis/services/MapService/MapServer";
MapServerBindingStub mapService = new MapServerBindingStub(serviceURL);
String mapName = mapService.getDefaultMapName();
MapServerInfo mapInfo = mapService.getServerInfo(mapName);
MapLayerInfo[] mapLayerInfos = mapInfo.getMapLayerInfos();
int layerID = 0;
for (MapLayerInfo layerInfo : mapLayerInfos)
{
if (layerInfo.getName().equals("States"))
{
layerID = layerInfo.getLayerID();
}
}
QueryFilter queryFilter = new QueryFilter();
queryFilter.setWhereClause("STATE_NAME LIKE '%Ca%'");
RecordSet recordSet = null;
recordSet = mapService.queryFeatureData(mapName, layerID, queryFilter);
Field[] fields = recordSet.getFields().getFieldArray();
System.out.println("Field Names...");
for(Field field : fields)
{
System.out.println(field.getAliasName());
}
QueryFeatureIDs
String serviceURL = "http://localhost:6080/arcgis/services/MapService/MapServer";
MapServerBindingStub mapService = new MapServerBindingStub(serviceURL);
String mapName = mapService.getDefaultMapName();
MapServerInfo mapInfo = mapService.getServerInfo(mapName);
MapLayerInfo[] mapLayerInfos = mapInfo.getMapLayerInfos();
int layerID = 0;
for (MapLayerInfo layerInfo : mapLayerInfos)
{
if (layerInfo.getName().equals("states"))
{
layerID = layerInfo.getLayerID();
}
}
QueryFilter queryFilter = new QueryFilter();
queryFilter.setWhereClause("STATE_NAME LIKE '%Ca%'");
FIDSet fidSet = mapService.queryFeatureIDs(mapName, layerID, queryFilter);
int[] fids = fidSet.getFIDArray();
for(int fid : fids)
{
System.out.println("FID: " + fid);
}
QueryHyperlinks
String serviceURL = "http://localhost:6080/arcgis/services/MapService/MapServer";
MapServerBindingStub mapService = new MapServerBindingStub(serviceURL);
String mapName = mapService.getDefaultMapName();
MapServerInfo mapInfo = mapService.getServerInfo(mapName);
MapDescription mapDesc = mapInfo.getDefaultMapDescription();
ImageDisplay imgDisp = new ImageDisplay();
imgDisp.setImageHeight(500); //Height of the image in pixels
imgDisp.setImageWidth(500); //Width of the image in pixels
imgDisp.setImageDPI(96);
LayerDescription[] layerDescriptions = mapDesc.getLayerDescriptions();
int[] layerIDs = new int[layerDescriptions.length];
int i = 0;
for (LayerDescription layerDesc : layerDescriptions)
{
layerIDs[i++] = layerDesc.getLayerID();
}
MapServerHyperlink[] hyperLinkResults = mapService.queryHyperlinks(mapDesc, imgDisp, layerIDs);
for (MapServerHyperlink hyperLinkResult : hyperLinkResults) {
System.out.println("Hyperlink URL: " + hyperLinkResult.getURL());
}
ToMapPoints
String serviceURL = "http://localhost:6080/arcgis/services/MapService/MapServer";
MapServerBindingStub mapService = new MapServerBindingStub(serviceURL);
String mapName = mapService.getDefaultMapName();
MapServerInfo mapInfo = mapService.getServerInfo(mapName);
MapDescription mapDesc = mapInfo.getDefaultMapDescription();
ImageDisplay imgDisp = new ImageDisplay();
imgDisp.setImageHeight(500); //Height of the image in pixels
imgDisp.setImageWidth(500); //Width of the image in pixels
imgDisp.setImageDPI(96);
int[] screenX = new int[1];
int[] screenY = new int[1];
screenX[0] = 261;
screenY[0] = 292;
MultipointN multiPoint = (MultipointN)mapService.toMapPoints(mapDesc, imgDisp, screenX, screenY);
Point[] points = multiPoint.getPointArray();
for (Point point : points) {
PointN pointN = (PointN) point;
System.out.println("X: " + pointN.getX());
System.out.println("Y: " + pointN.getY());
}
GeocodeServer
FindAddressCandidates
String serviceURL = "http://localhost:6080/arcgis/services/GeocodeService/GeocodeServer";
GeocodeServerBindingStub geocodeService = new GeocodeServerBindingStub(serviceURL);
//Get supported fields
Fields fields = geocodeService.getAddressFields();
//Setup locator properties
PropertySet propertyMods = geocodeService.getLocatorProperties();
PropertySetProperty[] locatorArray = propertyMods.getPropertyArray();
//street,zip
String street = "600 Trabert Ave";
String zip = "30318";
//Input to FindAddressCandidates
PropertySet address = new PropertySet();
//Address to geocode
PropertySetProperty[] inputFields = new PropertySetProperty[fields.getFieldArray().length];
for (int index = 0; index < fields.getFieldArray().length; index++) {
//Set the values for the supported fields
Field field = fields.getFieldArray()[index];
PropertySetProperty property = new PropertySetProperty();
property.setKey(field.getName());
//Set Street
if (field.getName().toUpperCase().equalsIgnoreCase("STREET")) {
property.setValue(street);
inputFields[index] = property;
continue;
}
//Set zip code
if (field.getName().toUpperCase().equalsIgnoreCase("ZONE")) {
property.setValue(zip);
inputFields[index] = property;
continue;
}
}
//Polulate address
address.setPropertyArray(inputFields);
//Change locator property value
for (int index = 0; index < locatorArray.length; index++) {
PropertySetProperty property = locatorArray[index];
if (property.getKey().equalsIgnoreCase("MinimumCandidateScore")) {
property.setValue("20");
}
}
//FindAddressCandidates
RecordSet candidates = geocodeService.findAddressCandidates(address,null);
//Optional parsing of the results
if (candidates != null) {
String fieldsOutput = "";
for (Field candidateField : candidates.getFields().getFieldArray()) {
fieldsOutput += candidateField.getName();
}
}
for (Record record : candidates.getRecords()) {
String valuesOutput = "";
Object[] values = record.getValues();
for (int index = 0; index < candidates.getFields().getFieldArray().length;index++) {
valuesOutput += " " + values[index].toString();
}
System.out.println(valuesOutput);
}
GeocodeAddress
String serviceURL = "http://localhost:6080/arcgis/services/GeocodeService/GeocodeServer";
GeocodeServerBindingStub geocodeService = new GeocodeServerBindingStub(serviceURL);
String street = "1 Main St.";
String zip = "94105";
PropertySetProperty[] address = new PropertySetProperty[2];
//Set street
PropertySetProperty streetProp = new PropertySetProperty();
streetProp.setKey("STREET");
streetProp.setValue(street);
address[0] = streetProp;
//Set zip
PropertySetProperty zoneProp = new PropertySetProperty();
zoneProp.setKey("ZONE");
zoneProp.setValue(zip);
address[1] = zoneProp;
//Input geocode property set
PropertySet geocodeProp = new PropertySet();
geocodeProp.setPropertyArray(address);
//Geocode address
PropertySet results = geocodeService.geocodeAddress(geocodeProp, null);
for (PropertySetProperty result : results.getPropertyArray()) {
if (result.getKey().equalsIgnoreCase("Shape")) {
PointN geocodePoint = (PointN) result.getValue();
double x = geocodePoint.getX();
double y = geocodePoint.getY();
System.out.println("XY: " + x + ", " + y);
}
}// for
GeocodeAddresses
import java.io.IOException;
import com.esri.arcgisws.*;
public class GeocodeAddressesClass {
public static void main(String[] args) {
try {
GeocodeAddresses();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
public static void GeocodeAddresses() throws IOException {
String username = "username";
String password = "password";
String url = "http://EXAMPLE:6080/arcgis/services/AtlantaStreets/GeocodeServer";
// Setup geocoding service with new token
GeocodeServerBindingStub geocodeService = new GeocodeServerBindingStub(url, username, password);
// Create property set to map locator address fields (key) to fields in the input
// address table (value). In this example they are the same.
PropertySetProperty geocodeProp1 = new PropertySetProperty();
geocodeProp1.setKey("Street");
geocodeProp1.setValue("Street");
PropertySetProperty geocodeProp2 = new PropertySetProperty();
geocodeProp2.setKey("Zip");
geocodeProp2.setValue("Zip");
PropertySetProperty[] propArray = new PropertySetProperty[2];
propArray[0] = geocodeProp1;
propArray[1] = geocodeProp2;
PropertySet geocodePropSet = new PropertySet();
geocodePropSet.setPropertyArray(propArray);
//Create a new recordset to store input addresses to be batch geocoded
RecordSet addressTable = new RecordSet();
Field[] geocodeServiceFields = geocodeService.getAddressFields().getFieldArray();
Field[] fieldArray = new Field[3];
fieldArray[0] = new Field();
fieldArray[0].setName("OID");
fieldArray[0].setType(EsriFieldType.esriFieldTypeOID);
fieldArray[0].setLength(50);
fieldArray[1] = findField(geocodeServiceFields, "Street");
fieldArray[2] = findField(geocodeServiceFields, "ZIP");
Fields fields = new Fields();
fields.setFieldArray(fieldArray);
addressTable.setFields(fields);
//Add records to input address table
Record[] records = new Record[2];
Record record1 = new Record();
Record record2 = new Record();
record1.setValues (new Object[] {1, "30 Marietta St", "30303"});
record2.setValues (new Object[] {2, "55 Trinity Avenue", "30303"});
records[0]=record1;
records[1]=record2;
addressTable.setRecords(records);
// Make the request to the geocoding service to geocode the addresses
RecordSet results = geocodeService.geocodeAddresses(addressTable, geocodePropSet, null);
// Output the results
for (Record record : results.getRecords()) {
StringBuilder sb = new StringBuilder();
for (Object value : record.getValues()) {
if (value instanceof PointN) {
PointN pt = (PointN) value;
sb.append(pt.getX() + "," + pt.getY() + "\t");
}
else {
sb.append(value + "\t");
}
}
System.out.println(sb);
}
Fields fieldsArray = geocodeService.getAddressFields();
for (Field f : fieldsArray.getFieldArray()) {
System.out.println(f.getName());
}
}
public static Field findField(Field[] fields, String name) {
for (Field f : fields) {
if (f.getName().equals(name))
return f;
}
return null;
}
}
GetAddressFields
String serviceURL = "http://localhost:6080/arcgis/services/GeocodeService/GeocodeServer";
GeocodeServerBindingStub geocodeService = new GeocodeServerBindingStub(serviceURL);
//Test GetAddressFields
Fields addressFields = geocodeService.getAddressFields();
Set<String> setOfAddressFields = new HashSet<String>();
System.out.println("Address Field Names...");
for (Field addressField : addressFields.getFieldArray()) {
System.out.println(addressField.getName());
setOfAddressFields.add(addressField.getName());
}
GetCandidateFields
String serviceURL = "http://localhost:6080/arcgis/services/GeocodeService/GeocodeServer";
GeocodeServerBindingStub geocodeService = new GeocodeServerBindingStub(serviceURL);
//Test GetCandidateFields
PropertySet propertyMods = geocodeService.getLocatorProperties();
Fields candidateFields = geocodeService.getCandidateFields(propertyMods);
Set<String> setOfCandidateFields = new HashSet<String>();
System.out.println("Candidate Field Names...");
for (Field candidateField : candidateFields.getFieldArray()) {
System.out.println(candidateField.getName());
setOfCandidateFields.add(candidateField.getName());
}
GetDefaultInputFieldMapping
String serviceURL = "http://localhost:6080/arcgis/services/GeocodeService/GeocodeServer";
GeocodeServerBindingStub geocodeService = new GeocodeServerBindingStub(serviceURL);
//Test GetDefaultInputFieldMapping
Map<String, String> mapOfFieldMappings = new HashMap<String, String>();
PropertySet fieldMapProps = geocodeService.getDefaultInputFieldMapping();
PropertySetProperty[] fieldMapArray = fieldMapProps.getPropertyArray();
System.out.println("Field Map Properties...");
for (PropertySetProperty fieldMapProperty : fieldMapArray) {
System.out.println(fieldMapProperty.getKey() + ": " + fieldMapProperty.getValue());
mapOfFieldMappings.put(fieldMapProperty.getKey(),(String)fieldMapProperty.getValue());
}
GetIntersectionCandidateFields
String serviceURL = "http://localhost:6080/arcgis/services/GeocodeService/GeocodeServer";
GeocodeServerBindingStub geocodeService = new GeocodeServerBindingStub(serviceURL);
//Test GetIntersectionCandidateFields
PropertySet propertyMods2 = geocodeService.getLocatorProperties();
Fields candidateFields2 = geocodeService.getIntersectionCandidateFields(propertyMods2);
Set<String> setOfInterCandiFields = new HashSet<String>();
System.out.println("Intersection Candidate Fields...");
for (Field candidateField : candidateFields2.getFieldArray()) {
System.out.println(candidateField.getName());
setOfInterCandiFields.add(candidateField.getName());
}
GetLocatorProperties
String serviceURL = "http://localhost:6080/arcgis/services/GeocodeService/GeocodeServer";
GeocodeServerBindingStub geocodeService = new GeocodeServerBindingStub(serviceURL);
//Test GetLocatorProperties
PropertySet locatorProps = geocodeService.getLocatorProperties();
PropertySetProperty[] locatorArray = locatorProps.getPropertyArray();
Set<String> setOfLocatorProps = new HashSet<String>();
System.out.println("Locator Properties...");
for (PropertySetProperty locatorProperty : locatorArray) {
System.out.println(locatorProperty.getKey() + ": " + locatorProperty.getValue());
setOfLocatorProps.add(locatorProperty.getKey());
}
GetResultField
String serviceURL = "http://localhost:6080/arcgis/services/GeocodeService/GeocodeServer";
GeocodeServerBindingStub geocodeService = new GeocodeServerBindingStub(serviceURL);
//Test GetResultFields
PropertySet propertyMods3 = geocodeService.getLocatorProperties();
Fields resultFields = geocodeService.getResultFields(propertyMods3);
Set<String> setOfResultFields = new HashSet<String>();
System.out.println("Result Fields...");
for (Field candidateField : resultFields.getFieldArray()) {
System.out.println(candidateField.getName());
setOfResultFields.add(candidateField.getName());
}
GetResultFields
String serviceURL = "http://localhost:6080/arcgis/services/GeocodeService/GeocodeServer";
GeocodeServerBindingStub geocodeService = new GeocodeServerBindingStub(serviceURL);
//Test GetResultFields
PropertySet propertyMods3 = geocodeService.getLocatorProperties();
Fields resultFields = geocodeService.getResultFields(propertyMods3);
Set<String> setOfResultFields = new HashSet<String>();
System.out.println("Result Fields...");
for (Field candidateField : resultFields.getFieldArray()) {
System.out.println(candidateField.getName());
setOfResultFields.add(candidateField.getName());
}
GetStandardizedFields
String serviceURL = "http://localhost:6080/arcgis/services/GeocodeService/GeocodeServer";
GeocodeServerBindingStub geocodeService = new GeocodeServerBindingStub(serviceURL);
//Test GetStandardizedFields
Fields standardizedFields = geocodeService.getStandardizedFields();
Set<String> setOfStdFields = new HashSet<String>();
System.out.println("Standardized Fields...");
for (Field stdField : standardizedFields.getFieldArray()) {
System.out.println(stdField.getName());
setOfStdFields.add(stdField.getName());
}
GetStandardizedIntersectionFields
String serviceURL = "http://localhost:6080/arcgis/services/GeocodeService/GeocodeServer";
GeocodeServerBindingStub geocodeService = new GeocodeServerBindingStub(serviceURL);
//Test GetStandardizedIntersectionFields
Fields standInterFields = geocodeService.getStandardizedIntersectionFields();
Set<String> setOfStdInterFields = new HashSet<String>();
System.out.println("Standardized Intersection Fields...");
for (Field stdInterField : standInterFields.getFieldArray()) {
System.out.println(stdInterField.getName());
setOfStdInterFields.add(stdInterField.getName());
}
ReverseGeocode
String serviceURL = "http://localhost:6080/arcgis/services/GeocodeService/GeocodeServer";
GeocodeServerBindingStub geocodeService = new GeocodeServerBindingStub(serviceURL);
//Set reverse geocode search parameters
PropertySetProperty revGeocodeProp1 = new PropertySetProperty();
revGeocodeProp1.setKey("ReverseDistanceUnits");
revGeocodeProp1.setValue("Meters");
PropertySetProperty revGeocodeProp2 = new PropertySetProperty();
revGeocodeProp2.setKey("ReverseDistance");
revGeocodeProp2.setValue("100");
//Optionally define output spatial reference for reverse geocoded point
ProjectedCoordinateSystem projectedCoordinateSystem = new ProjectedCoordinateSystem();
projectedCoordinateSystem.setWKID(54004);
PropertySetProperty revGeocodeProp3 = new PropertySetProperty();
revGeocodeProp3.setKey("OutputSpatialReference");
revGeocodeProp3.setValue(projectedCoordinateSystem);
PropertySetProperty[] propArray = new PropertySetProperty[] {
revGeocodeProp1, revGeocodeProp2, revGeocodeProp3 };
PropertySet revGeocodePropSet = new PropertySet();
revGeocodePropSet.setPropertyArray(propArray);
//Create point to reverse geocode, define input spatial reference
GeographicCoordinateSystem geographicCoordinateSystem = new GeographicCoordinateSystem();
geographicCoordinateSystem.setWKID(4326);
double xCoord = -122.39649504;
double yCoord = 37.7931136;
PointN inputPoint = new PointN();
inputPoint.setX(xCoord);
inputPoint.setY(yCoord);
inputPoint.setSpatialReference(geographicCoordinateSystem);
//Reverse geocode
PropertySet results = geocodeService.reverseGeocode(inputPoint, false, revGeocodePropSet);
System.out.println("Results...");
PropertySetProperty[] pSetPropertyArray = results.getPropertyArray();
for (PropertySetProperty pSetArray : pSetPropertyArray) {
String key = pSetArray.getKey();
Object value = pSetArray.getValue();
System.out.println(key + ": " + value);
}
StandardizeAddress
String serviceURL = "http://localhost:6080/arcgis/services/GeocodeService/GeocodeServer";
GeocodeServerBindingStub geocodeService = new GeocodeServerBindingStub(serviceURL);
//Create an address - This is specific to San Francisco
PropertySetProperty geocodeProp1 = new PropertySetProperty();
geocodeProp1.setKey("Street");
geocodeProp1.setValue("1 Main St.");
PropertySetProperty geocodeProp2 = new PropertySetProperty();
geocodeProp2.setKey("Zone");
geocodeProp2.setValue("94105");
PropertySetProperty[] propArray = new PropertySetProperty[2];
propArray[0] = geocodeProp1;
propArray[1] = geocodeProp2;
PropertySet geocodePropSet = new PropertySet();
geocodePropSet.setPropertyArray(propArray);
//StandardizeAddress
PropertySet standardizedAddress = geocodeService.standardizeAddress(geocodePropSet, null);
PropertySetProperty[] standardArray = standardizedAddress.getPropertyArray();
Map<String, String> mapOfStandardizedAddr = new HashMap<String, String>();
System.out.println("Standardized Address Properties..");
for (PropertySetProperty result : standardArray) {
System.out.println(result.getKey() + ": " + result.getValue());
mapOfStandardizedAddr.put(result.getKey(), (String) result.getValue());
}
GPServer
CancelJob
String serviceURL = "http://localhost:6080/arcgis/services/GPService/GPServer";
GPServerBindingStub gpService = new GPServerBindingStub(serviceURL);
//Set up input values
GPString inString = new GPString();
inString.setValue("test string");
GPDouble inDbl = new GPDouble();
inDbl.setValue(55.98);
GPValue[] inputValues = {inString, inDbl};
//input Service Name
String gpServiceName = "SimpleParamTests";
//Submit Job
String submitJobID = gpService.submitJob(gpServiceName, inputValues, null, null);
//Check Job Status
EsriJobStatus jobStat = gpService.getJobStatus(submitJobID);
//If the job is submitted, cancel it and get the status again
if (jobStat.getValue().toLowerCase() == EsriJobStatus.esriJobSubmitted.getValue().toLowerCase()) {
gpService.cancelJob(submitJobID);
jobStat = gpService.getJobStatus(submitJobID);
System.out.print ("Job status is " + jobStat.getValue());
}
Execute
String serviceURL = "http://localhost:6080/arcgis/services/GPService/GPServer";
GPServerBindingStub gpService = new GPServerBindingStub(serviceURL);
//Set up input values
GPString inString = new GPString();
inString.setValue("test string");
GPDouble inDbl = new GPDouble();
inDbl.setValue(55.98);
GPValue[] inputValues = {inString, inDbl};
//input Service Name
String gpServiceName = "SimpleParamTests";
GPResult result = null;
//Submit Job
String submitJobID = gpService.submitJob(gpServiceName, inputValues, null, null);
try
{
//Check Job Status
EsriJobStatus jobStat = gpService.getJobStatus(submitJobID);
//Ensure the jobs status is succeed, then you can call the rest of tests
while (jobStat != EsriJobStatus.esriJobSucceeded)
result = gpService.execute(gpServiceName, inputValues, null, null);
} catch (Exception e){
System.out.println("Exception occured: " + e.getStackTrace());
}
GetExecutionType
String serviceURL = "http://localhost:6080/arcgis/services/GPService/GPServer";
GPServerBindingStub gpService = new GPServerBindingStub(serviceURL);
EsriExecutionType eType = gpService.getExecutionType();
System.out.println(eType.getValue());
GetJobInputValues
GPToolInfo ti = new GPToolInfo();
GPParameterInfo[] pis = null;
String[] inParams = null;
GPValue[] values = null;
int rlength = 0;
int n=0;
if (jobStat.toString() == EsriJobStatus.esriJobSucceeded.toString()) {
if (modelNumber == 0 || modelNumber == 1 || modelNumber == 2 || modelNumber == 7 || modelNumber ==8) {
ti = gpService.getToolInfo(modelName);
int paramLen = ti.getParameterInfo().length;
pis = new GPParameterInfo[paramLen];
pis = ti.getParameterInfo();
if ((jobStat.toString()!= EsriJobStatus.esriJobFailed.toString()) && (jobStat.toString() != EsriJobStatus.esriJobTimedOut.toString()))
{
n=0;
inParams = new String[paramLen];
for (int k = 0; k<pis.length; k++)
{
GPParameterInfo pi = pis[k];
if ( (pi.getDirection() == EsriGPParameterDirection.esriGPParameterDirectionInput)){
inParams[n] = pi.getName();
n++;
}
String[] inputParams = new String[n];
for (int s = 0; s<n; s++) inputParams[s] = inParams[s];
values = gpService.getJobInputValues(submitJobID, inputParams);
rlength = values.length;
for (int s = 0; s<rlength; s++)
{
xHelper.Serialize(testType, values, modelNumber, s, testPath + File.separator + "Input", "Layer", ef.getServerName());
} //for s
} //if jobStat
else {
System.out.print("Cannot get Job Result, Job Status = " + jobStat.toString());
} //else
}
} //if
GetJobMessages
JobMessage[] msgs = gpService.getJobMessages(submitJobID);
GetJobResult
String serviceURL = "http://localhost:6080/arcgis/services/GPService/GPServer";
GPServerBindingStub gpService = new GPServerBindingStub(serviceURL);
//Set up input value
GPString inString = new GPString();
inString.setValue("test string");
GPDouble inDbl = new GPDouble();
inDbl.setValue(55.98);
GPValue[] inputValues = {inString, inDbl};
//input Service Name
String gpServiceName = "SimpleParamTests";
//Submit Job
String submitJobID = gpService.submitJob(gpServiceName, inputValues, null, null);
//Check Job Status
EsriJobStatus jobStat = gpService.getJobStatus(submitJobID);
//Ensure the jobs status is succeed
if (jobStat == EsriJobStatus.esriJobSucceeded) {
GPResult result = gpService.getJobResult(submitJobID, null, null);
}
GetJobResultOptions
GPResultOptions gpROp = new GPResultOptions();
gpROp = gpService.getJobResultOptions(this.submitJobID);
GetJobStatus
//First job is submitted, then canceled, then use GetJobStatus() to see if the status is cancelled.
String serviceURL = "http://localhost:6080/arcgis/services/GPService/GPServer";
GPServerBindingStub gpService = new GPServerBindingStub(serviceURL);
//Set up input values
GPString inString = new GPString();
inString.setValue("test string");
GPDouble inDbl = new GPDouble();
inDbl.setValue(55.98);
GPValue[] inputValues = {inString, inDbl};
//input Service Name
String gpServiceName = "SimpleParamTests";
//Submit Job
String submitJobID = gpService.submitJob(gpServiceName, inputValues, null, null);
//Check Job Status
EsriJobStatus jobStat = gpService.getJobStatus(submitJobID);
GetJobToolName
//if the job is successful, get the job tool name
if (jobStat.toString() == EsriJobStatus.esriJobSucceeded.toString()) {
String toolName = "";
try {
toolName = gpService.getJobToolName(GPSvrPostSubmit.submitJobID);
} catch(Exception e){
e.printStackTrace();
}
}
GetResultMapServerName
String ServerName = gpService.getResultMapServerName();
GetResultWorkspace
EsriGDSTransportType gtype = EsriGDSTransportType.esriGDSTransportTypeUrl;
//if the jobStat is success
if (jobStat.toString() == EsriJobStatus.esriJobSucceeded.toString()) {
GDSData gData = gpService.getResultWorkspace(submitJobID,gtype);
}
GetTaskInfos
String serviceURL = "http://localhost:6080/arcgis/services/GPService/GPServer";
GPServerBindingStub gpService = new GPServerBindingStub(serviceURL);
int Length = gpService.getToolInfos().length;
String[] taskOrInfoNames = new String[Length];
for (int i = 0; i<Length; i++){
taskOrInfoNames[i] = gpService.getTaskInfos()[i].getName();
System.out.println(taskOrInfoNames[i]);
}
GetTaskNames
String serviceURL = "http://localhost:6080/arcgis/services/GPService/GPServer";
GPServerBindingStub gpService = new GPServerBindingStub(serviceURL);
String[] taskNames = gpService.getTaskNames();
int length = taskNames.length;
if (length != 0) {
for (int i = 0; i< length; i++) {
System.out.println(taskNames[i]);
}
}
GetToolInfo
String serviceURL = "http://localhost:6080/arcgis/services/GPService/GPServer";
GPServerBindingStub gpService = new GPServerBindingStub(serviceURL);
//Obtain tool name
String toolNames[] = gpService.getToolNames();
int length = toolNames.length;
GPToolInfo[] toolInfo = new GPToolInfo[length];
//Call GetToolInfo
for (int i = 0; i< length; i++) {
toolInfo[i] = gpService.getToolInfo(toolNames[i]);
System.out.println(toolInfo[i].getDisplayName());
}
GetToolInfos
String serviceURL = "http://localhost:6080/arcgis/services/GPService/GPServer";
GPServerBindingStub gpService = new GPServerBindingStub(serviceURL);
String[] taskOrInfoNames = null;
int Length = gpService.getToolInfos().length;
taskOrInfoNames = new String[Length];
for (int i = 0; i<Length; i++){
taskOrInfoNames[i] = gpService.getToolInfos()[i].getDisplayName();
System.out.println(taskOrInfoNames[i].toString());
}
GetToolNames
String serviceURL = "http://localhost:6080/arcgis/services/GPService/GPServer";
GPServerBindingStub gpService = new GPServerBindingStub(serviceURL);
String toolNames[] = gpService.getToolNames();
int length = toolNames.length;
if (length != 0) {
for (int i = 0; i< length; i++) {
System.out.println(toolNames[i]);
}
}
SubmitJob
String serviceURL = "http://localhost:6080/arcgis/services/GPService/GPServer";
GPServerBindingStub gpService = new GPServerBindingStub(serviceURL);
//Set up input values
GPString inString = new GPString();
inString.setValue("test string");
GPDouble inDbl = new GPDouble();
inDbl.setValue(55.98);
GPValue[] inputValues = {inString, inDbl};
//input Service Name
String gpServiceName = "SimpleParamTests";
//Submit Job
String submitJobID = gpService.submitJob(gpServiceName, inputValues, null, null);
GeoDataServer
ExtractData
GDSData extractedData = geoDataService.extractData(null, replicaDesc, exportOpts, transportType);
GetDataElements
DEBrowseOptions browseOptions = new DEBrowseOptions();
browseOptions.setExpandType(EsriDEExpandType.esriDEExpandChildren);
browseOptions.setRetrieveFullProperties(true);
browseOptions.setRetrieveMetadata(true);
DataElement[] ele = geoDataService.getDataElements(browseOptions);
GetDefaultWorkingVersion
String defaultWorkingVersion = geoDataService.getDefaultWorkingVersion();
GetMaxRecordCount
//Test GetMaxRecordCount
int maxRecordCount = geoDataService.getMaxRecordCount();
GetNextResultPortion
GDSQueryResultPortion gdsQueryResPortion = geoDataService.getNextResultPortion(resultInfo);
GetReplicas
//Test GetReplicas
Set<String> setOfReplicas = new HashSet<String>();
GPReplica[] replicas = geoDataService.getReplicas();
for (GPReplica replica : replicas) {
setOfReplicas.add(replica.getName());
}
GetVersions
GPVersionInfo[] gpVersionInfoss = geoDataService.getVersions();
GetWrappedWorkspaceType
//Test GetWrappedWorkspaceType
EsriWorkspaceType workspaceType = geoDataService.getWrappedWorkspaceType();
ImportAcknowledgement
geoDataService.importAcknowledgement(extractedData);
ImportData
geoDataService.importData(extractedData, EsriGDSImportFormat.esriGDSImportFormatFileGDB);
TableSearch
GDSQueryResultPortion queryResults = geoDataService.tableSearch(null, "states", qf, resultInfo);
UnregisterReplica
geoDataService.unregisterReplica("test");
GeometryServer
Buffer
String serviceURL = "http://localhost:6080/arcgis/services/Geometry/GeometryServer";
GeometryServerBindingStub geometryService = new GeometryServerBindingStub(serviceURL);
SpatialReference inputSpatialReference = new GeographicCoordinateSystem();
inputSpatialReference
.setWKT("GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]]");
//Set buffer spatial reference
SpatialReference bufferSpatialReference = new ProjectedCoordinateSystem();
bufferSpatialReference.setWKID(102004);// USA_Contiguous_Lambert_Conformal_Conic
//Set output spatial reference
SpatialReference outputSpatialReference = inputSpatialReference;
//Input points
PointN inputPoint1 = new PointN();
inputPoint1.setX(-110);
inputPoint1.setY(40);
PointN inputPoint2 = new PointN();
inputPoint2.setX(-120);
inputPoint2.setY(45);
//Input geometry
Geometry[] inputGeometry = new Geometry[] { inputPoint1, inputPoint2 };
//Distance for buffer for each point
double[] distances = new double[] { 400, 200 };
//Set the unit
LinearUnit linearUnit = new LinearUnit();
linearUnit.setWKID(9035);
boolean bUnionResults = false;
//Run the buffer operation
Geometry[] outputGeometry = geometryService.buffer(
inputSpatialReference, bufferSpatialReference, outputSpatialReference,
distances, linearUnit, bUnionResults, inputGeometry);
for (Geometry geom : outputGeometry) {
if (geom instanceof PolygonN){
PolygonN polygon = (PolygonN) geom;
EnvelopeN extent = (EnvelopeN) polygon.getExtent();
System.out.println("Extent - XMin,YMin: " + extent.getXMin() + "," + extent.getYMin() + " XMax,YMax: " + extent.getXMax() + "," + extent.getYMax());
}
}
Densify
String serviceURL = "http://localhost:6080/arcgis/services/Geometry/GeometryServer";
GeometryServerBindingStub geometryService = new GeometryServerBindingStub(serviceURL);
//Input spatial reference
SpatialReference inputSpatialReference = new ProjectedCoordinateSystem();
inputSpatialReference.setWKID(54004); // World Mercator
//Points that will form a path
PointN p1 = new PointN();
p1.setX(500000);
p1.setY(500000);
PointN p2 = new PointN();
p2.setX(600000);
p2.setY(50000);
PointN p3 = new PointN();
p3.setX(700000);
p3.setY(50000);
PointN[] pointsArray = new PointN[] { p1, p2, p3 };
//Create a path
Path inputPath = new Path();
inputPath.setPointArray(pointsArray);
Path[] paths = new Path[] { inputPath };
//Create a polyline
PolylineN inputPolyline = new PolylineN();
inputPolyline.setPathArray(paths);
//Input geometry
Geometry[] inputGeometry = new Geometry[] { inputPolyline };
//Densify parameters
double maxSegmentLength = 10000;
boolean bUseDeviationDensification = false;
double densificationParam = 0;
//Densify
Geometry[] outputGeometry = geometryService.densify(
inputSpatialReference, inputGeometry, maxSegmentLength,
bUseDeviationDensification, densificationParam);
for (Geometry geom : outputGeometry) {
if (geom instanceof PolylineN){
PolylineN polyline = (PolylineN) geom;
EnvelopeN extent = (EnvelopeN) polyline.getExtent();
System.out.println("Extent - XMin,YMin: " + extent.getXMin() + "," + extent.getYMin() + " XMax,YMax: " + extent.getXMax() + "," + extent.getYMax());
}
}
FindSRByWKID
String serviceURL = "http://localhost:6080/arcgis/services/Geometry/GeometryServer";
GeometryServerBindingStub geometryService = new GeometryServerBindingStub(serviceURL);
SpatialReference outputSpatialReference = null;
//Test FindSRByWKID - Geographic WGS84
outputSpatialReference = geometryService.findSRByWKID("EPSG", 4326, -1, true, true);
boolean bIsHighPrecision = outputSpatialReference.getHighPrecision();
System.out.println("IsHighPrecision: " + bIsHighPrecision);
FindSRByWKT
String serviceURL = "http://localhost:6080/arcgis/services/Geometry/GeometryServer";
GeometryServerBindingStub geometryService = new GeometryServerBindingStub(serviceURL);
//Test FindSRByWKT - Geographic WGS84
SpatialReference outputSpatialReference = geometryService.findSRByWKT(
"GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],"
+ "UNIT[\"Degree\",0.0174532925199433]]","", true, true);
int expectedWKID = outputSpatialReference.getWKID();
System.out.println("Output Spatial Reference WKID: " + expectedWKID);
FindUnitsByWKID
String serviceURL = "http://localhost:6080/arcgis/services/Geometry/GeometryServer";
GeometryServerBindingStub geometryService = new GeometryServerBindingStub(serviceURL);
//Test FindUnitsByWKID - International Meter
LinearUnit linearUnit = (LinearUnit) geometryService.findUnitsByWKID("EPSG", 9001);
System.out.println("WKT: " + linearUnit.getWKT());
FindUnitsByWKT
String serviceURL = "http://localhost:6080/arcgis/services/Geometry/GeometryServer";
GeometryServerBindingStub geometryService = new GeometryServerBindingStub(serviceURL);
//Test FindUnitsByWKT - International Meter
LinearUnit linearUnit2 = (LinearUnit) geometryService.findUnitsByWKT(
"UNIT[\"Foot_US\",0.3048006096012192,AUTHORITY[\"EPSG\",9003]]");
System.out.println("WKID: " + linearUnit2.getWKID());
GetAreasAndLengths
String serviceURL = "http://localhost:6080/arcgis/services/Geometry/GeometryServer";
GeometryServerBindingStub geometryService = new GeometryServerBindingStub(serviceURL);
//Test GetAreasAndLength
SpatialReference inputSpatialReference = geometryService.findSRByWKID(
"EPSG", 54004, -1, true, true);
//New PointN array
PointN pnt1 = new PointN();
pnt1.setX(100000);
pnt1.setY(300000);
PointN pnt2 = new PointN();
pnt2.setX(100000);
pnt2.setY(350000);
PointN pnt3 = new PointN();
pnt3.setX(900000);
pnt3.setY(350000);
PointN[] points1 = new PointN[] { pnt1, pnt2, pnt3 };
//New PolylineN
Path path1 = new Path();
path1.setPointArray(points1);
Path[] paths1 = new Path[] { path1 };
PolylineN polylinen = new PolylineN();
polylinen.setPathArray(paths1);
//New PolygonN
Ring ring1 = new Ring();
ring1.setPointArray(points1);
Ring[] rings1 = new Ring[] { ring1 };
PolygonN polygonN1 = new PolygonN();
polygonN1.setRingArray(rings1);
PolygonN[] polygonArray1 = new PolygonN[] { polygonN1 };
//Get areas and length
Holder<double[]> lengthsArray = new Holder<double[]>();
Holder<double[]> areasArray = new Holder<double[]>();
geometryService.getAreasAndLengths(inputSpatialReference, polygonArray1,
lengthsArray, areasArray);
//result
System.out.println(areasArray.value[0]);
System.out.println(lengthsArray.value[0]);
GetLabelPoints
String serviceURL = "http://localhost:6080/arcgis/services/Geometry/GeometryServer";
GeometryServerBindingStub geometryService = new GeometryServerBindingStub(serviceURL);
//Test GetLabelPoints
SpatialReference inputSpatialReference2 = geometryService.findSRByWKID(
"EPSG", 4269, -1, true, true);
//Setup the geometry
PointN p1 = new PointN();
p1.setX(10.0);
p1.setY(30.0);
PointN p2 = new PointN();
p2.setX(10.0);
p2.setY(40.0);
PointN p3 = new PointN();
p3.setX(20.0);
p3.setY(40.0);
PointN p4 = new PointN();
p4.setX(20.0);
p4.setY(30.0);
PointN p5 = new PointN();
p5.setX(10.0);
p5.setY(30.0);
PointN[] points2 = new PointN[] { p1, p2, p3, p4, p5 };
Ring ring2 = new Ring();
ring2.setPointArray(points2);
Ring[] rings2 = new Ring[] { ring2 };
PolygonN polygonN2 = new PolygonN();
polygonN2.setRingArray(rings2);
PolygonN[] polygonArray2 = new PolygonN[] { polygonN2 };
//GetLabelPoints
Point[] labelPoints = (Point[]) geometryService.getLabelPoints(
inputSpatialReference2, polygonArray2);
for (Point labelPoint : labelPoints)
{
PointN labelPointN = (PointN) labelPoint;
System.out.println("Label Point: " + labelPointN.getX() + ", " + labelPointN.getY());
}
GetLengths
String serviceURL = "http://localhost:6080/arcgis/services/Geometry/GeometryServer";
GeometryServerBindingStub geometryService = new GeometryServerBindingStub(serviceURL);
//Test GetLengths
SpatialReference inputSpatialReference3 = geometryService.findSRByWKID(
"EPSG", 54004, -1, true, true);
//Create some points for a polyline
PointN pnt1 = new PointN();
pnt1.setX(100000);
pnt1.setY(300000);
PointN pnt2 = new PointN();
pnt2.setX(100000);
pnt2.setY(350000);
PointN pnt3 = new PointN();
pnt3.setX(900000);
pnt3.setY(350000);
PointN[] points3 = new PointN[] { pnt1, pnt2, pnt3 };
//New PolylineN
Path path3 = new Path();
path3.setPointArray(points3);
Path[] paths3 = new Path[] { path3 };
PolylineN polylineN3 = new PolylineN();
polylineN3.setPathArray(paths3);
PolylineN[] polylineArray3 = new PolylineN[] { polylineN3 };
//Get the length of the polyline
double[] lengths3 = geometryService.getLengths(inputSpatialReference3, polylineArray3);
for (double length : lengths3){
System.out.println("Length: " + length);
}
Relation
String serviceURL = "http://localhost:6080/arcgis/services/Geometry/GeometryServer";
GeometryServerBindingStub geometryService = new GeometryServerBindingStub(serviceURL);
//Set the input spatial reference
SpatialReference inputSpatialReference = new GeographicCoordinateSystem();
inputSpatialReference.setWKID(4326);
//First input geometry array - 1 polygon
PointN pnt1a = new PointN();
pnt1a.setX(10.0);
pnt1a.setY(30.0);
PointN pnt2a = new PointN();
pnt2a.setX(10.0);
pnt2a.setY(45.0);
PointN pnt3a = new PointN();
pnt3a.setX(25.0);
pnt3a.setY(45.0);
PointN pnt4a = new PointN();
pnt4a.setX(25.0);
pnt4a.setY(30.0);
PointN pnt5a = new PointN();
pnt5a.setX(10.00);
pnt5a.setY(30.0);
PointN[] pnts1a = new PointN[] { pnt1a, pnt2a, pnt3a, pnt4a, pnt5a };
Ring ring1 = new Ring();
ring1.setPointArray(pnts1a);
Ring[] rings = new Ring[] { ring1 };
PolygonN polygon1 = new PolygonN();
polygon1.setRingArray(rings);
Geometry[] inputGeometry1 = new Geometry[] { polygon1 };
//Second input geometry array - 3 points
PointN pnt1b = new PointN();
pnt1b.setX(20.0);
pnt1b.setY(40.0);
PointN pnt2b = new PointN();
pnt2b.setX(10.0);
pnt2b.setY(30.0);
PointN pnt3b = new PointN();
pnt3b.setX(50.0);
pnt3b.setY(50.0);
Geometry[] inputGeometry2 = new Geometry[3];
//Inside polygon
inputGeometry2[0] = pnt1b;
//Edge of polygon
inputGeometry2[1] = pnt2b;
//Outside polygon
inputGeometry2[2] = pnt3b;
//If esriGeometryRelationRelation, define relation parameter
EsriGeometryRelationEnum enumRelate = EsriGeometryRelationEnum.esriGeometryRelationRelation;
//G1 = first (base) geometry array, G2 = second (comparison) geometry array
String relationParameter = "G2 INTERSECT G1.BOUNDARY";
RelationResult[] relationResults = geometryService.relation(
inputSpatialReference, inputGeometry1, inputGeometry2, enumRelate, relationParameter);
for (RelationResult relationResult : relationResults){
System.out.println("Left Index: " + relationResult.getLeftIndex());
System.out.println("Right Index: " + relationResult.getRightIndex());
}
Simplify
String serviceURL = "http://localhost:6080/arcgis/services/Geometry/GeometryServer";
GeometryServerBindingStub geometryService = new GeometryServerBindingStub(serviceURL);
SpatialReference inputSpatialReference = geometryService.findSRByWKID(
"EPSG", 4326, -1, true, true);
//Ring 1
PointN pnt1a = new PointN();
pnt1a.setX(10.0);
pnt1a.setY(30.0);
PointN pnt2a = new PointN();
pnt2a.setX(10.0);
pnt2a.setY(45.0);
PointN pnt3a = new PointN();
pnt3a.setX(25.0);
pnt3a.setY(45.0);
PointN pnt4a = new PointN();
pnt4a.setX(25.0);
pnt4a.setY(30.0);
PointN pnt5a = new PointN();
pnt5a.setX(10.0);
pnt5a.setY(30.0);
PointN[] pnts1a = new PointN[] { pnt1a, pnt2a, pnt3a, pnt4a, pnt5a };
Ring ring1 = new Ring();
ring1.setPointArray(pnts1a);
//Ring 2
PointN pnt1b = new PointN();
pnt1b.setX(15.0);
pnt1b.setY(35.0);
PointN pnt2b = new PointN();
pnt2b.setX(15.0);
pnt2b.setY(50.0);
PointN pnt3b = new PointN();
pnt3b.setX(30.0);
pnt3b.setY(50.0);
PointN pnt4b = new PointN();
pnt4b.setX(30.0);
pnt4b.setY(35.0);
PointN pnt5b = new PointN();
pnt5b.setX(15.0);
pnt5b.setY(35.0);
PointN[] pnts1b = new PointN[] { pnt1b, pnt2b, pnt3b, pnt4b, pnt5b };
Ring ring2 = new Ring();
ring2.setPointArray(pnts1b);
//Multipart Polygon (2 overlapping rings)
Ring[] rings = new Ring[] { ring1, ring2 };
PolygonN polygon1 = new PolygonN();
polygon1.setRingArray(rings);
Geometry[] geometryArray = new Geometry[] { polygon1 };
//Overlapping section removed
Geometry[] simplifiedGeometries = geometryService.simplify(inputSpatialReference, geometryArray);
for (Geometry geom : simplifiedGeometries) {
PolygonN polygon = (PolygonN) geom;
EnvelopeN extent = (EnvelopeN) polygon.getExtent();
System.out.println("Extent - XMin,YMin: " + extent.getXMin() + "," + extent.getYMin() + " XMax,YMax: " + extent.getXMax() + "," + extent.getYMax());
}
ImageServer
ExportImage
String serviceURL = "http://localhost:6080/arcgis/services/ImageService/ImageServer";
ImageServerBindingStub imageService = new ImageServerBindingStub(serviceURL);
//Get GeoImageDescription
GeoImageDescription geoImgDesc = new GeoImageDescription();
//Setup extent
ImageServiceInfo serviceInfo = imageService.getServiceInfo();
EnvelopeN extent = (EnvelopeN)serviceInfo.getExtent();
geoImgDesc.setExtent(extent);
geoImgDesc.setHeight(600);
geoImgDesc.setWidth(800);
//Setup imagetype
ImageType imageType = new ImageType();
imageType.setImageFormat(EsriImageFormat.esriImageJPG);
imageType.setImageReturnType(EsriImageReturnType.esriImageReturnURL);
//Export image
ImageResult imageResult = imageService.exportImage(geoImgDesc, imageType);
System.out.println("Image URL: " + imageResult.getImageURL());
GetImage
String serviceURL = "http://localhost:6080/arcgis/services/ImageService/ImageServer";
ImageServerBindingStub imageService = new ImageServerBindingStub(serviceURL);
GeoImageDescription imgDesc = new GeoImageDescription();
int[] bandIds = new int[3];
bandIds[0] = 1;
bandIds[1] = 0;
bandIds[2] = 1;
imgDesc.setBandIDs(bandIds);
imgDesc.setHeight(500);
imgDesc.setWidth(500);
imgDesc.setExtent(imageService.getServiceInfo().getExtent());
byte[] image = imageService.getImage(imgDesc);
System.out.println("Image Byte Array Length: " + image.length);
GetServiceInfo
String serviceURL = "http://localhost:6080/arcgis/services/ImageService/ImageServer";
ImageServerBindingStub imageService = new ImageServerBindingStub(serviceURL);
//Get service info
ImageServiceInfo serviceInfo = imageService.getServiceInfo();
String serviceName = serviceInfo.getName();
System.out.println("Service Name: " + serviceName);
GetVersion
String serviceURL = "http://localhost:6080/arcgis/services/ImageService/ImageServer";
ImageServerBindingStub imageService = new ImageServerBindingStub(serviceURL);
BigDecimal bigD = imageService.getVersion();
System.out.println("Image Service Version: " + bigD);
NAServer
GetNALayerNames
String[] actualReturn = routeServerPort.getNALayerNames(EsriNAServerLayerType.esriNAServerRouteLayer);
GetNetworkDescription
//Test GetNetworkDescription
NAServerNetworkDescription networkDesc = naServerStub.getNetworkDescription(ConfigFileReader.getProperty(ConfigFileReader.NA_INPUT_ROUTE_LAYER_NAME_PROP));
GetSolverParameters
NAServerRouteParams routeParams = (NAServerRouteParams)routeServerPort.getSolverParameters(routeServerPort.getNALayerNames(EsriNAServerLayerType.esriNAServerRouteLayer)[0]);
NAServerClosestFacilityParams cfParams = (NAServerClosestFacilityParams) cfServerPort.getSolverParameters(cfServerPort.getNALayerNames(EsriNAServerLayerType.esriNAServerClosestFacilityLayer)[0]);
Solve
NAServerRouteResults results = (NAServerRouteResults) routeServerPort.solve(routeParams);
2/28/2020