Skip to content

Commit a6bd0ff

Browse files
committed
fix sline_sline_pos, add tests for degenerate polygons
1 parent 612f06b commit a6bd0ff

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

Diff for: expected/poly.out

+9
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,15 @@ SELECT spoly '{(0d,0d),(10d,10d),(0d,10d),(10d,0d)}';
328328
ERROR: spherepoly_from_array: a line segment overlaps or polygon too large
329329
LINE 1: SELECT spoly '{(0d,0d),(10d,10d),(0d,10d),(10d,0d)}';
330330
^
331+
--- degenerate polygons -----
332+
SELECT spoly '{(0d,1d),(0d,2d),(0d,3d)}';
333+
ERROR: spherepoly_from_array: a line segment overlaps or polygon too large
334+
LINE 1: SELECT spoly '{(0d,1d),(0d,2d),(0d,3d)}';
335+
^
336+
SELECT spoly '{(1d,0d),(2d,0d),(3d,0d)}';
337+
ERROR: spherepoly_from_array: a line segment overlaps or polygon too large
338+
LINE 1: SELECT spoly '{(1d,0d),(2d,0d),(3d,0d)}';
339+
^
331340
--- functions
332341
SELECT npoints( spoly '{(10d,0d),(10d,1d),(15d,0d)}');
333342
npoints

Diff for: sql/poly.sql

+6
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ SELECT spoly '{(10d,0d),(10d,1d)}';
8686

8787
SELECT spoly '{(0d,0d),(10d,10d),(0d,10d),(10d,0d)}';
8888

89+
--- degenerate polygons -----
90+
91+
SELECT spoly '{(0d,1d),(0d,2d),(0d,3d)}';
92+
93+
SELECT spoly '{(1d,0d),(2d,0d),(3d,0d)}';
94+
8995
--- functions
9096

9197
SELECT npoints( spoly '{(10d,0d),(10d,1d),(15d,0d)}');

Diff for: src/line.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -494,15 +494,6 @@ sline_sline_pos(const SLine *l1, const SLine *l2)
494494
vector3d_spoint(&p[2], &v[1][0]);
495495
vector3d_spoint(&p[3], &v[1][1]);
496496

497-
/* check connected lines */
498-
if (FPgt(il2->length, 0.0) && (vector3d_eq(&v[0][0], &v[1][0]) ||
499-
vector3d_eq(&v[0][0], &v[1][1]) ||
500-
vector3d_eq(&v[0][1], &v[1][0]) ||
501-
vector3d_eq(&v[0][1], &v[1][1])))
502-
{
503-
return PGS_LINE_CONNECT;
504-
}
505-
506497
/* Check, sl2 is at equator */
507498
if (FPzero(p[2].lat) && FPzero(p[3].lat))
508499
{
@@ -527,6 +518,15 @@ sline_sline_pos(const SLine *l1, const SLine *l2)
527518
return PGS_LINE_AVOID;
528519
}
529520

521+
/* check connected lines */
522+
if (FPgt(il2->length, 0.0) && (vector3d_eq(&v[0][0], &v[1][0]) ||
523+
vector3d_eq(&v[0][0], &v[1][1]) ||
524+
vector3d_eq(&v[0][1], &v[1][0]) ||
525+
vector3d_eq(&v[0][1], &v[1][1])))
526+
{
527+
return PGS_LINE_CONNECT;
528+
}
529+
530530
/* Now sl2 is not at equator */
531531

532532
if (FPle(il2->length, seg_length))

0 commit comments

Comments
 (0)