public String toJson() {
XContentBuilder builder = null;
try {
builder = jsonBuilder();
builder.startObject();
ESLocation centroid = shape.getCentroid();
builder.field("centroid", new double[] { centroid.getLongitude(), centroid.getLatitude() });
builder.field("lengthKm", shape.getLengthKm());
builder.field("areaKm2", shape.getAreaKm2());
builder.startObject("shape");
builder.field("type", shape.isClosed() ? "polygon" : "linestring");
builder.startArray("coordinates");