So I came across some code that looks like this:
Polygon polygon = Polygon.Builder()
.addVertex(new Point(38.085255f, -122.734590f))
.addVertex(new Point(37.513400f, -122.726350f))
.addVertex(new Point(37.044617f, -122.413239f))
.addVertex(new Point(37.121307f, -121.765046f))
.addVertex(new Point(37.497051f, -121.707368f))
.addVertex(new Point(37.812351f, -121.905122f))
.addVertex(new Point(37.899094f, -121.740327f))
.addVertex(new Point(37.987900f, -121.877656f))
.addVertex(new Point(37.886089f, -122.034211f))
.addVertex(new Point(38.085247f, -122.366548f))
.build();
This simply adds the points with float coordinates to an array and then at the end builds the polygon. Anyway, my question is if there is any easy way where I could loop through this addVertex process without having to change the basic structure of the process?
Basic idea of what I'm trying to do is:
for(int i = 0; i < vertices.length; i++) {
polygon.Builder.addVertex(new Point(vertices[i].getX(), vertices[i].getY());
}
polygon.Builder().build();
I tried to generalize this example as much as possible and hopefully I didn't add any confusion in the process.