Geometric Types
Geometric data types are used to represent two-dimensional shapes like points, lines, and polygons.
The availability of these types depends on the specific database and engine being used. Because of this, TDK has only limited support for them.
If you need to mask or generate data for these types, we recommend using text-based transformers
like formatted_string_generator
.
The examples below show how to set up TDK for different geometric types.
MySQL Spatial Data Types
MySQL implements spatial extensions as a subset of the SQL with Geometry Types environment.
POINT
A Point is a geometric shape that represents a single location using coordinates. In text form, it looks like this: POINT(12.34 56.78)
.
To use a text-based generator for points, we need to set up the following regular expression:
POINT\\(([1-8]{1,2}(\\.[0-9]{1,5})?) ([1-8]{1,2}(\\.[0-9]{1,5})?)\\)
The example below shows how to configure the transformer for this case.
transformations:
- columns: [ "point_column" ]
params:
type: formatted_string_generator
pattern: "POINT\\(([1-8]{1,2}(\\.[0-9]{1,5})?) ([1-8]{1,2}(\\.[0-9]{1,5})?)\\)"
LINESTRING
A LineString is a Curve with linear interpolation between points. The line needs to have at least two points.
In text form, it looks like this: LINESTRING(25 2.58, 1.9821 15.3952, 7 6.409, 13 26.81482)
.
To use a text-based generator for linestring, we need to set up the following regular expression:
LINESTRING\((([1-8]{1,2}(\\.[0-9]{1,5})?) ([1-8]{1,2}(\\.[0-9]{1,5})?))(, [1-8]{1,2}(\\.[0-9]{1,5})?) ([1-8]{1,2}(\\.[0-9]{1,5})?){1,6}\\)
The example below shows how to configure the transformer for this case.
transformations:
- columns: [ "linestring_column" ]
params:
type: formatted_string_generator
pattern: "LINESTRING\\((([1-8]{1,2}(\\.[0-9]{1,5})?) ([1-8]{1,2}(\\.[0-9]{1,5})?))(, (([1-8]{1,2}(\\.[0-9]{1,5})?) ([1-8]{1,2}(\\.[0-9]{1,5})?))){1,6}\\)"
POLYGON
A Polygon is a planar Surface representing a multisided geometry. It is defined by a single exterior boundary and zero or more interior boundaries, where each interior boundary defines a hole in the Polygon.
In text form, it looks like this: POLYGON0 0, 2.635 87.4045, 43.889 33, 83 68, 0 0
.
Polygon Rules:
-
A polygon’s boundary is made of closed, simple lines (LinearRings).
-
Rings cannot cross but may touch at a single point.
-
No lines, spikes, or gaps allowed.
-
The interior must be a single connected area.
-
Polygons can have holes, but the outer area won’t be fully connected.
To use a text-based generator for polygon, we need to set up the following regular expression:
POLYGON\\(\\(0 0(, [1-8]{1,2}(\\.[0-9]{1,5})?) ([1-8]{1,2}(\\.[0-9]{1,5})?){2,6}, 0 0\\)\\)
transformations:
- columns: [ "polygon_column" ]
params:
type: formatted_string_generator
pattern: "POLYGON\\(\\(0 0(, (([1-8]{1,2}(\\.[0-9]{1,5})?) ([1-8]{1,2}(\\.[0-9]{1,5})?))){2,6}, 0 0\\)\\)"
GEOMETRY
The Geometry is the main class for all shapes. You can store any shape type (Point, LineString, Polygon) in a GEOMETRY column. For example:
transformations:
- columns: [ "geometry_column" ]
params:
type: formatted_string_generator
pattern: "POINT\\(([1-8]{1,2}(\\.[0-9]{1,5})?) ([1-8]{1,2}(\\.[0-9]{1,5})?)\\)"
PostgreSQL Spatial Data Types
In PostgreSQL, geometric types are used to store and work with two-dimensional shapes like points, lines, polygons, circles, and boxes.
POINT
In PostgreSQL, a Point is written as (12.23, 53.23)
. This follows the pattern:
\\(([1-8]{1,2}(\\.[0-9]{1,5})?),([1-8]{1,2}(\\.[0-9]{1,5})?)\\)
.
The example below shows how to configure the transformer for this case.
transformations:
- columns: [ "point_column" ]
params:
type: formatted_string_generator
pattern: "\\(([1-8]{1,2}(\\.[0-9]{1,5})?),([1-8]{1,2}(\\.[0-9]{1,5})?)\\)"