Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/michelp/pgs2
Postgres extension for S2 spherical geometry
https://github.com/michelp/pgs2
postgresql s2 spherical-coordinates
Last synced: 2 months ago
JSON representation
Postgres extension for S2 spherical geometry
- Host: GitHub
- URL: https://github.com/michelp/pgs2
- Owner: michelp
- License: apache-2.0
- Created: 2021-11-05T15:15:39.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2021-11-24T08:04:00.000Z (about 3 years ago)
- Last Synced: 2024-04-21T06:58:01.903Z (9 months ago)
- Topics: postgresql, s2, spherical-coordinates
- Language: C
- Homepage:
- Size: 78.1 KB
- Stars: 17
- Watchers: 5
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pgs2
Postgres extension for [S2 spherical geometry](https://s2geometry.io/).
## Fixed Length Types
These fixed length types are stored "flat" and only turned into S2
instances at the point of use. They are stored very efficiently by
Postgres.### S2Point
Stored as 3 double precision floats.
### S2Cap
Point and radius stored as 4 doubles.
### S2LatLng
Stored as 2 doubles.
### S2LatLngRect
Stored as 4 doubles.
### S2Cell
An S2CellId is an unsigned 64bit integer, but since Postgres doesn't
have unsigned integer types, it's SQL literal representation is an
S2Cell "token" string. The token is decoded into an unsigned int64
and stored optimally.Cells can be cast to S2Point and S2LatLng by returning their center
point. S2Point and S2LatLng can be cast to a cell. Normally there is
exactly one such cell for a given point, but for points along cell
boundaries one cell id detiministically chosen:```
```
## TODO Variable Length S2Region Types
These types are variable length "expanded" types, they are stored in a
flattened representation using S2 Encoder/Decoder and automatically
expanded into live objects as needed when loaded into memory.### S2Polyline
### S2Loop
### S2Polygon
## TODO Aggregate S2Builder
S2Builder is wrapped by an aggregate, any region can be added to the
builder.`select s2builder(region, layer_name) as from ... where ...;`
s2builder supports all current geometry types.
## TODO Indexing
### S2Cell Token btree with text_pattern_ops
### S2CellId QuadTree with SP-GIST TODO
### S2RegionTermIndexer using GIN TODO