Skip to content

Add traversedArea function for temporal circular buffers#666

Merged
mschoema merged 1 commit intoMobilityDB:masterfrom
estebanzimanyi:trav_area
Apr 16, 2025
Merged

Add traversedArea function for temporal circular buffers#666
mschoema merged 1 commit intoMobilityDB:masterfrom
estebanzimanyi:trav_area

Conversation

@estebanzimanyi
Copy link
Copy Markdown
Member

No description provided.

@estebanzimanyi estebanzimanyi requested a review from mschoema April 14, 2025 17:08
@mschoema
Copy link
Copy Markdown
Member

One major question I have concerns the way we construct the resulting geometry.
Currently, We construct either a single circle or a trapezoid bounded by 2 circular strings (curvepolygon) for each segment. Then, we accumulate all of these circles and curvepolygons into a collection. Conceptually, we apply ST_Collect on the traversed area of each segment. Another option is to apply ST_Union instead, which would merge all these geometries into a single curvepoly geometry. In theory this would be better, but it would be slower and I also don't know if ST_Union can already handle curvepolygons correctly or not. What are your thoughts on this, should we keep it as such or try out the union approach?

@estebanzimanyi
Copy link
Copy Markdown
Member Author

The problem with performing the union of the circles or trapezoids obtained from each segment is that PostGIS polygonizes the circles. For example

select ST_AsText(traversedArea(tcbuffer '{Cbuffer(Point(1 1),1)@2000-01-01, Cbuffer(Point(3 2),2)@2000-01-02}'));
-- GEOMETRYCOLLECTION(CURVEPOLYGON(CIRCULARSTRING(0 1,2 1,0 1)),CURVEPOLYGON(CIRCULARSTRING(1 2,5 2,1 2)))

while

test=# select ST_AsText(ST_UnaryUnion(
  traversedArea(tcbuffer '{Cbuffer(Point(1 1),1)@2000-01-01, Cbuffer(Point(2 1),1)@2000-01-02}')));
-- POLYGON((1.471396736825998 0.118078735651645,1.427555093430282 0.096010706876557,1.38268343236509 0.076120467488713,1.3
3688985339222 0.058455934816979,1.290284677254462 0.043059664267791,1.242980179903264 0.029968746805456,1.19509032201612
8 0.01921471959677,1.146730474455361 0.010823490035219,1.09801714032956 0.004815273327803,1.049067674327418 0.0012045437
94828,1 0,0.950932325672582 0.001204543794828,0.90198285967044 0.004815273327803,0.853269525544638 0.010823490035219,0.8
04909677983871 0.01921471959677,0.757019820096736 0.029968746805456,0.709715322745538 0.043059664267791,0.66311014660778
 0.058455934816979,0.61731656763491 0.076120467488713,0.572444906569718 0.096010706876557,0.528603263174002 0.1180787356
51645,0.485897255806778 0.142271389999728,0.444429766980398 0.168530387697455,0.404300695507567 0.196792468519355,0.3656
06715836354 0.226989546637263,0.328441045152981 0.259048874645041,0.292893218813452 0.292893218813453,0.259048874645041
0.328441045152982,0.226989546637263 0.365606715836355,0.196792468519355 0.404300695507567,0.168530387697455 0.4444297669
80398,0.142271389999728 0.485897255806778,0.118078735651645 0.528603263174002,0.096010706876557 0.572444906569718,0.0761
20467488713 0.61731656763491,0.058455934816979 0.66311014660778,0.043059664267791 0.709715322745538,0.029968746805456 0.
757019820096736,0.01921471959677 0.804909677983872,0.010823490035219 0.853269525544638,0.004815273327803 0.9019828596704
4,0.001204543794828 0.950932325672582,0 1,0.004815273327803 1.098017140329561,0.010823490035219 1.146730474455364,0.0192
14719596769 1.195090322016128,0.029968746805456 1.242980179903265,0.043059664267791 1.290284677254462,0.05845593481698 1
.336889853392221,0.076120467488714 1.38268343236509,0.096010706876557 1.427555093430282,0.118078735651645 1.471396736825
998,0.142271389999728 1.514102744193222,0.168530387697455 1.555570233019602,0.196792468519355 1.595699304492433,0.226989
546637264 1.634393284163647,0.259048874645041 1.671558954847018,0.292893218813453 1.707106781186548,0.328441045152981 1.
740951125354959,0.365606715836355 1.773010453362738,0.404300695507567 1.803207531480645,0.444429766980398 1.831469612302
546,0.485897255806779 1.857728610000272,0.528603263174002 1.881921264348355,0.572444906569718 1.903989293123443,0.617316
56763491 1.923879532511287,0.663110146607781 1.941544065183021,0.709715322745537 1.956940335732209,0.757019820096737 1.9
70031253194544,0.804909677983871 1.98078528040323,0.853269525544639 1.989176509964781,0.90198285967044 1.995184726672197
,0.950932325672582 1.998795456205172,1 2,1.049067674327418 1.998795456205172,1.098017140329561 1.995184726672197,1.14673
0474455362 1.989176509964781,1.195090322016129 1.98078528040323,1.242980179903264 1.970031253194544,1.290284677254462 1.
956940335732209,1.33688985339222 1.941544065183021,1.38268343236509 1.923879532511286,1.427555093430282 1.90398929312344
3,1.471396736825998 1.881921264348355,1.5 1.865717715905028,1.528603263174002 1.881921264348355,1.572444906569718 1.9039
89293123443,1.61731656763491 1.923879532511287,1.663110146607781 1.941544065183021,1.709715322745537 1.956940335732209,1
.757019820096737 1.970031253194544,1.804909677983871 1.98078528040323,1.853269525544639 1.989176509964781,1.901982859670
44 1.995184726672197,1.950932325672583 1.998795456205172,2 2,2.049067674327418 1.998795456205172,2.09801714032956 1.9951
84726672197,2.146730474455362 1.989176509964781,2.195090322016129 1.98078528040323,2.242980179903264 1.970031253194544,2
.290284677254462 1.956940335732209,2.33688985339222 1.941544065183021,2.38268343236509 1.923879532511286,2.4275550934302
82 1.903989293123443,2.471396736825998 1.881921264348355,2.514102744193222 1.857728610000272,2.555570233019602 1.8314696
12302545,2.595699304492433 1.803207531480645,2.634393284163646 1.773010453362736,2.671558954847019 1.740951125354959,2.7
07106781186548 1.707106781186548,2.740951125354959 1.671558954847018,2.773010453362737 1.634393284163645,2.8032075314806
45 1.595699304492433,2.831469612302545 1.555570233019602,2.857728610000272 1.514102744193222,2.881921264348355 1.4713967
36825998,2.903989293123443 1.427555093430282,2.923879532511287 1.38268343236509,2.941544065183021 1.33688985339222,2.956
940335732209 1.290284677254462,2.970031253194544 1.242980179903264,2.98078528040323 1.195090322016128,2.989176509964781
1.146730474455361,2.995184726672197 1.09801714032956,2.998795456205173 1.049067674327418,3 1,2.998795456205173 0.9509323
25672582,2.995184726672197 0.90198285967044,2.989176509964781 0.853269525544638,2.98078528040323 0.804909677983871,2.970
031253194544 0.757019820096736,2.956940335732209 0.709715322745538,2.94154406518302 0.663110146607779,2.923879532511286
0.61731656763491,2.903989293123443 0.572444906569718,2.881921264348355 0.528603263174002,2.857728610000272 0.48589725580
6778,2.831469612302545 0.444429766980398,2.803207531480645 0.404300695507567,2.773010453362737 0.365606715836355,2.74095
1125354959 0.328441045152981,2.707106781186548 0.292893218813452,2.671558954847018 0.259048874645041,2.634393284163645 0
.226989546637263,2.595699304492433 0.196792468519355,2.555570233019602 0.168530387697455,2.514102744193222 0.14227138999
9728,2.471396736825998 0.118078735651645,2.427555093430282 0.096010706876557,2.38268343236509 0.076120467488713,2.336889
85339222 0.058455934816979,2.290284677254462 0.043059664267791,2.242980179903264 0.029968746805456,2.195090322016128 0.0
1921471959677,2.146730474455361 0.010823490035219,2.09801714032956 0.004815273327803,2.049067674327418 0.001204543794828
,2 0,1.950932325672582 0.001204543794828,1.90198285967044 0.004815273327803,1.853269525544638 0.010823490035219,1.804909
677983871 0.01921471959677,1.757019820096736 0.029968746805456,1.709715322745538 0.043059664267791,1.66311014660778 0.05
8455934816979,1.61731656763491 0.076120467488713,1.572444906569718 0.096010706876557,1.528603263174002 0.118078735651645
,1.5 0.134282284094972,1.471396736825998 0.118078735651645))

Therefore, I would keep things like this until circles are managed as circles in PostGIS.

@mschoema mschoema merged commit f252148 into MobilityDB:master Apr 16, 2025
10 of 16 checks passed
@mschoema mschoema deleted the trav_area branch April 16, 2025 09:11
estebanzimanyi added a commit to estebanzimanyi/MobilityDB that referenced this pull request Apr 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants