Friday, August 24, 2007

How to buffer features in ArcServer using Java

Creating a map image of buffered features takes a lot of code!

This sample steps you through it all and works with the cities and places shapefiles located with ESRI sample data. One thing you'll need to do is create a BufferSample.mxd with cities as the first layer in the TOC, places as the second layer in the TOC. Set-up the map service in ArcGIS Server and plug in your host, username/password values and you should be good to go!

A key method to look in the code is createBufferGeometry:
/**
* Create the buffer geometry
* @param layerId the layer position in the MXD table of contents
* @param feaure ids of selected features to buffer
* @param distance to buffer features in decimal degrees
* @return the buffer geometry
* @throws Exception when buffer geometry fails
*/
public IGeometry createBufferGeometry(int layerID, IFIDSet2 fidSet2, double distance) throws Exception {
// lots of code here!
return buffersGeometry; }

and the full sample is located at geovelocity's website: http://www.geovelocity.com/downloads/BufferSample.zip

No comments: