elasticsearch/elasticsearch — pull request #3149 by chilling (2013-06-07 08:02:04+00:00)
Title: Geo-Refactoring

The code handling geo-shapes is not centralized and creating points takes place at different places. Also the collection of
supported geo_shapes is not complete regarding to the GEOJSon specification.

## Null-Shapes
The latest implementation of geo-shapes allows to index *null-shapes*. This means a field that is defined to hold a geo-shape
can be set to `null`.

## New Shape
The geo-shapes *multipoint* and *multilinestring* have been added to the *geo_shape* types. Also *geo_circle* is introduced
by this branch.

## Dateline wrapping
A major issue of geo-shapes is the spherical geometry. Since ElasticSearch works on the *Geo-Coordinates* by wrapping the
Earths surface to a plane, some shapes are hard to define if it's crossing the *+180°*, *-180* longitude. To solve this
issue ElasticSearch offers the possibility to define geo-shapes crossing this borders and decompose these shapes and
automatically re-compose them in a spherical manner.

This feature may change the defined shape-type: If for example an *polygon* is defined, that crosses the dateline, it
will be re-assembled to a set of polygons. This causes ElasticSearch to index a *multipolygon*. Also *linestrings* might
by re-assembled to *multilinestrings*.

## Builders
The API has been refactored, so parsing geo-shapes will result in a builder. These builders can be parsed
and serialized without generating any shapes. So the shape generation will be done only on the nodes executing
the actual operation.
Also the baseclass `GeoShapeBuilder` implements the `ToXContent` interface which allows to set fields of `XContent`
directly.

## TODO's
- calling the `build()`-method changes the longitude/latitude values. So it only works once.
- The *geo-circle* will not work, if it's crossing the dateline
- The *envelope* also need to wrapped
- Shapes only need to be checked for wrapping once