ScyllaDB University Live | Free Virtual Training Event
Learn more
ScyllaDB Documentation Logo Documentation
  • Server
  • Cloud
  • Tools
    • ScyllaDB Manager
    • ScyllaDB Monitoring Stack
    • ScyllaDB Operator
  • Drivers
    • CQL Drivers
    • DynamoDB Drivers
  • Resources
    • ScyllaDB University
    • Community Forum
    • Tutorials
Download
ScyllaDB Docs Scylla C/C++ Driver DSE Features Geospatial types

Geospatial typesΒΆ

DSE 5.0 comes with additional types to represent geospatial data: PointType, LineStringType and PolygonType. These types can be added directly using CQL or the C/C++ DSE driver.

cqlsh> CREATE TABLE IF NOT EXISTS geotypes (key text PRIMARY KEY, point 'PointType', linestring 'LineStringType', polygon 'PolygonType');
cqlsh> INSERT INTO geotypes (key, point) VALUES ('point', 'POINT(42 3.14159)');
cqlsh> INSERT INTO geotypes (key, linestring) VALUES ('linestring', 'LINESTRING(0 0, 1 1)');
cqlsh> INSERT INTO geotypes (key, linestring) VALUES ('polygon', 'POLYGON((0 0, 1 0, 1 1, 0 0))');

These geospatial types can be also be used directly from C/C++ types:

CassStatement* statement =
  cass_statement_new("INSERT INTO examples.geotypes (key, point) VALUES (?, ?)", 2);

cass_statement_bind_string(statement, 0, "point");

/* Bind a point using with the point's components */
cass_statement_bind_dse_point(statement, 1, 42, 3.141459);

/* Execute statement */
CassStatement* statement =
  cass_statement_new("INSERT INTO examples.geotypes (key, linestring) VALUES (?, ?)", 2);

/* Construct the line string */
DseLineString* line_string = dse_line_string_new();

/* Optionally reserve space for the points */
dse_line_string_reserve(line_string, 2);

/* Add points to the line string */
dse_line_string_add_point(line_string, 0, 0);
dse_line_string_add_point(line_string, 1, 1);

/* Tell the line string we are not going to add any more points */
dse_line_string_finish(line_string);

cass_statement_bind_string(statement, 0, "linestring");

/* Bind the line string */
cass_statement_bind_dse_line_string(statement, 1, line_string);

/* Execute statement */
CassStatement* statement =
  cass_statement_new("INSERT INTO examples.geotypes (key, polygon) VALUES (?, ?)", 2);

/* Construct the polygon */
DsePolygon* polygon = dse_polygon_new();

/* A start a new ring */
dse_polygon_start_ring(polygon);

/* Add points to the current ring */
dse_polygon_add_point(polygon, 0, 0);
dse_polygon_add_point(polygon, 1, 0);
dse_polygon_add_point(polygon, 1, 1);
dse_polygon_add_point(polygon, 0, 0);

/* Tell the polygon string we are not going to add any more rings or points */
dse_polygon_finish(polygon);

cass_statement_bind_string(statement, 0, "key");

/* Bind the polygon */
cass_statement_bind_dse_polygon(statement, 1, polygon);

/* Execute statement */

Was this page helpful?

PREVIOUS
Authentication
  • Create an issue
  • Edit this page
Scylla C/C++ Driver
  • master
    • master
  • C/C++ Driver for ScyllaDB
  • API Documentation
    • CassAggregateMeta
    • CassAuthenticator
    • CassAuthenticatorCallbacks
    • CassBatch
    • CassCluster
    • CassCollection
    • CassColumnMeta
    • CassCustomPayload
    • CassDataType
    • CassErrorResult
    • CassExecProfile
    • CassFunctionMeta
    • CassFuture
    • CassIndexMeta
    • CassInet
    • CassIterator
    • CassKeyspaceMeta
    • CassLogMessage
    • CassMaterializedViewMeta
    • CassMetrics
    • CassNode
    • CassPrepared
    • CassResult
    • CassRetryPolicy
    • CassRow
    • CassSchemaMeta
    • CassSession
    • CassSpeculativeExecutionMetrics
    • CassSsl
    • CassStatement
    • CassTableMeta
    • CassTimestampGen
    • CassTuple
    • CassUserType
    • CassUuid
    • CassUuidGen
    • CassValue
    • CassVersion
    • DseDateRange
    • DseDateRangeBound
    • DseLineString
    • DseLineStringIterator
    • DsePolygon
    • DsePolygonIterator
  • Features
    • Basics
      • Batches
      • Binding Parameters
      • Client-side timestamps
      • Consistency
      • Data Types
      • The date and time Types
      • Futures
      • Handling Results
      • Keyspaces
      • Prepared Statements
      • Schema Metadata
      • Tuples
      • User-Defined Types (UDTs)
      • UUIDs
    • Building
    • Client Configuration
    • Cloud
    • Configuration
      • Retry policies
    • Execution Profiles
    • FAQ
    • Installation
    • Logging
    • Metrics
    • Scylla Specific Features
    • Security
      • SSL
    • Testing
      • Cassandra Cluster Manager (CCM)
    • Tracing
  • DSE Features
    • Authentication
    • Geospatial types
Docs Tutorials University Contact Us About Us
© 2025, ScyllaDB. All rights reserved. | Terms of Service | Privacy Policy | ScyllaDB, and ScyllaDB Cloud, are registered trademarks of ScyllaDB, Inc.
Last updated on 28 April 2025.
Powered by Sphinx 7.4.7 & ScyllaDB Theme 1.8.6