OnroerendErfgoed / pgSFTI

simple FuzzyTimeInterval for Postgresql

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can I propose some missing casts ?

Remi-C opened this issue · comments

Hey again @koenedaele,

I settled on this version of simple fuzzy intervals.
For the moment it works very well (except installation which is a little bit broken, no big deal)

However I ended up needing few functions more,
such as basic casts (sfti to record, to array, to float, to numrange ),
as well a a cast to geometry (an easy way to use indexing).

Here is the list of the new functions

Would you be open to a PR ?
Cheers,
Rémi-C

Hi @Remi-C .Thanks for your interest. Yes, we're certainly open to a PR or some other form of collaboration. Only issue I'm not sure about at the moment is introducing a dependency on PostGIS for this extension (although all our databases runs Postgis already, so it might make sense). Currently thinking if the PostGIS functions should be a separate extension. Or I might be able to rewrite some functions to get rid of the PosGIS functions.

I believe a lot of your functions are about reconverting from SFTI to something else. While we mostly had functions to go from something to SFTI?

@Remi-C I've implemented casts from sfti to int and float in the sfti extension itself.

pgsfti=# SELECT fti::float, fti::int, fti::smallint, fti FROM test_sfti LIMIT 5;
  fti   | fti  | fti  |                            fti                             
--------+------+------+------------------------------------------------------------
 2562.5 | 2563 | 2563 | (1772.000000,1782.000000,3343.000000,3353.000000,1.000000)
 2807.5 | 2808 | 2808 | (1892.000000,1902.000000,3713.000000,3723.000000,1.000000)
   1488 | 1488 | 1488 | (256.000000,266.000000,2710.000000,2720.000000,1.000000)
 2346.5 | 2347 | 2347 | (1926.000000,1936.000000,2757.000000,2767.000000,1.000000)
   1937 | 1937 | 1937 | (536.000000,546.000000,3328.000000,3338.000000,1.000000)
(5 rows)

Basically, this determines the middle of the sfti core and returns that as a float or rounds it as an int. Is this sufficient for your use case or did you want something else? I notice you solved this by calculating the centroid of the geom. This might give different results?