Sha256: e62166f44437ba7ea7eafeb2cc2d1a42d43bd145aadb02b705380d7a50859ddb

Contents?: true

Size: 1.12 KB

Versions: 3

Compression:

Stored size: 1.12 KB

Contents

require File.join File.dirname(__FILE__), 'env.rb'

include CartoJson

describe CartoJson::WKTParser do
  it 'works with point' do
    point = WKTParser.parse "POINT (2 1)"
    point.class.must_equal Point
    point.send(LAT).must_equal 1
    point.send(LNG).must_equal 2
  end
  
  it 'works with polygon' do
    polygon = WKTParser.parse "POLYGON ((2 1, 4 3, 6 5, 2 1))"
    polygon.class.must_equal Polygon
    polygon.points.length.must_equal 3
    polygon.points.first.must_equal Point.new(LAT => 1, LNG => 2)
    polygon.points.last.must_equal Point.new(LAT => 5, LNG => 6)
  end
  
  it 'works with linestring' do
    ls = WKTParser.parse "LINESTRING (2 1, 4 3)"
    ls.class.must_equal LineString
    ls.type.must_equal :linestring
    ls.points.first.must_equal Point.new(LAT => 1, LNG => 2)
    ls.points.last.must_equal Point.new(LAT => 3, LNG => 4)
  end
  
  it 'works with linestring' do
    ls = WKTParser.parse "LINESTRING (2 1, 4 3)"
    ls.class.must_equal LineString
    ls.type.must_equal :linestring
    ls.points.first.must_equal Point.new(LAT => 1, LNG => 2)
    ls.points.last.must_equal Point.new(LAT => 3, LNG => 4)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
carto_json-0.0.9 spec/wkt_parser_spec.rb
carto_json-0.0.8 spec/wkt_parser_spec.rb
carto_json-0.0.7 spec/wkt_parser_spec.rb