Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jgaskins/postgis
PostGIS extensions for the Crystal Postgres client
https://github.com/jgaskins/postgis
Last synced: 22 days ago
JSON representation
PostGIS extensions for the Crystal Postgres client
- Host: GitHub
- URL: https://github.com/jgaskins/postgis
- Owner: jgaskins
- License: mit
- Created: 2021-04-25T23:36:45.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-06-21T10:46:01.000Z (over 1 year ago)
- Last Synced: 2024-12-09T10:55:44.712Z (25 days ago)
- Language: Crystal
- Size: 4.88 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# postgis
PostGIS data types and encoders/decoders for the Crystal Postgres driver.
## Installation
1. Add the dependency to your `shard.yml`:
```yaml
dependencies:
postgis:
github: jgaskins/postgis
```2. Run `shards install`
## Usage
Ensure that your database has the `postgis` extension enabled:
```sql
CREATE EXTENSION postgis
```Load PostGIS into your application
```crystal
require "postgis"
```If you're writing raw SQL queries, you can specify the type of the result:
```crystal
db.query_one "SELECT 'point(1 2 3)'::geography", as: PostGIS::Point3D
```If you're using `DB::Serializable`, you can use `PostGIS` types for the models:
```crystal
struct Address
include DB::Serializable# ...
getter coordinates : PostGIS::Point2D
end
```Currently supported GIS types:
| GIS Type | Crystal type |
|----------|--------------|
| `POINT` | `PostGIS::Point2D`, `PostGIS::Point3D` |
| `POLYGON` | `PostGIS::Polygon2D` |More will be added in the future.
## Contributing
1. Fork it ()
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request## Contributors
- [Jamie Gaskins](https://github.com/jgaskins) - creator and maintainer