Hi guys,Basically what I'm doing is creating a wrapper around the Polygon class to include some extra variables I need for output. I return query results and read them into a list, then created an ENCODE function to generate a specific JSON format I want to use.The problem I'm having is that when I store a Polygon in an object list, if I then go back and write out the coordinates of the Polygon, every Polygon in the list writes the value of the LAST polygon retrieved in the search.So if I run display(feature) it works as expected, if i add to the list and then display later, it takes the LAST polygon's value. What gives? This seems counter-intuitive.
ICursor cursor = fclass.ITable_search(qf, true);
IRow row;
//create a list.
Collection<AgsFeature> features = new LinkedList<AgsFeature>();
//iterate through the query results and add them to the FEATURECOLLECTION.
while ((row = cursor.nextRow()) != null) {
Polygon currentPoly = new Polygon();
currentPoly = (Polygon)row.getValue(9);
switch (currentPoly.getGeometryType()) {
case esriGeometryType.esriGeometryPolygon:
//build the geometry.
AgsGeometry geometry = new AgsGeometry(currentPoly);
//build the feature.
AgsFeature feature = new AgsFeature(String.valueOf(row.getValue(0)),
geometry,
new HashMap<String,Object>());
display(feature);
features.add(feature);
break;
default:
throw new RuntimeException("Not implemented yet.");
}
}