I'm trying to insert geometry objects into my supabase postgres table.
I have the following geometry columns:
| Column name | Data type |
|---|---|
| point | POINT |
| line_string | LINESTRING |
| polygon | POLYGON |
I have tried multiple ways to insert POINT objects (I haven't gotten to the linestrings or polygons, seeing that they are more complicated).
const geometry = { x: -123, y: -123 }
const point = `(${geometry.x}, ${geometry.y})`; // Try number 1
const point = `point(${geometry.x},${geometry.y})`; // Try number 2
const point = `ST_SetSRID(ST_MakePoint(${geometry.y}, ${geometry.x}), 4326)`; // Try number 3
const { data, error } = await supabase.from('geometries').upsert({ point });
All three gave the same error:
{
message: 'parse error - invalid geometry',
code: 'XX000',
details: null,
hint: '"(0" <-- parse error at position 2 within geometry'
}
{
message: 'parse error - invalid geometry',
code: 'XX000',
details: null,
hint: '"point(0, 0" <-- parse error at position 10 within geometry'
}
{
message: 'parse error - invalid geometry',
code: 'XX000',
details: null,
hint: '"ST" <-- parse error at position 2 within geometry'
}
How do I insert/upsert point objects? Linestrings? Polygons?