Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for a polymorphic data type for enclosed regions #128

Open
esabol opened this issue Jul 17, 2024 · 2 comments
Open

Add support for a polymorphic data type for enclosed regions #128

esabol opened this issue Jul 17, 2024 · 2 comments

Comments

@esabol
Copy link
Contributor

esabol commented Jul 17, 2024

I think PgSphere could use a built-in, performant polymorphic datatype for an enclosed region. Basically, a type that could be either an scircle or an sbox or an spoly or an sellipse. Then define the usual operators that operate on this datatype for checking whether a point or other geometrical type is inside it, etc.

I propose calling this polymorphic datatype "sregion", but I'm open to alternatives.

Rationale: It's becoming more common for astronomical observations to have the fields-of-view (FoVs) of the instrument(s) doing the observing to be well defined as polygons of points in space, but it's still very common for boxes or circles to be used as approximations of FoVs for older observations as well. And IVOA standards (ObsCore) implementing searches on observation databases require lumping together all of these observations from these disparate sources into one giant table for searching. Without such a polymorphic type, you have to do a bunch of UNIONs and/or CASE...WHENs to handle the different types of enclosed regions that might be contained in these database tables. It would be beneficial if PgSphere could alleviate that level of complexity by incorporating support for this.

@obartunov
Copy link

obartunov commented Jul 18, 2024 via email

@esabol
Copy link
Contributor Author

esabol commented Jul 18, 2024

Do you have any idea about implementation ?

We have a rudimentary polymorphic data type that's implemented in SQL, which looks something like the below snippet, but it's not very performant. I think it needs to be implemented at the C level.

        CREATE TYPE sregion AS
        (   
            gtype   int,       -- 0 for null, 1 for scircle, 2 for spoly, etc.
            spec    text,      -- text definition of region
            circle  scircle,   -- circle delegate
            poly    spoly      -- polygon delegate
        );

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

No branches or pull requests

2 participants