Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/twpayne/pgx-geos
Package pgx-geos provides PostGIS and GEOS support for github.com/jackc/pgx/v5 via github.com/twpayne/go-geos.
https://github.com/twpayne/pgx-geos
geospatial gis go golang postgis postgres postgresql wkb wkt
Last synced: 12 days ago
JSON representation
Package pgx-geos provides PostGIS and GEOS support for github.com/jackc/pgx/v5 via github.com/twpayne/go-geos.
- Host: GitHub
- URL: https://github.com/twpayne/pgx-geos
- Owner: twpayne
- License: mit
- Created: 2024-02-03T00:24:21.000Z (9 months ago)
- Default Branch: master
- Last Pushed: 2024-09-18T00:11:19.000Z (about 2 months ago)
- Last Synced: 2024-10-14T21:07:20.160Z (25 days ago)
- Topics: geospatial, gis, go, golang, postgis, postgres, postgresql, wkb, wkt
- Language: Go
- Homepage:
- Size: 77.1 KB
- Stars: 25
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pgx-geos
[![PkgGoDev](https://pkg.go.dev/badge/github.com/twpayne/pgx-geos)](https://pkg.go.dev/github.com/twpayne/pgx-geos)
Package pgx-geos provides [PostGIS](https://postgis.net/) and
[GEOS](https://libgeos.org/) support for
[`github.com/jackc/pgx/v5`](https://pkg.go.dev/github.com/jackc/pgx/v5) via
[`github.com/twpayne/go-geos`](https://pkg.go.dev/github.com/twpayne/go-geos).## Usage
### Single connection
```go
import (
// ..."github.com/jackc/pgx/v5"
"github.com/twpayne/go-geos"
pgxgeos "github.com/twpayne/pgx-geos"
)// ...
connectionStr := os.Getenv("DATABASE_URL")
conn, err := pgx.Connect(context.Background(), connectionStr)
if err != nil {
return err
}
if err := pgxgeos.Register(ctx, conn, geos.NewContext()); err != nil {
return err
}
```### Connection pool
```go
import (
// ..."github.com/jackc/pgx/v5/pgxpool"
)// ...
config, err := pgxpool.ParseConfig(connectionStr)
if err != nil {
return err
}
config.AfterConnect = func(ctx context.Context, conn *pgx.Conn) error {
if err := pgxgeos.Register(ctx, conn, geos.NewContext()); err != nil {
return err
}
return nil
}pool, err := pgxpool.NewWithConfig(context.Background(), config)
if err != nil {
return err
}
```## License
MIT