Geospatial types

DSE 5 comes with a set of additional types to represent geospatial data: PointType, LineStringType, and PolygonType:

cqlsh> CREATE TABLE points_of_interest(name text PRIMARY KEY, coords 'PointType');
cqlsh> INSERT INTO points_of_interest (name, coords) VALUES ('Eiffel Tower', 'POINT(2.2945 48.8582)');

The DSE driver includes Java representations of these types, that can be used directly in queries:

import com.datastax.driver.dse.geometry.Point;

Row row = dseSession.execute("SELECT coords FROM points_of_interest WHERE name = 'Eiffel Tower'").one();
Point coords = row.get("coords", Point.class);

dseSession.execute("INSERT INTO points_of_interest (name, coords) VALUES (?, ?)",
        "Washington Monument", new Point(-77.0481073, 38.9006053));

This integration is made possible by custom type codecs. The DSE driver automatically registers a set of geospatial codecs at startup, in the CodecRegistry that was specified for your cluster.

If you’re not going to use geospatial types, you can prevent the codecs from being registered by calling withoutGeospatialCodecs() on the cluster builder (although leaving them does not have any significant impact).