Skip to content

Commit

Permalink
Merge pull request #53 from estebanzimanyi/develop
Browse files Browse the repository at this point in the history
Optimize atGeometry function
  • Loading branch information
mahmsakr committed Feb 22, 2021
2 parents c22da61 + 74c22b6 commit 2f49504
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
11 changes: 3 additions & 8 deletions point/src/tpoint_spatialfuncs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2760,14 +2760,9 @@ tgeompointseq_find_intersections(const TSequence *seq, int *count)
double2_set(&result[k++], i, i - 1);
else
double2_set(&result[k++], i - 1, i - 2);
if (k % seq->count == 0)
{
/* Expand array of the result */
double2 *tempresult = palloc0(sizeof(double2) * (k + seq->count));
memcpy(tempresult, result, sizeof(double2) * k);
pfree(result);
result = tempresult;
}
/* We are sure that the number of stationary segments will always be
* less than the size of the result array (that is, seq->count) and thus
* we do need to test whether the result array should be expanded */
}
else
double3_set(&xranges[l++], Min(points[i-1].x, points[i].x),
Expand Down
18 changes: 18 additions & 0 deletions point/test/expected/56_tpoint_spatialfuncs.test.out
Original file line number Diff line number Diff line change
Expand Up @@ -1369,6 +1369,24 @@ SELECT isSimple(tgeompoint 'Interp=Stepwise;[Point(0 0)@2000-01-01, Point(1 1)@2
t
(1 row)

SELECT isSimple(tgeompoint '[Point(0 0)@2000-01-01, Point(0 0)@2000-01-02, Point(1 1)@2000-01-03]');
issimple
----------
f
(1 row)

SELECT isSimple(tgeompoint '[Point(0 0)@2000-01-01, Point(1 1)@2000-01-02, Point(1 1)@2000-01-03]');
issimple
----------
f
(1 row)

SELECT isSimple(tgeompoint '[Point(0 0)@2000-01-01, Point(0 0)@2000-01-02, Point(1 1)@2000-01-03, Point(1 1)@2000-01-04]');
issimple
----------
f
(1 row)

SELECT isSimple(tgeompoint '{Point(0 0 0)@2000-01-01}');
issimple
----------
Expand Down
3 changes: 3 additions & 0 deletions point/test/queries/56_tpoint_spatialfuncs.test.sql
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,9 @@ SELECT isSimple(tgeompoint '{Point(0 0)@2000-01-01, Point(1 1)@2000-01-02}');
SELECT isSimple(tgeompoint '{Point(0 0)@2000-01-01, Point(0 0)@2000-01-02}');
SELECT isSimple(tgeompoint 'Interp=Stepwise;[Point(0 0)@2000-01-01, Point(1 1)@2000-01-02, Point(1 1)@2000-01-03]');
SELECT isSimple(tgeompoint 'Interp=Stepwise;[Point(0 0)@2000-01-01, Point(1 1)@2000-01-02, Point(2 0)@2000-01-03]');
SELECT isSimple(tgeompoint '[Point(0 0)@2000-01-01, Point(0 0)@2000-01-02, Point(1 1)@2000-01-03]');
SELECT isSimple(tgeompoint '[Point(0 0)@2000-01-01, Point(1 1)@2000-01-02, Point(1 1)@2000-01-03]');
SELECT isSimple(tgeompoint '[Point(0 0)@2000-01-01, Point(0 0)@2000-01-02, Point(1 1)@2000-01-03, Point(1 1)@2000-01-04]');

SELECT isSimple(tgeompoint '{Point(0 0 0)@2000-01-01}');
SELECT isSimple(tgeompoint '{Point(0 0 0)@2000-01-01, Point(1 1 1)@2000-01-02}');
Expand Down

0 comments on commit 2f49504

Please sign in to comment.