Project

to_wkt_

0.0
No commit activity in last 3 years
No release in over 3 years
Painlessly convert arrays to Well-Known Text (WKT) format.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
>= 0
>= 0
 Project Readme

to_wkt_

Quickly and easily convert arrays to Well-Known Text (WKT) format. Which are commonly used in GIS Databases such as PostGIS.

Installation

Add this line to your application's Gemfile:

gem 'to_wkt_'

And then execute:

$ bundle

Or install it yourself as:

$ gem install to_wkt_

Usage

ToWkt automatically exposes the following methods on any instance of Array:

  • #to_wkt_point

    • converts an array to a WKT POINT

    • e.g.

      ```ruby
      [0,0].to_wkt_point # "POINT(0 0)"
      ```
      
  • #to_wkt_line_string

    • converts an array to a WKT LINESTRING

    • e.g.

      ```ruby
      [ [0,0], [1,1], [1,2] ].to_wkt_line_string # "LINESTRING(0 0,1 1,1 2)"
      ```
      
  • #to_wkt_polygon

    • converts an array to a WKT POLYGON

    • e.g.

      ```ruby 
      polygon_array = [ [ [0,0], [4,0], [4,4], [0,4], [0,0] ], [ [1,1], [2,1], [2,2], [1,2], [1,1] ] ]
      polygon_array.to_wkt_polygon # "POLYGON((0 0,4 0,4 4,0 4,0 0),(1 1,2 1,2 2,1 2,1 1))"
      ```
      
  • #to_wkt_multi_point

    • converts an array to a WKT MULTIPOINT

    • e.g.

      ```ruby
      [ [0,0], [1,2] ].to_wkt_multi_point # "MULTIPOINT(0 0,1 2)"
      ```
      
  • #to_wkt_multi_line_string

    • converts an array to a WKT MULTILINESTRING

    • e.g.

      ```ruby
      multi_line_array = [ [ [0,0], [1,1], [1,2] ], [ [2,3], [3,2], [5,4] ] ]
      multi_line_array.to_wkt_multi_line_string # "MULTILINESTRING((0 0,1 1,1 2),(2 3,3 2,5 4))"
      ```
      
  • #to_wkt_multi_polygon

    • converts an array to a WKT MULTIPOLYGON

    • e.g.

      ```ruby
      multi_polygon_array = [ 
        [ [[0,0], [4,0], [4,4], [0,4], [0,0]], [[1,1], [2,1], [2,2], [1,2], [1,1]] ], 
        [ [[-1,-1], [-1,-2], [-2,-2], [-2,-1], [-1,-1]] ] 
      ]
      multi_polygon_array.to_wkt_multi_polygon= "MULTIPOLYGON(((0 0,4 0,4 4,0 4,0 0),(1 1,2 1,2 2,1 2,1 1)),((-1 -1,-1 -2,-2 -2,-2 -1,-1 -1)))" 
      ```
      

Contributing

ToDos

WKT specs contain 18 different geometries; right now only 6 are implemented in to_wkt_.

  • Implemented
    • Point
    • LineString
    • Polygon
    • MultiPoint
    • MultiLineString
    • MultiPolygon
  • Not Implemented
    • Geometry
    • Triangle
    • CircularString
    • Curve
    • MultiCurve
    • CompoundCurve
    • CurvePolygon
    • Surface
    • MultiSurface
    • PolyhedralSurface
    • TIN
    • GeometryCollection

Some of these will be easier to implement than others.

How to Contribute

  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 new Pull Request