Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • T torque-postgresql
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 6
    • Issues 6
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 1
    • Merge requests 1
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Carlos
  • torque-postgresql
  • Wiki
  • Box

Box · Changes

Page history
Created Box (markdown) authored Aug 18, 2019 by Carlos's avatar Carlos
Hide whitespace changes
Inline Side-by-side
Box.md 0 → 100644
View page @ 8b0e7bcf
Box original implementation. Provides an easy interface to manipulate, save and restore, box-like values from the database. Works very similar to the `ActiveRecord::Point`, but for a list of 2 points each one with an `x` and `y` value. [PostgreSQL Docs](https://www.postgresql.org/docs/9.6/datatype-geometric.html#AEN7119)
# How it works
### Migration
Just set the type of the column as `box` when creating a table.
```ruby
create_table "region" do |t|
t.string "title", null: false
t.box "area"
end
```
### Using it
The column is automatically identified and its value turned into what is set on [`geometry.box_class`](https://github.com/crashtech/torque-postgresql/wiki/Configuring#geometry.box_class) or into a `Torque::PostgreSQL::Box`.
This original implementation provides a couple of methods:
```ruby
region = Region.new
region.area.x1
region.area.y1
region.area.x2
region.area.y2
region.area.points # Which will return the 4 points of the box
```
The value can be set in some different manners:
```ruby
region.area = '1,1,10,10'
region.area = '[1,1],[10,10]'
region.area = '((1,1),(10,10))'
region.area = [1,1,10,10]
region.area = [[1,1],[10,10]]
region.area = { x1: 1, y1: 1, x2: 10, y2: 10 }
```
\ No newline at end of file
Clone repository
  • Wiki
  • Configuring

Core Extensions

  • Range

Data types

  • Enum
  • Enum Set
  • Interval
  • Date/Time Range
  • Box
  • Circle
  • Line
  • Segment

Querying

  • Arel
  • Has Many
  • Belongs to Many
  • Dynamic Attributes
  • Distinct On
  • Auxiliary Statements
  • Inherited Tables