Skip to content

Commit

Permalink
A Line is actually a LineString, which accepts two or more Points (#268)
Browse files Browse the repository at this point in the history
  • Loading branch information
kearfy authored May 16, 2024
1 parent 4a06840 commit 591df7b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/library/cbor/geometry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@ export class GeometryPoint extends Geometry {
}

export class GeometryLine extends Geometry {
readonly line: [GeometryPoint, GeometryPoint];
readonly line: [GeometryPoint, GeometryPoint, ...GeometryPoint[]];

constructor(line: [GeometryPoint, GeometryPoint] | GeometryLine) {
// SurrealDB only has the context of a "Line", which is two points.
// SurrealDB's "Line" is actually a "LineString" under the hood, which accepts two or more points
constructor(
line: [GeometryPoint, GeometryPoint, ...GeometryPoint[]] | GeometryLine,
) {
super();
line = line instanceof GeometryLine ? line.line : line;
this.line = [new GeometryPoint(line[0]), new GeometryPoint(line[1])];
Expand Down

0 comments on commit 591df7b

Please sign in to comment.