In the code below, I am trying to access the 'singleBuilding' variable inside the 'GMLWalker' visit function. I am getting the error "Cannot refer to the non-final local variable singleBuilding defined in an enclosing scope". Any clues on how I can achieve this.
private FeatureWalker IterateGroundSurface(BuildingClass singleBuilding){
FeatureWalker groundWalker = new FeatureWalker(){
public void visit(GroundSurface groundSurface){
GMLWalker gmlWalker = new GMLWalker(){
public void visit(LinearRing linearRing){
if(linearRing.isSetPosList()){
SurfaceMember surfaceMember = new SurfaceMember();
DirectPositionList posList = linearRing.getPosList();
List<Double> points = posList.toList3d();
List<CoordinateClass> polygonfloor = new ArrayList<CoordinateClass>();
PolygonClass poly = new PolygonClass();
for(int i=0 ; i<points.size() ;i+=3){
double[] vals = new double[]{points.get(i) , points.get(i+1),points.get(i+2)};
//System.out.println(vals[0]+" "+vals[1]+" "+vals[2]);
CoordinateClass coord = new CoordinateClass(vals);
polygonfloor.add(coord);
}
poly.setPolygon(polygonfloor);
surfaceMember.setPolygon(poly);
singleBuilding.setSurfacePolygon(surfaceMember);
//surfacePolygons.add(buildingSurfacePolygon);
}
}
};
groundSurface.accept(gmlWalker);
}
};
return groundWalker;
}
Thanks,