int vertexCount = vertices.size();
//TODO: handle null vertices
Coordinate[] coords = new Coordinate[vertexCount];
for (int i = 0; i < vertexCount; i++) {
Vertex v = vertices.get(i);
Coordinate c = new Coordinate(v.getLng(), v.getLat());
coords[i] = c;
}
// now create a line string from the coordinates array where null = no holes in the polygon
LinearRing ring = new GeometryFactory().createLinearRing(coords);
Geometry geometry = new GeometryFactory().createPolygon(ring, null);
// create a point from the mapCenter vertex
// TODO: mapCenter is null when creating a new study region.
Vertex mapCenterVertex = studyRegion.getMapCenter();
logger.debug("mapCenter=" + studyRegion.getMapCenter());
Coordinate mapCenterCoord = new Coordinate(mapCenterVertex.getLng(), mapCenterVertex.getLat());
Geometry mapCenter = new GeometryFactory().createPoint(mapCenterCoord);
StudyRegion savedStudyRegion = null;
try {