Frequently asked question

How can a complete geometry of a selected feature be returned in a FeatureLayer using Java Connector?

Last Published: April 25, 2020


The article in the Related Information section below describes how to retrieve the coordinate list for a feature using the class.

However, while using the class mentioned above, it is not possible to determine different Paths that make a PolyLine feature, or Rings and Holes that make a Polygon feature.

To get complete geometric information of an individual part of a feature, use the class.

It is necessary to pass an ArcXML response in the String format as an argument to this class. The example code given below illustrates how to get an ArcXML response in String format and pass it to the GeometryRecordset class to get the complete geometry information of a feature.

Example Code (for World service from ArcIMS tutorial data)
<%@ page import="*,,*,com.esri.aims.mtier.model.acetate.Point,
com.esri.aims.mtier.model.acetate.Hole,com.esri.aims.mtier.model.acetate.Ring" %>

<jsp:useBean id="connection" class="" scope="page" />
<jsp:useBean id="map" class="" scope="page" />
<BODY bgcolor="#ffffff"><p align="left">

//define server parameters
String hostName = "localhost"; //replace with app. server host name
int port = 5300; //replace with app. server port number
String serviceName = "world"; //replace with image service name

//define where expression
String whereExpression = "CNTRY_NAME='South Africa'"; //replace with where expression for filter

//define layer index
int index = 1; //replace with layer index

//set connection parameters

//initialize map
map.initMap(connection, 0, true, true, true, true);

//get feature layer and setGeometry=true
FeatureLayer fLayer = (FeatureLayer)map.getLayers().item(index);

//create and apply filter to layer filter = new;

GeometryRecordset geometry = new GeometryRecordset();

//get current ArcXML request prepared by Map object
String arcxmlReq = map.getArcXML();

//send String axl request and get back String response
String arcXMLResponse = map.sendArcXML(arcxmlReq,map.GET_FEATURE);

// Stores all the Geometry Result after parsing
java.util.Vector vectorGeometry = new java.util.Vector();
vectorGeometry = geometry.getGeometry(null,null,arcXMLResponse);

//print out geometry of each parts
for (int i=0;i<vectorGeometry.size();i++){
// Iterate through only Polygon Object
if (vectorGeometry.get(i) instanceof Polygon){
Polygon polygon = (Polygon) vectorGeometry.get(i);
out.println("Polygon - Ring Count : " + polygon.getRingsCount());
// Iterate through only Ring Object
Ring ring = null;
for (int j=0;j<polygon.getRingsCount();j++){
ring = polygon.getRing(j);
for (int k=0;k<ring.getHolesCount();k++){
Hole hole = ring.getHole(k);
Points pts = hole.getPoints();
for (int l=0;l<pts.getCount();l++){
Point tPoint = pts.getPointObject(l);
out.println("Hole: X = "+ tPoint.getX() + ",Y="+ tPoint.getY());
Points ringPoints = ring.getPoints();
for (int k=0;k<ringPoints.getCount();k++){
Point tempPoint = ringPoints.getPointObject(k);
out.println("Ring " + (j+1) + " : X = "+ tempPoint.getX() + ",Y="+ tempPoint.getY());
out.println ("******************************");



Article ID:000006506

  • Legacy Products

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Related Information

Discover more on this topic