Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 4 commits
  • 27 files changed
  • 0 comments
  • 2 contributors
Oct 30, 2012
Tim Dettrick tjdett Combining not-running georss.rb tests with georss_spec.rb 1c91089
Tim Dettrick tjdett Fixing KML tests. e1501e5
Tim Dettrick tjdett Scoping class use in specs.
The use of "include GeoRuby; include GeoRuby::SimpleFeatures" was
masking "include" issues in the GeoJSON and GeoRSS implementations.

By using those includes in global scope inside `spec_helper.rb`, they
altered the behaviour under `lib/`.

Sadly, simply using an include in the specs wasn't an option either, due
to changes in Ruby 1.9.3:

rspec/rspec-core#506
71b9d6c
Marcos Piccinini Merge pull request #20 from tjdett/test-fixes
Fixing GeoRSS namespace scoping and scoping use in specs
7b989f3

Showing 27 changed files with 663 additions and 678 deletions. Show diff stats Hide diff stats

  1. +1 15 lib/geo_ruby.rb
  2. +2 0  lib/geo_ruby/geojson.rb
  3. +1 0  lib/geo_ruby/georss.rb
  4. +1 1  lib/geo_ruby/kml.rb
  5. +25 0 lib/geo_ruby/simple_features.rb
  6. +26 26 spec/geo_ruby/geojson_spec.rb
  7. +0 218 spec/geo_ruby/georss.rb
  8. +215 3 spec/geo_ruby/georss_spec.rb
  9. +19 22 spec/geo_ruby/gpx4r/gpx_spec.rb
  10. +6 6 spec/geo_ruby/kml_spec.rb
  11. +36 38 spec/geo_ruby/shp4r/shp_spec.rb
  12. +3 5 spec/geo_ruby/simple_features/circle_spec.rb
  13. +8 8 spec/geo_ruby/simple_features/envelope_spec.rb
  14. +45 45 spec/geo_ruby/simple_features/ewkb_parser_spec.rb
  15. +49 49 spec/geo_ruby/simple_features/ewkt_parser_spec.rb
  16. +20 20 spec/geo_ruby/simple_features/geometry_collection_spec.rb
  17. +2 2 spec/geo_ruby/simple_features/geometry_factory_spec.rb
  18. +9 12 spec/geo_ruby/simple_features/geometry_spec.rb
  19. +53 53 spec/geo_ruby/simple_features/line_string_spec.rb
  20. +6 6 spec/geo_ruby/simple_features/linear_ring_spec.rb
  21. +13 13 spec/geo_ruby/simple_features/multi_line_string_spec.rb
  22. +10 10 spec/geo_ruby/simple_features/multi_point_spec.rb
  23. +13 13 spec/geo_ruby/simple_features/multi_polygon_spec.rb
  24. +52 52 spec/geo_ruby/simple_features/point_spec.rb
  25. +40 40 spec/geo_ruby/simple_features/polygon_spec.rb
  26. +7 12 spec/geo_ruby_spec.rb
  27. +1 9 spec/spec_helper.rb
16 lib/geo_ruby.rb
... ... @@ -1,21 +1,7 @@
1 1 # $:.unshift(File.dirname(__FILE__)) #unless
2 2 # $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3 3
4   -require 'geo_ruby/simple_features/helper'
5   -require 'geo_ruby/simple_features/ewkt_parser'
6   -require 'geo_ruby/simple_features/ewkb_parser'
7   -require 'geo_ruby/simple_features/geometry'
8   -require 'geo_ruby/simple_features/point'
9   -require 'geo_ruby/simple_features/line_string'
10   -require 'geo_ruby/simple_features/linear_ring'
11   -require 'geo_ruby/simple_features/circle'
12   -require 'geo_ruby/simple_features/polygon'
13   -require 'geo_ruby/simple_features/multi_point'
14   -require 'geo_ruby/simple_features/multi_line_string'
15   -require 'geo_ruby/simple_features/multi_polygon'
16   -require 'geo_ruby/simple_features/geometry_collection'
17   -require 'geo_ruby/simple_features/envelope'
18   -require 'geo_ruby/simple_features/geometry_factory'
  4 +require 'geo_ruby/simple_features'
19 5
20 6 # Require if you need
21 7 # require 'geo_ruby/shp4r/shp'
2  lib/geo_ruby/geojson.rb
@@ -8,6 +8,7 @@
8 8 end
9 9
10 10 module GeoRuby
  11 +
11 12 #Raised when an error in the GeoJSON string is detected
12 13 class GeojsonFormatError < StandardError
13 14 end
@@ -73,6 +74,7 @@ def to_json(options = {})
73 74
74 75
75 76 class GeojsonParser
  77 + include GeoRuby::SimpleFeatures
76 78 attr_reader :geometry
77 79
78 80 def parse(geojson, srid=DEFAULT_SRID)
1  lib/geo_ruby/georss.rb
@@ -21,6 +21,7 @@ class GeorssTags < Struct.new(:featuretypetag,:relationshiptag,:elev,:floor,:rad
21 21 #Parses GeoRSS strings
22 22 #You can also use directly the static method Geometry.from_georss
23 23 class GeorssParser
  24 + include GeoRuby::SimpleFeatures
24 25 attr_reader :georss_tags, :geometry
25 26
26 27 #Parses the georss geometry passed as argument and notifies the factory of events
2  lib/geo_ruby/kml.rb
@@ -61,7 +61,7 @@ def accumulate_start(e)
61 61 def accumulate_end(e); @buffer << "</#{e[0]}>"; end
62 62
63 63 def parse_coordinates(buffer)
64   - if(buffer =~ /<coordinates>(.+)<\/coordinates>/)
  64 + if(buffer =~ /<coordinates>(.+)<\/coordinates>/m)
65 65 $1.gsub(/\n/, " ").strip.split(/\s+/).each do |coord|
66 66 x,y,z = coord.split(',')
67 67 if(x.nil? || y.nil?)
25 lib/geo_ruby/simple_features.rb
... ... @@ -0,0 +1,25 @@
  1 +module GeoRuby
  2 + module SimpleFeatures
  3 +
  4 + %w[
  5 + geometry
  6 + circle
  7 + envelope
  8 + ewkb_parser
  9 + ewkt_parser
  10 + geometry_collection
  11 + geometry_factory
  12 + helper
  13 + line_string
  14 + linear_ring
  15 + multi_line_string
  16 + multi_point
  17 + multi_polygon
  18 + point
  19 + polygon
  20 + ].each do |rel_file|
  21 + require File.join(File.dirname(__FILE__), 'simple_features', rel_file)
  22 + end
  23 +
  24 + end
  25 +end
52 spec/geo_ruby/geojson_spec.rb
@@ -7,25 +7,25 @@
7 7 #
8 8 # TODO Refactor comon test approaches into methods
9 9 # TODO Add use of contexts?
10   -describe GeojsonParser do
  10 +describe GeoRuby::GeojsonParser do
11 11
12   - it "should create a specified Point" do
  12 + it "should create a specified GeoRuby::SimpleFeatures::Point" do
13 13 point_json = %{ { "type": "Point", "coordinates": [100.0, 0.0] } }
14   - point = Geometry.from_geojson(point_json)
15   - point.class.should eql(Point)
  14 + point = GeoRuby::SimpleFeatures::Geometry.from_geojson(point_json)
  15 + point.class.should eql(GeoRuby::SimpleFeatures::Point)
16 16 point_hash = JSON.parse(point_json)
17 17 point.to_coordinates.should eql(point_hash['coordinates'])
18 18 end
19 19
20   - it "should create a specified LineString" do
  20 + it "should create a specified GeoRuby::SimpleFeatures::LineString" do
21 21 ls_json = %{ { "type": "LineString", "coordinates": [ [100.0, 0.0], [101.0, 1.0] ]} }
22   - line_string = Geometry.from_geojson(ls_json)
23   - line_string.class.should eql(LineString)
  22 + line_string = GeoRuby::SimpleFeatures::Geometry.from_geojson(ls_json)
  23 + line_string.class.should eql(GeoRuby::SimpleFeatures::LineString)
24 24 ls_hash = JSON.parse(ls_json)
25 25 line_string.to_coordinates.should eql(ls_hash['coordinates'])
26 26 end
27 27
28   - it "should create a specified Polygon" do
  28 + it "should create a specified GeoRuby::SimpleFeatures::Polygon" do
29 29 poly_json = <<-EOJ
30 30 { "type": "Polygon",
31 31 "coordinates": [
@@ -34,26 +34,26 @@
34 34 ]
35 35 }
36 36 EOJ
37   - polygon = Geometry.from_geojson(poly_json)
38   - polygon.class.should eql(Polygon)
  37 + polygon = GeoRuby::SimpleFeatures::Geometry.from_geojson(poly_json)
  38 + polygon.class.should eql(GeoRuby::SimpleFeatures::Polygon)
39 39 polygon.rings.size.should eql(2)
40 40 poly_hash = JSON.parse(poly_json)
41 41 polygon.to_coordinates.should eql(poly_hash['coordinates'])
42 42 end
43 43
44   - it "should create a specified MultiPoint" do
  44 + it "should create a specified GeoRuby::SimpleFeatures::MultiPoint" do
45 45 mp_json = <<-EOJ
46 46 { "type": "MultiPoint",
47 47 "coordinates": [ [100.0, 0.0], [101.0, 1.0] ]
48 48 }
49 49 EOJ
50   - multi_point = Geometry.from_geojson(mp_json)
51   - multi_point.class.should eql(MultiPoint)
  50 + multi_point = GeoRuby::SimpleFeatures::Geometry.from_geojson(mp_json)
  51 + multi_point.class.should eql(GeoRuby::SimpleFeatures::MultiPoint)
52 52 mp_hash = JSON.parse(mp_json)
53 53 multi_point.to_coordinates.should eql(mp_hash['coordinates'])
54 54 end
55 55
56   - it "should create a specified MultiLineString" do
  56 + it "should create a specified GeoRuby::SimpleFeatures::MultiLineString" do
57 57 mls_json = <<-EOJ
58 58 { "type": "MultiLineString",
59 59 "coordinates": [
@@ -62,13 +62,13 @@
62 62 ]
63 63 }
64 64 EOJ
65   - multi_ls = Geometry.from_geojson(mls_json)
66   - multi_ls.class.should eql(MultiLineString)
  65 + multi_ls = GeoRuby::SimpleFeatures::Geometry.from_geojson(mls_json)
  66 + multi_ls.class.should eql(GeoRuby::SimpleFeatures::MultiLineString)
67 67 mls_hash = JSON.parse(mls_json)
68 68 multi_ls.to_coordinates.should eql(mls_hash['coordinates'])
69 69 end
70 70
71   - it "should create a specifiead MultiPolygon" do
  71 + it "should create a specifiead GeoRuby::SimpleFeatures::MultiPolygon" do
72 72 mpoly_json = <<-EOJ
73 73 { "type": "MultiPolygon",
74 74 "coordinates": [
@@ -78,13 +78,13 @@
78 78 ]
79 79 }
80 80 EOJ
81   - mpoly = Geometry.from_geojson(mpoly_json)
82   - mpoly.class.should eql(MultiPolygon)
  81 + mpoly = GeoRuby::SimpleFeatures::Geometry.from_geojson(mpoly_json)
  82 + mpoly.class.should eql(GeoRuby::SimpleFeatures::MultiPolygon)
83 83 mpoly_hash = JSON.parse(mpoly_json)
84 84 mpoly.to_coordinates.should eql(mpoly_hash['coordinates'])
85 85 end
86 86
87   - it "should create a specified GeometryCollection" do
  87 + it "should create a specified GeoRuby::SimpleFeatures::GeometryCollection" do
88 88 gcol_json = <<-EOJ
89 89 { "type": "GeometryCollection",
90 90 "geometries": [
@@ -97,8 +97,8 @@
97 97 ]
98 98 }
99 99 EOJ
100   - gcol = Geometry.from_geojson(gcol_json)
101   - gcol.class.should eql(GeometryCollection)
  100 + gcol = GeoRuby::SimpleFeatures::Geometry.from_geojson(gcol_json)
  101 + gcol.class.should eql(GeoRuby::SimpleFeatures::GeometryCollection)
102 102 gcol_hash = JSON.parse(gcol_json)
103 103 gcol.geometries.each_with_index do |g,i|
104 104 gh = gcol_hash['geometries'][i]
@@ -120,8 +120,8 @@
120 120 }
121 121 }
122 122 EOJ
123   - f = Geometry.from_geojson(feature_json)
124   - f.class.should eql(GeojsonFeature)
  123 + f = GeoRuby::SimpleFeatures::Geometry.from_geojson(feature_json)
  124 + f.class.should eql(GeoRuby::GeojsonFeature)
125 125 feature_hash = JSON.parse(feature_json)
126 126 f.id.should eql(feature_hash['id'])
127 127 f.properties.should eql(feature_hash['properties'])
@@ -131,8 +131,8 @@
131 131
132 132 it "should create a specified FeatureCollection" do
133 133 fcol_json = File.read(DATA_DIR + 'feature_collection.json')
134   - fcol = Geometry.from_geojson(fcol_json)
135   - fcol.class.should eql(GeojsonFeatureCollection)
  134 + fcol = GeoRuby::SimpleFeatures::Geometry.from_geojson(fcol_json)
  135 + fcol.class.should eql(GeoRuby::GeojsonFeatureCollection)
136 136 fcol_hash = JSON.parse(fcol_json)
137 137 fcol.features.each_with_index do |f,i|
138 138 fgh = fcol_hash['features'][i]['geometry']
218 spec/geo_ruby/georss.rb
... ... @@ -1,218 +0,0 @@
1   -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2   -
3   -describe GeorssParser do
4   - it "test_point_creation" do
5   - point = Point.from_x_y(3,4)
6   -
7   - point.as_georss(:dialect => :simple, :elev => 45.7, :featuretypetag => "hoyoyo").gsub("\n","").should eql("<georss:point featuretypetag=\"hoyoyo\" elev=\"45.7\">4 3</georss:point>")
8   - point.as_georss(:dialect => :w3cgeo).gsub("\n","").should eql("<geo:lat>4</geo:lat><geo:long>3</geo:long>")
9   - point.as_georss(:dialect => :gml).gsub("\n","").should eql("<georss:where><gml:Point><gml:pos>4 3</gml:pos></gml:Point></georss:where>")
10   -
11   - point.as_kml(:id => "HOYOYO-42").gsub("\n","").should eql("<Point id=\"HOYOYO-42\"><coordinates>3,4</coordinates></Point>")
12   - end
13   -
14   - it "test_line_string" do
15   - ls = LineString.from_points([Point.from_lon_lat_z(12.4,-45.3,56),Point.from_lon_lat_z(45.4,41.6,45)],123,true)
16   -
17   - ls.as_georss.gsub("\n","").should eql("<georss:line>-45.3 12.4 41.6 45.4</georss:line>")
18   - ls.as_georss(:dialect => :w3cgeo).gsub("\n","").should eql("<geo:lat>-45.3</geo:lat><geo:long>12.4</geo:long>")
19   - ls.as_georss(:dialect => :gml).gsub("\n","").should eql("<georss:where><gml:LineString><gml:posList>-45.3 12.4 41.6 45.4</gml:posList></gml:LineString></georss:where>")
20   -
21   - ls.as_kml(:extrude => 1, :altitude_mode => "absolute").gsub("\n","").should eql("<LineString><extrude>1</extrude><altitudeMode>absolute</altitudeMode><coordinates>12.4,-45.3,56 45.4,41.6,45</coordinates></LineString>")
22   - end
23   -
24   - it "test_polygon" do
25   - linear_ring1 = LinearRing.from_coordinates([[12.4,-45.3],[45.4,41.6],[4.456,1.0698],[12.4,-45.3]],256)
26   - linear_ring2 = LinearRing.from_coordinates([[2.4,5.3],[5.4,1.4263],[14.46,1.06],[2.4,5.3]],256)
27   - polygon = Polygon.from_linear_rings([linear_ring1,linear_ring2],256)
28   -
29   - polygon.as_georss(:georss_ns => "hoyoyo").gsub("\n","").should eql("<hoyoyo:polygon>-45.3 12.4 41.6 45.4 1.0698 4.456 -45.3 12.4</hoyoyo:polygon>")
30   - polygon.as_georss(:dialect => :w3cgeo, :w3cgeo_ns => "bouyoul").gsub("\n","").should eql("<bouyoul:lat>-45.3</bouyoul:lat><bouyoul:long>12.4</bouyoul:long>")
31   - polygon.as_georss(:dialect => :gml).gsub("\n","").should eql("<georss:where><gml:Polygon><gml:exterior><gml:LinearRing><gml:posList>-45.3 12.4 41.6 45.4 1.0698 4.456 -45.3 12.4</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon></georss:where>")
32   -
33   - polygon.as_kml.gsub("\n","").should eql("<Polygon><outerBoundaryIs><LinearRing><coordinates>12.4,-45.3 45.4,41.6 4.456,1.0698 12.4,-45.3</coordinates></LinearRing></outerBoundaryIs><innerBoundaryIs><LinearRing><coordinates>2.4,5.3 5.4,1.4263 14.46,1.06 2.4,5.3</coordinates></LinearRing></innerBoundaryIs></Polygon>")
34   - end
35   -
36   - it "test_geometry_collection" do
37   - gc = GeometryCollection.from_geometries([Point.from_x_y(4.67,45.4,256),LineString.from_coordinates([[5.7,12.45],[67.55,54]],256)],256)
38   -
39   - #only the first geometry is output
40   - gc.as_georss(:dialect => :simple,:floor => 4).gsub("\n","").should eql("<georss:point floor=\"4\">45.4 4.67</georss:point>")
41   - gc.as_georss(:dialect => :w3cgeo).gsub("\n","").should eql("<geo:lat>45.4</geo:lat><geo:long>4.67</geo:long>")
42   - gc.as_georss(:dialect => :gml).gsub("\n","").should eql("<georss:where><gml:Point><gml:pos>45.4 4.67</gml:pos></gml:Point></georss:where>")
43   -
44   - gc.as_kml(:id => "HOYOYO-42").gsub("\n","").should eql("<MultiGeometry id=\"HOYOYO-42\"><Point><coordinates>4.67,45.4</coordinates></Point><LineString><coordinates>5.7,12.45 67.55,54</coordinates></LineString></MultiGeometry>")
45   - end
46   -
47   - it "test_envelope" do
48   - linear_ring1 = LinearRing.from_coordinates([[12,-45,5],[45,41,6],[4,1,8],[12.4,-45,3]],256,true)
49   - linear_ring2 = LinearRing.from_coordinates([[2,5,9],[5.4,1,-5.4],[14,1,34],[2,5,3]],256,true)
50   - polygon = Polygon.from_linear_rings([linear_ring1,linear_ring2],256,true)
51   -
52   - e = polygon.envelope
53   -
54   - e.as_georss(:dialect => :simple).gsub("\n","").should eql("<georss:box>-45 4 41 45</georss:box>")
55   - #center
56   - e.as_georss(:dialect => :w3cgeo).gsub("\n","").should eql("<geo:lat>-2</geo:lat><geo:long>24</geo:long>")
57   - e.as_georss(:dialect => :gml).gsub("\n","").should eql("<georss:where><gml:Envelope><gml:LowerCorner>-45 4</gml:LowerCorner><gml:UpperCorner>41 45</gml:UpperCorner></gml:Envelope></georss:where>")
58   -
59   - e.as_kml.gsub("\n","").should eql("<LatLonAltBox><north>41</north><south>-45</south><east>45</east><west>4</west><minAltitude>-5.4</minAltitude><maxAltitude>34</maxAltitude></LatLonAltBox>")
60   - end
61   -
62   - it "test_point_georss_read" do
63   - #W3CGeo
64   - str = " <geo:lat >12.3</geo:lat >\n\t <geo:long> 4.56</geo:long> "
65   - geom = Geometry.from_georss(str)
66   - geom.class.should eql(Point)
67   - geom.lat.should eql(12.3)
68   - geom.lon.should eql(4.56)
69   -
70   - str = " <geo:Point> \n \t <geo:long> 4.56</geo:long> \n\t <geo:lat >12.3</geo:lat > </geo:Point> "
71   - geom = Geometry.from_georss(str)
72   - geom.class.should eql(Point)
73   - geom.lat.should eql(12.3)
74   - geom.lon.should eql(4.56)
75   -
76   - #gml
77   - str = " <georss:where> \t\r <gml:Point > \t <gml:pos> 4 \t 3 </gml:pos> </gml:Point> </georss:where>"
78   - geom = Geometry.from_georss(str)
79   - geom.class.should eql(Point)
80   - geom.lat.should eql(4.0)
81   - geom.lon.should eql(3.0)
82   -
83   - #simple
84   - str = "<georss:point > 4 \r\t 3 \t</georss:point >"
85   - geom = Geometry.from_georss(str)
86   - geom.class.should eql(Point)
87   - geom.lat.should eql(4.0)
88   - geom.lon.should eql(3.0)
89   -
90   - #simple with tags
91   - str = "<georss:point featuretypetag=\"hoyoyo\" elev=\"45.7\" \n floor=\"2\" relationshiptag=\"puyopuyo\" radius=\"42\" > 4 \n 3 \t</georss:point >"
92   - geom,tags = Geometry.from_georss_with_tags(str)
93   - geom.class.should eql(Point)
94   - geom.lat.should eql(4.0)
95   - geom.lon.should eql(3.0)
96   - tags.featuretypetag.should eql("hoyoyo")
97   - tags.elev.should eql(45.7)
98   - tags.relationshiptag.should eql("puyopuyo")
99   - tags.floor.should eql(2)
100   - tags.radius.should eql(42.0)
101   - end
102   -
103   - it "test_line_string_georss_read" do
104   - ls = LineString.from_points([Point.from_lon_lat(12.4,-45.3),Point.from_lon_lat(45.4,41.6)])
105   -
106   - str = "<georss:line > -45.3 12.4 \n \r41.6\t 45.4</georss:line>"
107   - geom = Geometry.from_georss(str)
108   - geom.class.should eql(LineString)
109   - ls.should == geom
110   -
111   - str = "<georss:where><gml:LineString><gml:posList>-45.3 12.4 41.6 45.4</gml:posList></gml:LineString></georss:where>"
112   - geom = Geometry.from_georss(str)
113   - geom.class.should eql(LineString)
114   - ls.should == geom
115   - end
116   -
117   - it "test_polygon_georss_read" do
118   - linear_ring = LinearRing.from_coordinates([[12.4,-45.3],[45.4,41.6],[4.456,1.0698],[12.4,-45.3]])
119   - polygon = Polygon.from_linear_rings([linear_ring])
120   -
121   - str = "<hoyoyo:polygon featuretypetag=\"42\" > -45.3 12.4 41.6 \n\r 45.4 1.0698 \r 4.456 -45.3 12.4 </hoyoyo:polygon>"
122   - geom = Geometry.from_georss(str)
123   - geom.class.should eql(Polygon)
124   - polygon.should == geom
125   -
126   - str = "<georss:where>\r\t \n <gml:Polygon><gml:exterior> <gml:LinearRing><gml:posList> -45.3 \n\r 12.4 41.6 \n\t 45.4 1.0698 4.456 -45.3 12.4</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon></georss:where>"
127   - geom = Geometry.from_georss(str)
128   - geom.class.should eql(Polygon)
129   - polygon.should == geom
130   - end
131   -
132   - it "test_envelope_georss_read" do
133   - e = Envelope.from_coordinates([[4.456,-45.3],[45.4,41.6]])
134   -
135   - str = "<georss:box >-45.3 4.456 \n41.6 45.4</georss:box>"
136   - geom = Geometry.from_georss(str)
137   - geom.class.should eql(Envelope)
138   - geom.should == e
139   -
140   - str = "<georss:where><gml:Envelope><gml:lowerCorner>-45.3 \n 4.456</gml:lowerCorner><gml:upperCorner>41.6 \t\n 45.4</gml:upperCorner></gml:Envelope></georss:where>"
141   - geom = Geometry.from_georss(str)
142   - geom.class.should eql(Envelope)
143   - geom.should == e
144   - end
145   -
146   - it "test_kml_read" do
147   - g = Geometry.from_kml("<Point><coordinates>45,12,25</coordinates></Point>")
148   - g.should be_a Point
149   - g.should == Point.from_x_y_z(45,12,25)
150   -
151   - g = Geometry.from_kml("<LineString>
152   - <extrude>1</extrude>
153   - <tessellate>1</tessellate>
154   - <coordinates>
155   - -122.364383,37.824664,0 -122.364152,37.824322,0
156   - </coordinates>
157   - </LineString>")
158   - g.should be_a LineString
159   - g.length.should eql(2)
160   - g.should == LineString.from_points([Point.from_x_y_z(-122.364383,37.824664,0),Point.from_x_y_z(-122.364152,37.824322,0)],4326,true)
161   -
162   - g = Geometry.from_kml("<Polygon>
163   - <extrude>1</extrude>
164   - <altitudeMode>relativeToGround</altitudeMode>
165   - <outerBoundaryIs>
166   - <LinearRing>
167   - <coordinates>
168   - -122.366278,37.818844,30
169   - -122.365248,37.819267,30
170   - -122.365640,37.819861,30
171   - -122.366669,37.819429,30
172   - -122.366278,37.818844,30
173   - </coordinates>
174   - </LinearRing>
175   - </outerBoundaryIs>
176   - <innerBoundaryIs>
177   - <LinearRing>
178   - <coordinates>
179   - -122.366212,37.818977,30
180   - -122.365424,37.819294,30
181   - -122.365704,37.819731,30
182   - -122.366488,37.819402,30
183   - -122.366212,37.818977,30
184   - </coordinates>
185   - </LinearRing>
186   - </innerBoundaryIs>
187   - <innerBoundaryIs>
188   - <LinearRing>
189   - <coordinates>
190   - -122.366212,37.818977,30
191   - -122.365424,37.819294,30
192   - -122.365704,37.819731,30
193   - -122.366488,37.819402,30
194   - -122.366212,37.818977,30
195   - </coordinates>
196   - </LinearRing>
197   - </innerBoundaryIs>
198   - </Polygon>")
199   - g.should be_a Polygon
200   - g.length.should eql(3)
201   - end
202   -
203   - it "test_to_kml_for_point_does_not_raise_type_error_if_geom_data_not_provided" do
204   - point = Point.from_coordinates([1.6,2.8],123)
205   - lambda { point.kml_representation }.should_not raise_error(TypeError)
206   - end
207   -
208   - it "test_to_kml_for_polygon_does_not_raise_type_error_if_geom_data_not_provided" do
209   - polygon = Polygon.from_coordinates([[[12.4,-45.3],[45.4,41.6],[4.456,1.0698],[12.4,-45.3]],[[2.4,5.3],[5.4,1.4263],[14.46,1.06],[2.4,5.3]]],256)
210   - lambda { polygon.kml_representation }.should_not raise_error(TypeError)
211   - end
212   -
213   - it "test_to_kml_for_line_string_does_not_raise_type_error_if_geom_data_not_provided" do
214   - ls = LineString.from_coordinates([[5.7,12.45],[67.55,54]],256)
215   - lambda { ls.kml_representation }.should_not raise_error(TypeError)
216   - end
217   -
218   -end
218 spec/geo_ruby/georss_spec.rb
@@ -2,13 +2,225 @@
2 2
3 3 RSS_DATA_DIR = File.dirname(__FILE__) + '/../data/georss/'
4 4
5   -describe GeorssParser do
  5 +describe GeoRuby::GeorssParser do
6 6
7 7 it "should parse an rss file" do
8   - geo = GeorssParser.new.parse(File.read(RSS_DATA_DIR + "/w3c.xml"))
9   - geo.should be_a Point
  8 + geo = subject.parse(File.read(RSS_DATA_DIR + "/w3c.xml"))
  9 + geo.should be_a GeoRuby::SimpleFeatures::Point
10 10 end
11 11
  12 + it "test_point_creation" do
  13 + point = GeoRuby::SimpleFeatures::Point.from_x_y(3,4)
12 14
  15 + point.as_georss(:dialect => :simple, :elev => 45.7, :featuretypetag => "hoyoyo").gsub("\n","").should eql("<georss:point featuretypetag=\"hoyoyo\" elev=\"45.7\">4 3</georss:point>")
  16 + point.as_georss(:dialect => :w3cgeo).gsub("\n","").should eql("<geo:lat>4</geo:lat><geo:long>3</geo:long>")
  17 + point.as_georss(:dialect => :gml).gsub("\n","").should eql("<georss:where><gml:Point><gml:pos>4 3</gml:pos></gml:Point></georss:where>")
  18 +
  19 + point.as_kml(:id => "HOYOYO-42").gsub("\n","").should eql("<Point id=\"HOYOYO-42\"><coordinates>3,4</coordinates></Point>")
  20 + end
  21 +
  22 + it "test_line_string" do
  23 + ls = GeoRuby::SimpleFeatures::LineString.from_points([GeoRuby::SimpleFeatures::Point.from_lon_lat_z(12.4,-45.3,56),GeoRuby::SimpleFeatures::Point.from_lon_lat_z(45.4,41.6,45)],123,true)
  24 +
  25 + ls.as_georss.gsub("\n","").should eql("<georss:line>-45.3 12.4 41.6 45.4</georss:line>")
  26 + ls.as_georss(:dialect => :w3cgeo).gsub("\n","").should eql("<geo:lat>-45.3</geo:lat><geo:long>12.4</geo:long>")
  27 + ls.as_georss(:dialect => :gml).gsub("\n","").should eql("<georss:where><gml:LineString><gml:posList>-45.3 12.4 41.6 45.4</gml:posList></gml:LineString></georss:where>")
  28 +
  29 + ls.as_kml(:extrude => 1, :altitude_mode => "absolute").gsub("\n","").should eql("<LineString><extrude>1</extrude><altitudeMode>absolute</altitudeMode><coordinates>12.4,-45.3,56 45.4,41.6,45</coordinates></LineString>")
  30 + end
  31 +
  32 + it "test_polygon" do
  33 + linear_ring1 = GeoRuby::SimpleFeatures::LinearRing.from_coordinates([[12.4,-45.3],[45.4,41.6],[4.456,1.0698],[12.4,-45.3]],256)
  34 + linear_ring2 = GeoRuby::SimpleFeatures::LinearRing.from_coordinates([[2.4,5.3],[5.4,1.4263],[14.46,1.06],[2.4,5.3]],256)
  35 + polygon = GeoRuby::SimpleFeatures::Polygon.from_linear_rings([linear_ring1,linear_ring2],256)
  36 +
  37 + polygon.as_georss(:georss_ns => "hoyoyo").gsub("\n","").should eql("<hoyoyo:polygon>-45.3 12.4 41.6 45.4 1.0698 4.456 -45.3 12.4</hoyoyo:polygon>")
  38 + polygon.as_georss(:dialect => :w3cgeo, :w3cgeo_ns => "bouyoul").gsub("\n","").should eql("<bouyoul:lat>-45.3</bouyoul:lat><bouyoul:long>12.4</bouyoul:long>")
  39 + polygon.as_georss(:dialect => :gml).gsub("\n","").should eql("<georss:where><gml:Polygon><gml:exterior><gml:LinearRing><gml:posList>-45.3 12.4 41.6 45.4 1.0698 4.456 -45.3 12.4</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon></georss:where>")
  40 +
  41 + polygon.as_kml.gsub("\n","").should eql("<Polygon><outerBoundaryIs><LinearRing><coordinates>12.4,-45.3 45.4,41.6 4.456,1.0698 12.4,-45.3</coordinates></LinearRing></outerBoundaryIs><innerBoundaryIs><LinearRing><coordinates>2.4,5.3 5.4,1.4263 14.46,1.06 2.4,5.3</coordinates></LinearRing></innerBoundaryIs></Polygon>")
  42 + end
  43 +
  44 + it "test_geometry_collection" do
  45 + gc = GeoRuby::SimpleFeatures::GeometryCollection.from_geometries([GeoRuby::SimpleFeatures::Point.from_x_y(4.67,45.4,256),GeoRuby::SimpleFeatures::LineString.from_coordinates([[5.7,12.45],[67.55,54]],256)],256)
  46 +
  47 + #only the first geometry is output
  48 + gc.as_georss(:dialect => :simple,:floor => 4).gsub("\n","").should eql("<georss:point floor=\"4\">45.4 4.67</georss:point>")
  49 + gc.as_georss(:dialect => :w3cgeo).gsub("\n","").should eql("<geo:lat>45.4</geo:lat><geo:long>4.67</geo:long>")
  50 + gc.as_georss(:dialect => :gml).gsub("\n","").should eql("<georss:where><gml:Point><gml:pos>45.4 4.67</gml:pos></gml:Point></georss:where>")
  51 +
  52 + gc.as_kml(:id => "HOYOYO-42").gsub("\n","").should eql("<MultiGeometry id=\"HOYOYO-42\"><Point><coordinates>4.67,45.4</coordinates></Point><LineString><coordinates>5.7,12.45 67.55,54</coordinates></LineString></MultiGeometry>")
  53 + end
  54 +
  55 + it "test_envelope" do
  56 + linear_ring1 = GeoRuby::SimpleFeatures::LinearRing.from_coordinates([[12,-45,5],[45,41,6],[4,1,8],[12.4,-45,3]],256,true)
  57 + linear_ring2 = GeoRuby::SimpleFeatures::LinearRing.from_coordinates([[2,5,9],[5.4,1,-5.4],[14,1,34],[2,5,3]],256,true)
  58 + polygon = GeoRuby::SimpleFeatures::Polygon.from_linear_rings([linear_ring1,linear_ring2],256,true)
  59 +
  60 + e = polygon.envelope
  61 +
  62 + e.as_georss(:dialect => :simple).gsub("\n","").should eql("<georss:box>-45 4 41 45</georss:box>")
  63 + #center
  64 + e.as_georss(:dialect => :w3cgeo).gsub("\n","").should eql("<geo:lat>-2</geo:lat><geo:long>24</geo:long>")
  65 + e.as_georss(:dialect => :gml).gsub("\n","").should eql("<georss:where><gml:Envelope><gml:LowerCorner>-45 4</gml:LowerCorner><gml:UpperCorner>41 45</gml:UpperCorner></gml:Envelope></georss:where>")
  66 +
  67 + e.as_kml.gsub("\n","").should eql("<LatLonAltBox><north>41</north><south>-45</south><east>45</east><west>4</west><minAltitude>-5.4</minAltitude><maxAltitude>34</maxAltitude></LatLonAltBox>")
  68 + end
  69 +
  70 + it "test_point_georss_read" do
  71 + #W3CGeo
  72 + str = " <geo:lat >12.3</geo:lat >\n\t <geo:long> 4.56</geo:long> "
  73 + geom = GeoRuby::SimpleFeatures::Geometry.from_georss(str)
  74 + geom.class.should eql(GeoRuby::SimpleFeatures::Point)
  75 + geom.lat.should eql(12.3)
  76 + geom.lon.should eql(4.56)
  77 +
  78 + str = " <geo:Point> \n \t <geo:long> 4.56</geo:long> \n\t <geo:lat >12.3</geo:lat > </geo:Point> "
  79 + geom = GeoRuby::SimpleFeatures::Geometry.from_georss(str)
  80 + geom.class.should eql(GeoRuby::SimpleFeatures::Point)
  81 + geom.lat.should eql(12.3)
  82 + geom.lon.should eql(4.56)
  83 +
  84 + #gml
  85 + str = " <georss:where> \t\r <gml:Point > \t <gml:pos> 4 \t 3 </gml:pos> </gml:Point> </georss:where>"
  86 + geom = GeoRuby::SimpleFeatures::Geometry.from_georss(str)
  87 + geom.class.should eql(GeoRuby::SimpleFeatures::Point)
  88 + geom.lat.should eql(4.0)
  89 + geom.lon.should eql(3.0)
  90 +
  91 + #simple
  92 + str = "<georss:point > 4 \r\t 3 \t</georss:point >"
  93 + geom = GeoRuby::SimpleFeatures::Geometry.from_georss(str)
  94 + geom.class.should eql(GeoRuby::SimpleFeatures::Point)
  95 + geom.lat.should eql(4.0)
  96 + geom.lon.should eql(3.0)
  97 +
  98 + #simple with tags
  99 + str = "<georss:point featuretypetag=\"hoyoyo\" elev=\"45.7\" \n floor=\"2\" relationshiptag=\"puyopuyo\" radius=\"42\" > 4 \n 3 \t</georss:point >"
  100 + geom,tags = GeoRuby::SimpleFeatures::Geometry.from_georss_with_tags(str)
  101 + geom.class.should eql(GeoRuby::SimpleFeatures::Point)
  102 + geom.lat.should eql(4.0)
  103 + geom.lon.should eql(3.0)
  104 + tags.featuretypetag.should eql("hoyoyo")
  105 + tags.elev.should eql(45.7)
  106 + tags.relationshiptag.should eql("puyopuyo")
  107 + tags.floor.should eql(2)
  108 + tags.radius.should eql(42.0)
  109 + end
  110 +
  111 + it "test_line_string_georss_read" do
  112 + ls = GeoRuby::SimpleFeatures::LineString.from_points([GeoRuby::SimpleFeatures::Point.from_lon_lat(12.4,-45.3),GeoRuby::SimpleFeatures::Point.from_lon_lat(45.4,41.6)])
  113 +
  114 + str = "<georss:line > -45.3 12.4 \n \r41.6\t 45.4</georss:line>"
  115 + geom = GeoRuby::SimpleFeatures::Geometry.from_georss(str)
  116 + geom.class.should eql(GeoRuby::SimpleFeatures::LineString)
  117 + ls.should == geom
  118 +
  119 + str = "<georss:where><gml:LineString><gml:posList>-45.3 12.4 41.6 45.4</gml:posList></gml:LineString></georss:where>"
  120 + geom = GeoRuby::SimpleFeatures::Geometry.from_georss(str)
  121 + geom.class.should eql(GeoRuby::SimpleFeatures::LineString)
  122 + ls.should == geom
  123 + end
  124 +
  125 + it "test_polygon_georss_read" do
  126 + linear_ring = GeoRuby::SimpleFeatures::LinearRing.from_coordinates([[12.4,-45.3],[45.4,41.6],[4.456,1.0698],[12.4,-45.3]])
  127 + polygon = GeoRuby::SimpleFeatures::Polygon.from_linear_rings([linear_ring])
  128 +
  129 + str = "<hoyoyo:polygon featuretypetag=\"42\" > -45.3 12.4 41.6 \n\r 45.4 1.0698 \r 4.456 -45.3 12.4 </hoyoyo:polygon>"
  130 + geom = GeoRuby::SimpleFeatures::Geometry.from_georss(str)
  131 + geom.class.should eql(GeoRuby::SimpleFeatures::Polygon)
  132 + polygon.should == geom
  133 +
  134 + str = "<georss:where>\r\t \n <gml:Polygon><gml:exterior> <gml:LinearRing><gml:posList> -45.3 \n\r 12.4 41.6 \n\t 45.4 1.0698 4.456 -45.3 12.4</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon></georss:where>"
  135 + geom = GeoRuby::SimpleFeatures::Geometry.from_georss(str)
  136 + geom.class.should eql(GeoRuby::SimpleFeatures::Polygon)
  137 + polygon.should == geom
  138 + end
  139 +
  140 + it "test_envelope_georss_read" do
  141 + e = GeoRuby::SimpleFeatures::Envelope.from_coordinates([[4.456,-45.3],[45.4,41.6]])
  142 +
  143 + str = "<georss:box >-45.3 4.456 \n41.6 45.4</georss:box>"
  144 + geom = GeoRuby::SimpleFeatures::Geometry.from_georss(str)
  145 + geom.class.should eql(GeoRuby::SimpleFeatures::Envelope)
  146 + geom.should == e
  147 +
  148 + str = "<georss:where><gml:Envelope><gml:lowerCorner>-45.3 \n 4.456</gml:lowerCorner><gml:upperCorner>41.6 \t\n 45.4</gml:upperCorner></gml:Envelope></georss:where>"
  149 + geom = GeoRuby::SimpleFeatures::Geometry.from_georss(str)
  150 + geom.class.should eql(GeoRuby::SimpleFeatures::Envelope)
  151 + geom.should == e
  152 + end
  153 +
  154 + it "test_kml_read" do
  155 + g = GeoRuby::SimpleFeatures::Geometry.from_kml("<Point><coordinates>45,12,25</coordinates></Point>")
  156 + g.should be_a GeoRuby::SimpleFeatures::Point
  157 + g.should == GeoRuby::SimpleFeatures::Point.from_x_y_z('45','12','25')
  158 +
  159 + g = GeoRuby::SimpleFeatures::Geometry.from_kml("<LineString>
  160 + <extrude>1</extrude>
  161 + <tessellate>1</tessellate>
  162 + <coordinates>
  163 + -122.364383,37.824664,0 -122.364152,37.824322,0
  164 + </coordinates>
  165 + </LineString>")
  166 + g.should be_a GeoRuby::SimpleFeatures::LineString
  167 + g.length.should eql(2)
  168 + g.should == GeoRuby::SimpleFeatures::LineString.from_points([GeoRuby::SimpleFeatures::Point.from_x_y_z('-122.364383','37.824664','0'),GeoRuby::SimpleFeatures::Point.from_x_y_z('-122.364152','37.824322','0')],4326,true)
  169 +
  170 + g = GeoRuby::SimpleFeatures::Geometry.from_kml("<Polygon>
  171 + <extrude>1</extrude>
  172 + <altitudeMode>relativeToGround</altitudeMode>
  173 + <outerBoundaryIs>
  174 + <LinearRing>
  175 + <coordinates>
  176 + -122.366278,37.818844,30
  177 + -122.365248,37.819267,30
  178 + -122.365640,37.819861,30
  179 + -122.366669,37.819429,30
  180 + -122.366278,37.818844,30
  181 + </coordinates>
  182 + </LinearRing>
  183 + </outerBoundaryIs>
  184 + <innerBoundaryIs>
  185 + <LinearRing>
  186 + <coordinates>
  187 + -122.366212,37.818977,30
  188 + -122.365424,37.819294,30
  189 + -122.365704,37.819731,30
  190 + -122.366488,37.819402,30
  191 + -122.366212,37.818977,30
  192 + </coordinates>
  193 + </LinearRing>
  194 + </innerBoundaryIs>
  195 + <innerBoundaryIs>
  196 + <LinearRing>
  197 + <coordinates>
  198 + -122.366212,37.818977,30
  199 + -122.365424,37.819294,30
  200 + -122.365704,37.819731,30
  201 + -122.366488,37.819402,30
  202 + -122.366212,37.818977,30
  203 + </coordinates>
  204 + </LinearRing>
  205 + </innerBoundaryIs>
  206 + </Polygon>")
  207 + g.should be_a GeoRuby::SimpleFeatures::Polygon
  208 + g.length.should eql(3)
  209 + end
  210 +
  211 + it "test_to_kml_for_point_does_not_raise_type_error_if_geom_data_not_provided" do
  212 + point = GeoRuby::SimpleFeatures::Point.from_coordinates([1.6,2.8],123)
  213 + lambda { point.kml_representation }.should_not raise_error(TypeError)
  214 + end
  215 +
  216 + it "test_to_kml_for_polygon_does_not_raise_type_error_if_geom_data_not_provided" do
  217 + polygon = GeoRuby::SimpleFeatures::Polygon.from_coordinates([[[12.4,-45.3],[45.4,41.6],[4.456,1.0698],[12.4,-45.3]],[[2.4,5.3],[5.4,1.4263],[14.46,1.06],[2.4,5.3]]],256)
  218 + lambda { polygon.kml_representation }.should_not raise_error(TypeError)
  219 + end
  220 +
  221 + it "test_to_kml_for_line_string_does_not_raise_type_error_if_geom_data_not_provided" do
  222 + ls = GeoRuby::SimpleFeatures::LineString.from_coordinates([[5.7,12.45],[67.55,54]],256)
  223 + lambda { ls.kml_representation }.should_not raise_error(TypeError)
  224 + end
13 225
14 226 end
41 spec/geo_ruby/gpx4r/gpx_spec.rb
... ... @@ -1,23 +1,20 @@
1 1 require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2 2
3   -include GeoRuby::Gpx4r
4   -include GeoRuby::SimpleFeatures
5   -
6   -describe Gpx4r do
  3 +describe GeoRuby::Gpx4r do
7 4
8 5 it "should add gpx extension and raise if doesn't exists" do
9 6 lambda do
10 7 File.should_receive(:exists?).with("short.gpx").and_return(false)
11   - GpxFile.open('short').should be_true
12   - end.should raise_error MalformedGpxException
  8 + GeoRuby::Gpx4r::GpxFile.open('short').should be_true
  9 + end.should raise_error GeoRuby::Gpx4r::MalformedGpxException
13 10 end
14 11
15 12 describe "Waypoints" do
16 13
17 14 before(:all) do
18   - @gpxfile = GpxFile.open(File.dirname(__FILE__) + '/../../data/gpx/short.gpx', :with_z => true, :with_m => true)
19   - @gpxfile2 = GpxFile.open(File.dirname(__FILE__) + '/../../data/gpx/fells_loop', :with_z => true, :with_m => true)
20   - @gpxfile3 = GpxFile.open(File.dirname(__FILE__) + '/../../data/gpx/tracktreks.gpx', :with_z => true)
  15 + @gpxfile = GeoRuby::Gpx4r::GpxFile.open(File.dirname(__FILE__) + '/../../data/gpx/short.gpx', :with_z => true, :with_m => true)
  16 + @gpxfile2 = GeoRuby::Gpx4r::GpxFile.open(File.dirname(__FILE__) + '/../../data/gpx/fells_loop', :with_z => true, :with_m => true)
  17 + @gpxfile3 = GeoRuby::Gpx4r::GpxFile.open(File.dirname(__FILE__) + '/../../data/gpx/tracktreks.gpx', :with_z => true)
21 18 end
22 19
23 20 it "should open and parse" do
@@ -63,43 +60,43 @@
63 60 end
64 61
65 62 it "should return it as a linestring" do
66   - @gpxfile.as_line_string.should be_instance_of LineString
67   - @gpxfile.as_polyline.should be_instance_of LineString
  63 + @gpxfile.as_line_string.should be_instance_of GeoRuby::SimpleFeatures::LineString
  64 + @gpxfile.as_polyline.should be_instance_of GeoRuby::SimpleFeatures::LineString
68 65 end
69 66
70 67 it "should return it as a linestring 3" do
71   - @gpxfile3.as_line_string.should be_instance_of LineString
72   - @gpxfile3.as_polyline.should be_instance_of LineString
  68 + @gpxfile3.as_line_string.should be_instance_of GeoRuby::SimpleFeatures::LineString
  69 + @gpxfile3.as_polyline.should be_instance_of GeoRuby::SimpleFeatures::LineString
73 70 end
74 71
75 72 it "should return a envelope" do
76   - @gpxfile.envelope.should be_instance_of Envelope
  73 + @gpxfile.envelope.should be_instance_of GeoRuby::SimpleFeatures::Envelope
77 74 @gpxfile.envelope.lower_corner.x.should be_within(0.001).of(9.08128)
78 75 @gpxfile.envelope.lower_corner.y.should be_within(0.001).of(48.7169)
79 76 end
80 77
81 78 it "should return a envelope 3" do
82   - @gpxfile3.envelope.should be_instance_of Envelope
  79 + @gpxfile3.envelope.should be_instance_of GeoRuby::SimpleFeatures::Envelope
83 80 @gpxfile3.envelope.lower_corner.x.should be_within(0.001).of(-149.8422613)
84 81 @gpxfile3.envelope.lower_corner.y.should be_within(0.001).of(-17.547636)
85 82 end
86 83
87 84 it "should return it as a polygon" do
88 85 [@gpxfile, @gpxfile2, @gpxfile3].each do |g|
89   - g.as_polygon.should be_instance_of Polygon
90   - g.as_polygon[0].should be_instance_of LinearRing
  86 + g.as_polygon.should be_instance_of GeoRuby::SimpleFeatures::Polygon
  87 + g.as_polygon[0].should be_instance_of GeoRuby::SimpleFeatures::LinearRing
91 88 g.as_polygon[0].should be_closed
92 89 g.as_polygon[1].should be_nil
93 90 end
94 91 end
95 92
96 93 it "should close the polygon" do
97   - se = Point.from_x_y(-44, -23)
98   - sw = Point.from_x_y(-42, -22)
99   - nw = Point.from_x_y(-42, -25)
100   - ne = Point.from_x_y(-44, -21)
  94 + se = GeoRuby::SimpleFeatures::Point.from_x_y(-44, -23)
  95 + sw = GeoRuby::SimpleFeatures::Point.from_x_y(-42, -22)
  96 + nw = GeoRuby::SimpleFeatures::Point.from_x_y(-42, -25)
  97 + ne = GeoRuby::SimpleFeatures::Point.from_x_y(-44, -21)
101 98 @gpxfile.instance_variable_set(:@points, [se,sw,nw,ne])
102   - @gpxfile.as_polygon.should == Polygon.from_points([[se,sw,nw,ne,se]])
  99 + @gpxfile.as_polygon.should == GeoRuby::SimpleFeatures::Polygon.from_points([[se,sw,nw,ne,se]])
103 100 end
104 101 end
105 102
12 spec/geo_ruby/kml_spec.rb
... ... @@ -1,6 +1,6 @@
1 1 require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2 2
3   -describe KmlParser do
  3 +describe GeoRuby::KmlParser do
4 4 before(:all) do
5 5 POINT = "<Point><coordinates>-82.4898187291883,34.2473206042649</coordinates></Point>"
6 6 LINESTRING = "<LineString><coordinates>-122.365662,37.826988 -122.365202,37.826302 -122.364581,37.82655 -122.365038,37.827237</coordinates></LineString>"
@@ -14,11 +14,11 @@
14 14 end
15 15
16 16 before(:each) do
17   - @factory = GeometryFactory.new
18   - @kml_parser = KmlParser.new(@factory)
  17 + @factory = GeoRuby::SimpleFeatures::GeometryFactory.new
  18 + @kml_parser = described_class.new(@factory)
19 19 end
20 20
21   - it "should parse a Point correctly" do
  21 + it "should parse a GeoRuby::SimpleFeatures::Point correctly" do
22 22 @kml_parser.parse(POINT)
23 23 g = @factory.geometry
24 24 g.should_not eql(nil)
@@ -26,7 +26,7 @@
26 26 g.as_kml.gsub(/\n/,'').should eql(POINT)
27 27 end
28 28
29   - it "should parse a LineString correctly" do
  29 + it "should parse a GeoRuby::SimpleFeatures::LineString correctly" do
30 30 @kml_parser.parse(LINESTRING)
31 31 g = @factory.geometry
32 32 g.should_not eql(nil)
@@ -40,7 +40,7 @@
40 40 g.as_kml.gsub(/\n/,'').should eql(LINEARRING)
41 41 end
42 42
43   - it "should parse a Polygon correctly" do
  43 + it "should parse a GeoRuby::SimpleFeatures::Polygon correctly" do
44 44 @kml_parser.parse(POLYGON)
45 45 g = @factory.geometry
46 46 g.should_not eql(nil)
74 spec/geo_ruby/shp4r/shp_spec.rb
... ... @@ -1,18 +1,16 @@
1 1 require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2 2
3   -include GeoRuby::Shp4r
4   -
5   -describe Shp4r do
  3 +describe GeoRuby::Shp4r do
6 4
7 5 describe "Point" do
8 6 before(:each) do
9   - @shpfile = ShpFile.open(File.dirname(__FILE__) + '/../../data/point.shp')
  7 + @shpfile = GeoRuby::Shp4r::ShpFile.open(File.dirname(__FILE__) + '/../../data/point.shp')
10 8 end
11 9
12 10 it "should parse ok" do
13 11 @shpfile.record_count.should eql(2)
14 12 @shpfile.should have(1).fields
15   - @shpfile.shp_type.should eql(ShpType::POINT)
  13 + @shpfile.shp_type.should eql(GeoRuby::Shp4r::ShpType::POINT)
16 14 end
17 15
18 16 it "should parse fields" do
@@ -23,7 +21,7 @@
23 21
24 22 it "should parse record 1" do
25 23 rec = @shpfile[0]
26   - rec.geometry.should be_kind_of Point
  24 + rec.geometry.should be_kind_of GeoRuby::SimpleFeatures::Point
27 25 rec.geometry.x.should be_within(0.00001).of(-90.08375)
28 26 rec.geometry.y.should be_within(0.00001).of(34.39996)
29 27 rec.data["Hoyoyo"].should eql(6)
@@ -31,7 +29,7 @@
31 29
32 30 it "should parse record 2" do
33 31 rec = @shpfile[1]
34   - rec.geometry.should be_kind_of Point
  32 + rec.geometry.should be_kind_of GeoRuby::SimpleFeatures::Point
35 33 rec.geometry.x.should be_within(0.00001).of(-87.82580)
36 34 rec.geometry.y.should be_within(0.00001).of(33.36416)
37 35 rec.data["Hoyoyo"].should eql(9)
@@ -41,26 +39,26 @@
41 39
42 40 describe "Polyline" do
43 41 before(:each) do
44   - @shpfile = ShpFile.open(File.dirname(__FILE__) + '/../../data/polyline.shp')
  42 + @shpfile = GeoRuby::Shp4r::ShpFile.open(File.dirname(__FILE__) + '/../../data/polyline.shp')
45 43 end
46 44
47 45 it "should parse ok" do
48 46 @shpfile.record_count.should eql(1)
49 47 @shpfile.should have(1).fields
50   - @shpfile.shp_type.should eql(ShpType::POLYLINE)
  48 + @shpfile.shp_type.should eql(GeoRuby::Shp4r::ShpType::POLYLINE)
51 49 end
52 50
53 51 it "should parse fields" do
54 52 field = @shpfile.fields.first
55 53 field.name.should eql("Chipoto")
56   - # Dbf now uses the decimal to choose between int and float
  54 + # GeoRuby::Shp4r::Dbf now uses the decimal to choose between int and float
57 55 # So here is N instead of F
58 56 field.type.should eql("N")
59 57 end
60 58
61 59 it "should parse record 1" do
62 60 rec = @shpfile[0]
63   - rec.geometry.should be_kind_of MultiLineString
  61 + rec.geometry.should be_kind_of GeoRuby::SimpleFeatures::MultiLineString
64 62 rec.geometry.length.should eql(1)
65 63 rec.geometry[0].length.should eql(6)
66 64 rec.data["Chipoto"].should eql(5.678)
@@ -70,13 +68,13 @@
70 68
71 69 describe "Polygon" do
72 70 before(:each) do
73   - @shpfile = ShpFile.open(File.dirname(__FILE__) + '/../../data/polygon.shp')
  71 + @shpfile = GeoRuby::Shp4r::ShpFile.open(File.dirname(__FILE__) + '/../../data/polygon.shp')
74 72 end
75 73
76 74 it "should parse ok" do
77 75 @shpfile.record_count.should eql(1)
78 76 @shpfile.should have(1).fields
79   - @shpfile.shp_type.should eql(ShpType::POLYGON)
  77 + @shpfile.shp_type.should eql(GeoRuby::Shp4r::ShpType::POLYGON)
80 78 end
81 79
82 80 it "should parse fields" do
@@ -87,7 +85,7 @@
87 85
88 86 it "should parse record 1" do
89 87 rec = @shpfile[0]
90   - rec.geometry.should be_kind_of MultiPolygon
  88 + rec.geometry.should be_kind_of GeoRuby::SimpleFeatures::MultiPolygon
91 89 rec.geometry.length.should eql(1)
92 90 rec.geometry[0].length.should eql(1)
93 91 rec.geometry[0][0].length.should eql(7)
@@ -111,12 +109,12 @@ def rm_all_shp(file)
111 109 it "test_point" do
112 110 cp_all_shp(File.dirname(__FILE__) + '/../../data/point',
113 111 File.dirname(__FILE__) + '/../../data/point2')
114   - shpfile = ShpFile.open(File.dirname(__FILE__) + '/../../data/point2.shp')
  112 + shpfile = GeoRuby::Shp4r::ShpFile.open(File.dirname(__FILE__) + '/../../data/point2.shp')
115 113
116 114 shpfile.transaction do |tr|
117   - tr.should be_instance_of ShpTransaction
118   - tr.add(ShpRecord.new(Point.from_x_y(123.4,123.4),'Hoyoyo' => 5))
119   - tr.add(ShpRecord.new(Point.from_x_y(-16.67,16.41),'Hoyoyo' => -7))
  115 + tr.should be_instance_of GeoRuby::Shp4r::ShpTransaction
  116 + tr.add(GeoRuby::Shp4r::ShpRecord.new(GeoRuby::SimpleFeatures::Point.from_x_y(123.4,123.4),'Hoyoyo' => 5))
  117 + tr.add(GeoRuby::Shp4r::ShpRecord.new(GeoRuby::SimpleFeatures::Point.from_x_y(-16.67,16.41),'Hoyoyo' => -7))
120 118 tr.delete(1)
121 119 end
122 120
@@ -130,12 +128,12 @@ def rm_all_shp(file)
130 128 cp_all_shp(File.dirname(__FILE__) + '/../../data/polyline',
131 129 File.dirname(__FILE__) + '/../../data/polyline2')
132 130
133   - shpfile = ShpFile.open(File.dirname(__FILE__) + '/../../data/polyline2.shp')
  131 + shpfile = GeoRuby::Shp4r::ShpFile.open(File.dirname(__FILE__) + '/../../data/polyline2.shp')
134 132
135 133 shpfile.transaction do |tr|
136   - tr.should be_instance_of ShpTransaction
137   - tr.add(ShpRecord.new(LineString.from_coordinates([[123.4,123.4],[45.6,12.3]]),'Chipoto' => 5.6778))
138   - tr.add(ShpRecord.new(LineString.from_coordinates([[23.4,13.4],[45.6,12.3],[12,-67]]),'Chipoto' => -7.1))
  134 + tr.should be_instance_of GeoRuby::Shp4r::ShpTransaction
  135 + tr.add(GeoRuby::Shp4r::ShpRecord.new(GeoRuby::SimpleFeatures::LineString.from_coordinates([[123.4,123.4],[45.6,12.3]]),'Chipoto' => 5.6778))
  136 + tr.add(GeoRuby::Shp4r::ShpRecord.new(GeoRuby::SimpleFeatures::LineString.from_coordinates([[23.4,13.4],[45.6,12.3],[12,-67]]),'Chipoto' => -7.1))
139 137 tr.delete(0)
140 138 end
141 139
@@ -147,12 +145,12 @@ def rm_all_shp(file)
147 145 it "test_polygon" do
148 146 cp_all_shp(File.dirname(__FILE__) + '/../../data/polygon',
149 147 File.dirname(__FILE__) + '/../../data/polygon2')
150   - shpfile = ShpFile.open(File.dirname(__FILE__) + '/../../data/polygon2.shp')
  148 + shpfile = GeoRuby::Shp4r::ShpFile.open(File.dirname(__FILE__) + '/../../data/polygon2.shp')
151 149
152 150 shpfile.transaction do |tr|
153   - tr.should be_instance_of ShpTransaction
  151 + tr.should be_instance_of GeoRuby::Shp4r::ShpTransaction
154 152 tr.delete(0)
155   - tr.add(ShpRecord.new(Polygon.from_coordinates([[[0,0],[40,0],[40,40],[0,40],[0,0]],[[10,10],[10,20],[20,20],[10,10]]]),'Hello' => "oook"))
  153 + tr.add(GeoRuby::Shp4r::ShpRecord.new(GeoRuby::SimpleFeatures::Polygon.from_coordinates([[[0,0],[40,0],[40,40],[0,40],[0,0]],[[10,10],[10,20],[20,20],[10,10]]]),'Hello' => "oook"))
156 154 end
157 155
158 156 shpfile.record_count.should eql(1)
@@ -164,11 +162,11 @@ def rm_all_shp(file)
164 162 it "test_multipoint" do
165 163 cp_all_shp(File.dirname(__FILE__) + '/../../data/multipoint',
166 164 File.dirname(__FILE__) + '/../../data/multipoint2')
167   - shpfile = ShpFile.open(File.dirname(__FILE__) + '/../../data/multipoint2.shp')
  165 + shpfile = GeoRuby::Shp4r::ShpFile.open(File.dirname(__FILE__) + '/../../data/multipoint2.shp')
168 166
169 167 shpfile.transaction do |tr|
170   - tr.should be_instance_of ShpTransaction
171   - tr.add(ShpRecord.new(MultiPoint.from_coordinates([[45.6,-45.1],[12.4,98.2],[51.2,-0.12],[156.12345,56.109]]),'Hello' => 5,"Hoyoyo" => "AEZAE"))
  168 + tr.should be_instance_of GeoRuby::Shp4r::ShpTransaction
  169 + tr.add(GeoRuby::Shp4r::ShpRecord.new(GeoRuby::SimpleFeatures::MultiPoint.from_coordinates([[45.6,-45.1],[12.4,98.2],[51.2,-0.12],[156.12345,56.109]]),'Hello' => 5,"Hoyoyo" => "AEZAE"))
172 170 end
173 171
174 172 shpfile.record_count.should eql(2)
@@ -181,11 +179,11 @@ def rm_all_shp(file)
181 179 cp_all_shp(File.dirname(__FILE__) + '/../../data/polygon',
182 180 File.dirname(__FILE__) + '/../../data/polygon4')
183 181
184   - shpfile = ShpFile.open(File.dirname(__FILE__) + '/../../data/polygon4.shp')
  182 + shpfile = GeoRuby::Shp4r::ShpFile.open(File.dirname(__FILE__) + '/../../data/polygon4.shp')
185 183
186 184 shpfile.transaction do |tr|
187   - tr.should be_instance_of ShpTransaction
188   - tr.add(ShpRecord.new(MultiPolygon.from_polygons([Polygon.from_coordinates([[[0,0],[40,0],[40,40],[0,40],[0,0]],[[10,10],[10,20],[20,20],[10,10]]])]),'Hello' => "oook"))
  185 + tr.should be_instance_of GeoRuby::Shp4r::ShpTransaction
  186 + tr.add(GeoRuby::Shp4r::ShpRecord.new(GeoRuby::SimpleFeatures::MultiPolygon.from_polygons([GeoRuby::SimpleFeatures::Polygon.from_coordinates([[[0,0],[40,0],[40,40],[0,40],[0,0]],[[10,10],[10,20],[20,20],[10,10]]])]),'Hello' => "oook"))
189 187 end
190 188
191 189 shpfile.record_count.should eql(2)
@@ -199,11 +197,11 @@ def rm_all_shp(file)
199 197 cp_all_shp(File.dirname(__FILE__) + '/../../data/polygon',
200 198 File.dirname(__FILE__) + '/../../data/polygon5')
201 199
202   - shpfile = ShpFile.open(File.dirname(__FILE__) + '/../../data/polygon5.shp')
  200 + shpfile = GeoRuby::Shp4r::ShpFile.open(File.dirname(__FILE__) + '/../../data/polygon5.shp')
203 201
204 202 shpfile.transaction do |tr|
205   - tr.should be_instance_of ShpTransaction
206   - tr.add(ShpRecord.new(MultiPolygon.from_polygons([Polygon.from_coordinates([[[0,0],[40,0],[40,40],[0,40],[0,0]],[[10,10],[10,20],[20,20],[10,10]]])]),'Hello' => "oook"))
  203 + tr.should be_instance_of GeoRuby::Shp4r::ShpTransaction
  204 + tr.add(GeoRuby::Shp4r::ShpRecord.new(GeoRuby::SimpleFeatures::MultiPolygon.from_polygons([GeoRuby::SimpleFeatures::Polygon.from_coordinates([[[0,0],[40,0],[40,40],[0,40],[0,0]],[[10,10],[10,20],[20,20],[10,10]]])]),'Hello' => "oook"))
207 205 tr.rollback
208 206 end
209 207 shpfile.record_count.should eql(1)
@@ -215,9 +213,9 @@ def rm_all_shp(file)
215 213 end
216 214
217 215 it "test_creation" do
218   - shpfile = ShpFile.create(File.dirname(__FILE__) + '/../../data/point3.shp',ShpType::POINT,[Dbf::Field.new("Hoyoyo","C",10,0)])
  216 + shpfile = GeoRuby::Shp4r::ShpFile.create(File.dirname(__FILE__) + '/../../data/point3.shp',GeoRuby::Shp4r::ShpType::POINT,[GeoRuby::Shp4r::Dbf::Field.new("Hoyoyo","C",10,0)])
219 217 shpfile.transaction do |tr|
220   - tr.add(ShpRecord.new(Point.from_x_y(123,123.4),'Hoyoyo' => "HJHJJ"))
  218 + tr.add(GeoRuby::Shp4r::ShpRecord.new(GeoRuby::SimpleFeatures::Point.from_x_y(123,123.4),'Hoyoyo' => "HJHJJ"))
221 219 end
222 220 shpfile.record_count.should eql(1)
223 221 shpfile.close
@@ -225,9 +223,9 @@ def rm_all_shp(file)
225 223 end
226 224
227 225 it "test_creation_multipoint" do
228   - shpfile = ShpFile.create(File.dirname(__FILE__) + '/../../data/multipoint3.shp',ShpType::MULTIPOINT,[Dbf::Field.new("Hoyoyo","C",10),Dbf::Field.new("Hello","N",10)])
  226 + shpfile = GeoRuby::Shp4r::ShpFile.create(File.dirname(__FILE__) + '/../../data/multipoint3.shp',GeoRuby::Shp4r::ShpType::MULTIPOINT,[GeoRuby::Shp4r::Dbf::Field.new("Hoyoyo","C",10),GeoRuby::Shp4r::Dbf::Field.new("Hello","N",10)])
229 227 shpfile.transaction do |tr|
230   - tr.add(ShpRecord.new(MultiPoint.from_coordinates([[123,123.4],[345,12.2]]),'Hoyoyo' => "HJHJJ","Hello" => 5))
  228 + tr.add(GeoRuby::Shp4r::ShpRecord.new(GeoRuby::SimpleFeatures::MultiPoint.from_coordinates([[123,123.4],[345,12.2]]),'Hoyoyo' => "HJHJJ","Hello" => 5))
231 229 end
232 230 shpfile.record_count.should eql(1)
233 231 shpfile.close
8 spec/geo_ruby/simple_features/circle_spec.rb
... ... @@ -1,16 +1,14 @@
1 1 # -*- coding: utf-8 -*-
2 2 require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
3 3
4   -describe Circle do
  4 +describe GeoRuby::SimpleFeatures::Circle do
5 5
6 6 it "should instantiate" do
7   - Circle.new.should be_kind_of Geometry
  7 + subject.should be_kind_of GeoRuby::SimpleFeatures::Geometry
8 8 end
9 9
10   -
11 10 describe "Instance" do
12   - let(:circle) { Circle.new(4326) }
  11 + let(:circle) { GeoRuby::SimpleFeatures::Circle.new(4326) }
13 12 end
14 13
15   -
16 14 end
16 spec/geo_ruby/simple_features/envelope_spec.rb
... ... @@ -1,29 +1,29 @@
1 1 require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2 2
3   -describe Envelope do
  3 +describe GeoRuby::SimpleFeatures::Envelope do
4 4 before(:each) do
5 5 @srid = 4269
6   - @env = Envelope.from_points([Point.from_x_y(10,20, @srid),Point.from_x_y(20,30, @srid)], @srid)
  6 + @env = GeoRuby::SimpleFeatures::Envelope.from_points([GeoRuby::SimpleFeatures::Point.from_x_y(10,20, @srid),GeoRuby::SimpleFeatures::Point.from_x_y(20,30, @srid)], @srid)
7 7 end
8 8
9 9 it "should initialize" do
10   - @env.should be_instance_of(Envelope)
  10 + @env.should be_instance_of(GeoRuby::SimpleFeatures::Envelope)
11 11 end
12 12
13 13 it "converted tu" do
14   - linear_ring = LinearRing.from_coordinates([[12.4,-45.3],[45.4,41.6],[4.456,1.0698],[12.4,-45.3]],256)
15   - polygon = Polygon.from_linear_rings([linear_ring],256)
  14 + linear_ring = GeoRuby::SimpleFeatures::LinearRing.from_coordinates([[12.4,-45.3],[45.4,41.6],[4.456,1.0698],[12.4,-45.3]],256)
  15 + polygon = GeoRuby::SimpleFeatures::Polygon.from_linear_rings([linear_ring],256)
16 16 e = polygon.envelope
17 17
18   - e.lower_corner.class.should eql(Point)
19   - e.upper_corner.class.should eql(Point)
  18 + e.lower_corner.class.should eql(GeoRuby::SimpleFeatures::Point)
  19 + e.upper_corner.class.should eql(GeoRuby::SimpleFeatures::Point)
20 20
21 21 e.lower_corner.x.should eql(4.456)
22 22 e.lower_corner.y.should eql(-45.3)
23 23 e.upper_corner.x.should eql(45.4)
24 24 e.upper_corner.y.should eql(41.6)
25 25
26   - line_string = LineString.from_coordinates([[13.6,-49.3],[45.4,44.6],[14.2,1.09],[13.6,-49.3]],256)
  26 + line_string = GeoRuby::SimpleFeatures::LineString.from_coordinates([[13.6,-49.3],[45.4,44.6],[14.2,1.09],[13.6,-49.3]],256)
27 27 e2 = line_string.envelope
28 28
29 29 e3 = e.extend(e2)
90 spec/geo_ruby/simple_features/ewkb_parser_spec.rb
... ... @@ -1,106 +1,106 @@
1 1 require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2 2
3   -describe EWKBParser do
  3 +describe GeoRuby::SimpleFeatures::EWKBParser do
4 4
5 5 before(:each) do
6   - @factory = GeometryFactory::new
7   - @hex_ewkb_parser = HexEWKBParser::new(@factory)
  6 + @factory = GeoRuby::SimpleFeatures::GeometryFactory::new
  7 + @hex_ewkb_parser = GeoRuby::SimpleFeatures::HexEWKBParser::new(@factory)
8 8 end
9 9
10 10 it "test_point2d" do
11 11 @hex_ewkb_parser.parse("01010000207B000000CDCCCCCCCCCC28406666666666A64640")
12 12 point = @factory.geometry
13   - point.should be_instance_of Point
14   - point.should == Point.from_x_y(12.4,45.3,123)
  13 + point.should be_instance_of GeoRuby::SimpleFeatures::Point
  14 + point.should == GeoRuby::SimpleFeatures::Point.from_x_y(12.4,45.3,123)
15 15 end
16 16
17 17 it "test_point2d_BigEndian" do
18 18 @hex_ewkb_parser.parse("00000000014013A035BD512EC7404A3060C38F3669")
19 19 point = @factory.geometry
20   - point.should be_instance_of Point
21   - point.should == Point.from_x_y(4.906455,52.377953)
  20 + point.should be_instance_of GeoRuby::SimpleFeatures::Point
  21 + point.should == GeoRuby::SimpleFeatures::Point.from_x_y(4.906455,52.377953)
22 22 end
23 23
24 24 it "test_point3dz" do
25 25 @hex_ewkb_parser.parse("01010000A07B000000CDCCCCCCCCCC28406666666666A646400000000000000CC0")
26 26 point = @factory.geometry
27   - point.should be_instance_of Point
28   - point.should == Point.from_x_y_z(12.4,45.3,-3.5,123)
  27 + point.should be_instance_of GeoRuby::SimpleFeatures::Point
  28 + point.should == GeoRuby::SimpleFeatures::Point.from_x_y_z(12.4,45.3,-3.5,123)
29 29 end
30 30
31 31 it "test_point4d" do
32 32 @hex_ewkb_parser.parse("01010000E07B000000CDCCCCCCCCCC28406666666666A646400000000000000CC00000000000002E40")
33 33 point = @factory.geometry
34   - point.should be_instance_of Point
35   - point.should == Point.from_x_y_z_m(12.4,45.3,-3.5,15,123)
  34 + point.should be_instance_of GeoRuby::SimpleFeatures::Point
  35 + point.should == GeoRuby::SimpleFeatures::Point.from_x_y_z_m(12.4,45.3,-3.5,15,123)
36 36 end
37 37
38 38 it "test_line_string" do
39 39 @hex_ewkb_parser.parse("01020000200001000002000000CDCCCCCCCCCC28406666666666A646C03333333333B34640CDCCCCCCCCCC4440")
40 40 line_string = @factory.geometry
41   - line_string.should be_instance_of LineString
42   - line_string.should == LineString.from_coordinates([[12.4,-45.3],[45.4,41.6]],256)
  41 + line_string.should be_instance_of GeoRuby::SimpleFeatures::LineString
  42 + line_string.should == GeoRuby::SimpleFeatures::LineString.from_coordinates([[12.4,-45.3],[45.4,41.6]],256)
43 43
44 44 @hex_ewkb_parser.parse("01020000A00001000002000000CDCCCCCCCCCC28406666666666A646C06666666666A641403333333333B34640CDCCCCCCCCCC44409A99999999992840")
45 45 line_string = @factory.geometry
46   - line_string.should be_instance_of LineString
47   - line_string.should == LineString.from_coordinates([[12.4,-45.3,35.3],[45.4,41.6,12.3]],256,true)
  46 + line_string.should be_instance_of GeoRuby::SimpleFeatures::LineString
  47 + line_string.should == GeoRuby::SimpleFeatures::LineString.from_coordinates([[12.4,-45.3,35.3],[45.4,41.6,12.3]],256,true)
48 48
49 49 @hex_ewkb_parser.parse("01020000E00001000002000000CDCCCCCCCCCC28406666666666A646C06666666666A64140CDCCCCCCCC8C46403333333333B34640CDCCCCCCCCCC44409A999999999928403D0AD7A3701D4440")
50 50 line_string = @factory.geometry
51   - line_string.should be_instance_of LineString
52   - line_string.should == LineString.from_coordinates([[12.4,-45.3,35.3,45.1],[45.4,41.6,12.3,40.23]],256,true,true)
  51 + line_string.should be_instance_of GeoRuby::SimpleFeatures::LineString
  52 + line_string.should == GeoRuby::SimpleFeatures::LineString.from_coordinates([[12.4,-45.3,35.3,45.1],[45.4,41.6,12.3,40.23]],256,true,true)
53 53 end
54 54
55 55 it "test_polygon" do
56 56 @hex_ewkb_parser.parse("0103000020000100000200000005000000000000000000000000000000000000000000000000001040000000000000000000000000000010400000000000001040000000000000000000000000000010400000000000000000000000000000000005000000000000000000F03F000000000000F03F0000000000000840000000000000F03F00000000000008400000000000000840000000000000F03F0000000000000840000000000000F03F000000000000F03F")
57 57 polygon = @factory.geometry
58   - polygon.should be_instance_of Polygon
59   - polygon.should == Polygon.from_coordinates([[[0,0],[4,0],[4,4],[0,4],[0,0]],[[1,1],[3,1],[3,3],[1,3],[1,1]]],256)
  58 + polygon.should be_instance_of GeoRuby::SimpleFeatures::Polygon
  59 + polygon.should == GeoRuby::SimpleFeatures::Polygon.from_coordinates([[[0,0],[4,0],[4,4],[0,4],[0,0]],[[1,1],[3,1],[3,3],[1,3],[1,1]]],256)
60 60
61 61 @hex_ewkb_parser.parse("01030000A000010000020000000500000000000000000000000000000000000000000000000000004000000000000010400000000000000000000000000000004000000000000010400000000000001040000000000000004000000000000000000000000000001040000000000000004000000000000000000000000000000000000000000000004005000000000000000000F03F000000000000F03F00000000000000400000000000000840000000000000F03F0000000000000040000000000000084000000000000008400000000000000040000000000000F03F00000000000008400000000000000040000000000000F03F000000000000F03F0000000000000040")
62 62 polygon = @factory.geometry
63   - polygon.should be_instance_of Polygon
64   - polygon.should == Polygon.from_coordinates([[[0,0,2],[4,0,2],[4,4,2],[0,4,2],[0,0,2]],[[1,1,2],[3,1,2],[3,3,2],[1,3,2],[1,1,2]]],256,true)
  63 + polygon.should be_instance_of GeoRuby::SimpleFeatures::Polygon
  64 + polygon.should == GeoRuby::SimpleFeatures::Polygon.from_coordinates([[[0,0,2],[4,0,2],[4,4,2],[0,4,2],[0,0,2]],[[1,1,2],[3,1,2],[3,3,2],[1,3,2],[1,1,2]]],256,true)
65 65
66 66 @hex_ewkb_parser.parse("010300006000010000020000000500000000000000000000000000000000000000000000000000004000000000000010400000000000000000000000000000004000000000000010400000000000001040000000000000004000000000000000000000000000001040000000000000004000000000000000000000000000000000000000000000004005000000000000000000F03F000000000000F03F00000000000000400000000000000840000000000000F03F0000000000000040000000000000084000000000000008400000000000000040000000000000F03F00000000000008400000000000000040000000000000F03F000000000000F03F0000000000000040")
67 67 polygon = @factory.geometry
68   - polygon.should be_instance_of Polygon
69   - polygon.should == Polygon.from_coordinates([[[0,0,2],[4,0,2],[4,4,2],[0,4,2],[0,0,2]],[[1,1,2],[3,1,2],[3,3,2],[1,3,2],[1,1,2]]],256,false,true)
  68 + polygon.should be_instance_of GeoRuby::SimpleFeatures::Polygon
  69 + polygon.should == GeoRuby::SimpleFeatures::Polygon.from_coordinates([[[0,0,2],[4,0,2],[4,4,2],[0,4,2],[0,0,2]],[[1,1,2],[3,1,2],[3,3,2],[1,3,2],[1,1,2]]],256,false,true)
70 70
71 71 @hex_ewkb_parser.parse("01030000E0000100000200000005000000000000000000000000000000000000000000000000000040CDCCCCCCCC8C46C00000000000001040000000000000000000000000000000400000000000001440000000000000104000000000000010400000000000000040AE47E17A14AE1240000000000000000000000000000010400000000000000040713D0AD7A370F53F000000000000000000000000000000000000000000000040CDCCCCCCCC8C46C005000000000000000000F03F000000000000F03F00000000000000409A999999999928400000000000000840000000000000F03F00000000000000400000000000C05E400000000000000840000000000000084000000000000000406666666666662840000000000000F03F000000000000084000000000000000400000000000002840000000000000F03F000000000000F03F00000000000000409A99999999992840")
72 72 polygon = @factory.geometry
73   - polygon.should be_instance_of Polygon
74   - polygon.should == Polygon.from_coordinates([[[0,0,2,-45.1],[4,0,2,5],[4,4,2,4.67],[0,4,2,1.34],[0,0,2,-45.1]],[[1,1,2,12.3],[3,1,2,123],[3,3,2,12.2],[1,3,2,12],[1,1,2,12.3]]],256,true,true)
  73 + polygon.should be_instance_of GeoRuby::SimpleFeatures::Polygon
  74 + polygon.should == GeoRuby::SimpleFeatures::Polygon.from_coordinates([[[0,0,2,-45.1],[4,0,2,5],[4,4,2,4.67],[0,4,2,1.34],[0,0,2,-45.1]],[[1,1,2,12.3],[3,1,2,123],[3,3,2,12.2],[1,3,2,12],[1,1,2,12.3]]],256,true,true)
75 75 end
76 76
77 77 it "test_geometry_collection" do
78 78 @hex_ewkb_parser.parse("010700002000010000020000000101000000AE47E17A14AE12403333333333B34640010200000002000000CDCCCCCCCCCC16406666666666E628403333333333E350400000000000004B40")
79 79 geometry_collection = @factory.geometry
80   - geometry_collection.should be_instance_of GeometryCollection
  80 + geometry_collection.should be_instance_of GeoRuby::SimpleFeatures::GeometryCollection
81 81
82   - geometry_collection.should == GeometryCollection.from_geometries([Point.from_x_y(4.67,45.4,256),LineString.from_coordinates([[5.7,12.45],[67.55,54]],256)],256)
  82 + geometry_collection.should == GeoRuby::SimpleFeatures::GeometryCollection.from_geometries([GeoRuby::SimpleFeatures::Point.from_x_y(4.67,45.4,256),GeoRuby::SimpleFeatures::LineString.from_coordinates([[5.7,12.45],[67.55,54]],256)],256)
83 83 geometry_collection[0].srid.should eql(256)
84 84
85 85 @hex_ewkb_parser.parse("01070000E0000100000200000001010000C0AE47E17A14AE12403333333333B34640F6285C8FC2D54640666666666666024001020000C002000000CDCCCCCCCCCC16406666666666E628403D0AD7A3703D124033333333339358403333333333E350400000000000004B4066666666666628403333333333330B40")
86 86 geometry_collection = @factory.geometry
87   - geometry_collection.should be_instance_of GeometryCollection
88   - geometry_collection.should == GeometryCollection.from_geometries([Point.from_x_y_z_m(4.67,45.4,45.67,2.3,256),LineString.from_coordinates([[5.7,12.45,4.56,98.3],[67.55,54,12.2,3.4]],256,true, true)],256,true, true)
  87 + geometry_collection.should be_instance_of GeoRuby::SimpleFeatures::GeometryCollection
  88 + geometry_collection.should == GeoRuby::SimpleFeatures::GeometryCollection.from_geometries([GeoRuby::SimpleFeatures::Point.from_x_y_z_m(4.67,45.4,45.67,2.3,256),GeoRuby::SimpleFeatures::LineString.from_coordinates([[5.7,12.45,4.56,98.3],[67.55,54,12.2,3.4]],256,true, true)],256,true, true)
89 89 geometry_collection[0].srid.should eql(256)
90 90 end
91 91
92 92 it "test_multi_point" do
93 93 @hex_ewkb_parser.parse("0104000020BC010000030000000101000000CDCCCCCCCCCC28403333333333D35EC0010100000066666666664650C09A99999999D95E4001010000001F97DD388EE35E400000000000C05E40")
94 94 multi_point = @factory.geometry
95   - multi_point.should be_instance_of MultiPoint
96   - multi_point.should == MultiPoint.from_coordinates([[12.4,-123.3],[-65.1,123.4],[123.55555555,123]],444)
  95 + multi_point.should be_instance_of GeoRuby::SimpleFeatures::MultiPoint
  96 + multi_point.should == GeoRuby::SimpleFeatures::MultiPoint.from_coordinates([[12.4,-123.3],[-65.1,123.4],[123.55555555,123]],444)
97 97 multi_point.srid.should eql(444)
98 98 multi_point[0].srid.should eql(444)
99 99
100 100 @hex_ewkb_parser.parse("01040000A0BC010000030000000101000080CDCCCCCCCCCC28403333333333D35EC00000000000001240010100008066666666664650C09A99999999D95E40333333333333F33F01010000801F97DD388EE35E400000000000C05E406666666666660240")
101 101 multi_point = @factory.geometry
102   - multi_point.should be_instance_of MultiPoint
103   - multi_point.should == MultiPoint.from_coordinates([[12.4,-123.3,4.5],[-65.1,123.4,1.2],[123.55555555,123,2.3]],444,true)
  102 + multi_point.should be_instance_of GeoRuby::SimpleFeatures::MultiPoint
  103 + multi_point.should == GeoRuby::SimpleFeatures::MultiPoint.from_coordinates([[12.4,-123.3,4.5],[-65.1,123.4,1.2],[123.55555555,123,2.3]],444,true)
104 104 multi_point.srid.should eql(444)
105 105 multi_point[0].srid.should eql(444)
106 106 end
@@ -108,15 +108,15 @@
108 108 it "test_multi_line_string" do
109 109 @hex_ewkb_parser.parse("01050000200001000002000000010200000002000000000000000000F83F9A99999999994640E4BD6A65C20F4BC0FA7E6ABC749388BF010200000003000000000000000000F83F9A99999999994640E4BD6A65C20F4BC0FA7E6ABC749388BF39B4C876BE8F46403333333333D35E40")
110 110 multi_line_string = @factory.geometry
111   - multi_line_string.should be_instance_of MultiLineString
112   - multi_line_string.should == MultiLineString.from_line_strings([LineString.from_coordinates([[1.5,45.2],[-54.12312,-0.012]],256),LineString.from_coordinates([[1.5,45.2],[-54.12312,-0.012],[45.123,123.3]],256)],256)
  111 + multi_line_string.should be_instance_of GeoRuby::SimpleFeatures::MultiLineString
  112 + multi_line_string.should == GeoRuby::SimpleFeatures::MultiLineString.from_line_strings([GeoRuby::SimpleFeatures::LineString.from_coordinates([[1.5,45.2],[-54.12312,-0.012]],256),GeoRuby::SimpleFeatures::LineString.from_coordinates([[1.5,45.2],[-54.12312,-0.012],[45.123,123.3]],256)],256)
113 113 multi_line_string.srid.should eql(256)
114 114 multi_line_string[0].srid.should eql(256)
115 115
116 116 @hex_ewkb_parser.parse("0105000020000100000200000001020000C002000000000000000000F83F9A99999999994640CDCCCCCCCCCCF43F333333333333F33FE4BD6A65C20F4BC0FA7E6ABC749388BF333333333333F33F000000000000124001020000C003000000000000000000F83F9A99999999994640666666666666144000000000000012C0E4BD6A65C20F4BC0FA7E6ABC749388BF3333333333331BC03333333333330B4039B4C876BE8F46403333333333D35E40000000000000124033333333333315C0")
117 117 multi_line_string = @factory.geometry
118   - multi_line_string.should be_instance_of MultiLineString
119   - multi_line_string.should == MultiLineString.from_line_strings([LineString.from_coordinates([[1.5,45.2,1.3,1.2],[-54.12312,-0.012,1.2,4.5]],256,true,true),LineString.from_coordinates([[1.5,45.2,5.1,-4.5],[-54.12312,-0.012,-6.8,3.4],[45.123,123.3,4.5,-5.3]],256,true,true)],256,true,true)
  118 + multi_line_string.should be_instance_of GeoRuby::SimpleFeatures::MultiLineString
  119 + multi_line_string.should == GeoRuby::SimpleFeatures::MultiLineString.from_line_strings([GeoRuby::SimpleFeatures::LineString.from_coordinates([[1.5,45.2,1.3,1.2],[-54.12312,-0.012,1.2,4.5]],256,true,true),GeoRuby::SimpleFeatures::LineString.from_coordinates([[1.5,45.2,5.1,-4.5],[-54.12312,-0.012,-6.8,3.4],[45.123,123.3,4.5,-5.3]],256,true,true)],256,true,true)
120 120 multi_line_string.srid.should eql(256)
121 121 multi_line_string[0].srid.should eql(256)
122 122 end
@@ -124,15 +124,15 @@
124 124 it "test_multi_polygon" do
125 125 @hex_ewkb_parser.parse("0106000020000100000200000001030000000200000004000000CDCCCCCCCCCC28406666666666A646C03333333333B34640CDCCCCCCCCCC44406DE7FBA9F1D211403D2CD49AE61DF13FCDCCCCCCCCCC28406666666666A646C004000000333333333333034033333333333315409A999999999915408A8EE4F21FD2F63FEC51B81E85EB2C40F6285C8FC2F5F03F3333333333330340333333333333154001030000000200000005000000000000000000000000000000000000000000000000001040000000000000000000000000000010400000000000001040000000000000000000000000000010400000000000000000000000000000000005000000000000000000F03F000000000000F03F0000000000000840000000000000F03F00000000000008400000000000000840000000000000F03F0000000000000840000000000000F03F000000000000F03F")
126 126 multi_polygon = @factory.geometry
127   - multi_polygon.should be_instance_of MultiPolygon
128   - multi_polygon.should == MultiPolygon.from_polygons([Polygon.from_coordinates([[[12.4,-45.3],[45.4,41.6],[4.456,1.0698],[12.4,-45.3]],[[2.4,5.3],[5.4,1.4263],[14.46,1.06],[2.4,5.3]]],256),Polygon.from_coordinates([[[0,0],[4,0],[4,4],[0,4],[0,0]],[[1,1],[3,1],[3,3],[1,3],[1,1]]],256)],256)
  127 + multi_polygon.should be_instance_of GeoRuby::SimpleFeatures::MultiPolygon
  128 + multi_polygon.should == GeoRuby::SimpleFeatures::MultiPolygon.from_polygons([GeoRuby::SimpleFeatures::Polygon.from_coordinates([[[12.4,-45.3],[45.4,41.6],[4.456,1.0698],[12.4,-45.3]],[[2.4,5.3],[5.4,1.4263],[14.46,1.06],[2.4,5.3]]],256),GeoRuby::SimpleFeatures::Polygon.from_coordinates([[[0,0],[4,0],[4,4],[0,4],[0,0]],[[1,1],[3,1],[3,3],[1,3],[1,1]]],256)],256)
129 129 multi_polygon.srid.should eql(256)
130 130 multi_polygon[0].srid.should eql(256)
131 131
132 132 @hex_ewkb_parser.parse("0106000020000100000200000001030000400200000004000000CDCCCCCCCCCC28406666666666A646C0333333333333F33F3333333333B34640CDCCCCCCCCCC4440333333333333F33F6DE7FBA9F1D211403D2CD49AE61DF13F333333333333F33FCDCCCCCCCCCC28406666666666A646C0333333333333F33F0400000033333333333303403333333333331540333333333333F33F9A999999999915408A8EE4F21FD2F63F333333333333F33FEC51B81E85EB2C40F6285C8FC2F5F03F333333333333F33F33333333333303403333333333331540333333333333F33F0103000040020000000500000000000000000000000000000000000000333333333333F33F00000000000010400000000000000000333333333333F33F00000000000010400000000000001040666666666666024000000000000000000000000000001040333333333333F33F00000000000000000000000000000000333333333333F33F05000000000000000000F03F000000000000F03F9A999999999901400000000000000840000000000000F03F6666666666660A40000000000000084000000000000008409A9999999999F13F000000000000F03F00000000000008403333333333330340000000000000F03F000000000000F03F9A99999999990140")
133 133 multi_polygon = @factory.geometry
134   - multi_polygon.should be_instance_of MultiPolygon
135   - multi_polygon.should == MultiPolygon.from_polygons([Polygon.from_coordinates([[[12.4,-45.3,1.2],[45.4,41.6,1.2],[4.456,1.0698,1.2],[12.4,-45.3,1.2]],[[2.4,5.3,1.2],[5.4,1.4263,1.2],[14.46,1.06,1.2],[2.4,5.3,1.2]]],256,false,true),Polygon.from_coordinates([[[0,0,1.2],[4,0,1.2],[4,4,2.3],[0,4,1.2],[0,0,1.2]],[[1,1,2.2],[3,1,3.3],[3,3,1.1],[1,3,2.4],[1,1,2.2]]],256,false,true)],256,false,true)
  134 + multi_polygon.should be_instance_of GeoRuby::SimpleFeatures::MultiPolygon
  135 + multi_polygon.should == GeoRuby::SimpleFeatures::MultiPolygon.from_polygons([GeoRuby::SimpleFeatures::Polygon.from_coordinates([[[12.4,-45.3,1.2],[45.4,41.6,1.2],[4.456,1.0698,1.2],[12.4,-45.3,1.2]],[[2.4,5.3,1.2],[5.4,1.4263,1.2],[14.46,1.06,1.2],[2.4,5.3,1.2]]],256,false,true),GeoRuby::SimpleFeatures::Polygon.from_coordinates([[[0,0,1.2],[4,0,1.2],[4,4,2.3],[0,4,1.2],[0,0,1.2]],[[1,1,2.2],[3,1,3.3],[3,3,1.1],[1,3,2.4],[1,1,2.2]]],256,false,true)],256,false,true)
136 136 multi_polygon.srid.should eql(256)
137 137 multi_polygon[0].srid.should eql(256)
138 138 end
@@ -140,19 +140,19 @@
140 140
141 141 it "test_failure_trailing_data" do
142 142 #added A345 at the end
143   - lambda {@hex_ewkb_parser.parse("01010000207B000000CDCCCCCCCCCC28406666666666A64640A345")}.should raise_error(EWKBFormatError)
  143 + lambda {@hex_ewkb_parser.parse("01010000207B000000CDCCCCCCCCCC28406666666666A64640A345")}.should raise_error(GeoRuby::SimpleFeatures::EWKBFormatError)
144 144 end
145 145
146 146 it "test_failure_unknown_geometry_type" do
147   - lambda {@hex_ewkb_parser.parse("01090000207B000000CDCCCCCCCCCC28406666666666A64640")}.should raise_error(EWKBFormatError)
  147 + lambda {@hex_ewkb_parser.parse("01090000207B000000CDCCCCCCCCCC28406666666666A64640")}.should raise_error(GeoRuby::SimpleFeatures::EWKBFormatError)
148 148 end
149 149
150 150 it "test_failure_m" do
151   - lambda {@hex_ewkb_parser.parse("01010000607B000000CDCCCCCCCCCC28406666666666A64640")}.should raise_error(EWKBFormatError)
  151 + lambda {@hex_ewkb_parser.parse("01010000607B000000CDCCCCCCCCCC28406666666666A64640")}.should raise_error(GeoRuby::SimpleFeatures::EWKBFormatError)
152 152 end
153 153
154 154 it "test_failure_truncated_data" do
155   - lambda {@hex_ewkb_parser.parse("01010000207B000000CDCCCCCCCCCC2840666666")}.should raise_error(EWKBFormatError)
  155 + lambda {@hex_ewkb_parser.parse("01010000207B000000CDCCCCCCCCCC2840666666")}.should raise_error(GeoRuby::SimpleFeatures::EWKBFormatError)
156 156 end
157 157
158 158 end
98 spec/geo_ruby/simple_features/ewkt_parser_spec.rb
... ... @@ -1,26 +1,26 @@
1 1 require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2 2
3   -describe EWKTParser do
  3 +describe GeoRuby::SimpleFeatures::EWKTParser do
4 4
5 5 before(:each) do
6   - @factory = GeometryFactory::new
7   - @ewkt_parser = EWKTParser::new(@factory)
  6 + @factory = GeoRuby::SimpleFeatures::GeometryFactory::new
  7 + @ewkt_parser = GeoRuby::SimpleFeatures::EWKTParser::new(@factory)
8 8 end
9 9
10 10 it "test_point" do
11 11 ewkt="POINT( 3.456 0.123)"
12 12 @ewkt_parser.parse(ewkt)
13 13 point = @factory.geometry
14   - point.should be_instance_of Point
15   - point.should == Point.from_x_y(3.456,0.123)
  14 + point.should be_instance_of GeoRuby::SimpleFeatures::Point
  15 + point.should == GeoRuby::SimpleFeatures::Point.from_x_y(3.456,0.123)
16 16 end
17 17
18 18 it "test_point_with_srid" do
19 19 ewkt="SRID=245;POINT(0.0 2.0)"
20 20 @ewkt_parser.parse(ewkt)
21 21 point = @factory.geometry
22   - point.should be_instance_of Point
23   - point.should == Point.from_x_y(0,2,245)
  22 + point.should be_instance_of GeoRuby::SimpleFeatures::Point
  23 + point.should == GeoRuby::SimpleFeatures::Point.from_x_y(0,2,245)
24 24 point.srid.should eql(245)
25 25 ewkt.should == point.as_ewkt(true,false)
26 26 end
@@ -29,8 +29,8 @@
29 29 ewkt="POINT(3.456 0.123 123.667)"
30 30 @ewkt_parser.parse(ewkt)
31 31 point = @factory.geometry
32   - point.should be_instance_of Point
33   - point.should == Point.from_x_y_z(3.456,0.123,123.667)
  32 + point.should be_instance_of GeoRuby::SimpleFeatures::Point
  33 + point.should == GeoRuby::SimpleFeatures::Point.from_x_y_z(3.456,0.123,123.667)
34 34 ewkt.should == point.as_ewkt(false)
35 35 end
36 36
@@ -38,8 +38,8 @@
38 38 ewkt="POINTM(3.456 0.123 123.667)"
39 39 @ewkt_parser.parse(ewkt)
40 40 point = @factory.geometry
41   - point.should be_instance_of Point
42   - point.should == Point.from_x_y_m(3.456,0.123,123.667)
  41 + point.should be_instance_of GeoRuby::SimpleFeatures::Point
  42 + point.should == GeoRuby::SimpleFeatures::Point.from_x_y_m(3.456,0.123,123.667)
43 43 ewkt.should == point.as_ewkt(false)
44 44 end
45 45
@@ -47,8 +47,8 @@
47 47 ewkt="POINT(3.456 0.123 123.667 15.0)"
48 48 @ewkt_parser.parse(ewkt)
49 49 point = @factory.geometry
50   - point.should be_instance_of Point
51   - point.should == Point.from_x_y_z_m(3.456,0.123,123.667,15.0)
  50 + point.should be_instance_of GeoRuby::SimpleFeatures::Point
  51 + point.should == GeoRuby::SimpleFeatures::Point.from_x_y_z_m(3.456,0.123,123.667,15.0)
52 52 ewkt.should == point.as_ewkt(false)
53 53 end
54 54
@@ -56,73 +56,73 @@
56 56 it "test_linestring" do
57 57 @ewkt_parser.parse("LINESTRING(3.456 0.123,123.44 123.56,54555.22 123.3)")
58 58 line_string = @factory.geometry
59   - line_string.should be_instance_of LineString
60   - line_string.should == LineString.from_coordinates([[3.456,0.123],[123.44,123.56],[54555.22,123.3]])
  59 + line_string.should be_instance_of GeoRuby::SimpleFeatures::LineString
  60 + line_string.should == GeoRuby::SimpleFeatures::LineString.from_coordinates([[3.456,0.123],[123.44,123.56],[54555.22,123.3]])
61 61
62 62 @ewkt_parser.parse("SRID=256;LINESTRING(12.4 -45.3,45.4 41.6)")
63 63 line_string = @factory.geometry
64   - line_string.should be_instance_of LineString
65   - line_string.should == LineString.from_coordinates([[12.4,-45.3],[45.4,41.6]],256)
  64 + line_string.should be_instance_of GeoRuby::SimpleFeatures::LineString
  65 + line_string.should == GeoRuby::SimpleFeatures::LineString.from_coordinates([[12.4,-45.3],[45.4,41.6]],256)
66 66
67 67 @ewkt_parser.parse("SRID=256;LINESTRING(12.4 -45.3 35.3,45.4 41.6 12.3)")
68 68 line_string = @factory.geometry
69   - line_string.should be_instance_of LineString
70   - line_string.should == LineString.from_coordinates([[12.4,-45.3,35.3],[45.4,41.6,12.3]],256,true)
  69 + line_string.should be_instance_of GeoRuby::SimpleFeatures::LineString
  70 + line_string.should == GeoRuby::SimpleFeatures::LineString.from_coordinates([[12.4,-45.3,35.3],[45.4,41.6,12.3]],256,true)
71 71
72 72 @ewkt_parser.parse("SRID=256;LINESTRINGM(12.4 -45.3 35.3,45.4 41.6 12.3)")
73 73 line_string = @factory.geometry
74   - line_string.should be_instance_of LineString
75   - line_string.should == LineString.from_coordinates([[12.4,-45.3,35.3],[45.4,41.6,12.3]],256,false,true)
  74 + line_string.should be_instance_of GeoRuby::SimpleFeatures::LineString
  75 + line_string.should == GeoRuby::SimpleFeatures::LineString.from_coordinates([[12.4,-45.3,35.3],[45.4,41.6,12.3]],256,false,true)
76 76
77 77 @ewkt_parser.parse("SRID=256;LINESTRING(12.4 -45.3 35.3 25.2,45.4 41.6 12.3 13.75)")
78 78 line_string = @factory.geometry
79   - line_string.should be_instance_of LineString
80   - line_string.should == LineString.from_coordinates([[12.4,-45.3,35.3,25.2],[45.4,41.6,12.3,13.75]],256,true,true)
  79 + line_string.should be_instance_of GeoRuby::SimpleFeatures::LineString
  80 + line_string.should == GeoRuby::SimpleFeatures::LineString.from_coordinates([[12.4,-45.3,35.3,25.2],[45.4,41.6,12.3,13.75]],256,true,true)
81 81 end
82 82
83 83 it "test_polygon" do
84 84 @ewkt_parser.parse("POLYGON((0 0,4 0,4 4,0 4,0 0),(1 1,3 1,3 3,1 3,1 1))")
85 85 polygon = @factory.geometry
86   - polygon.should be_instance_of Polygon
87   - polygon.should == Polygon.from_coordinates([[[0,0],[4,0],[4,4],[0,4],[0,0]],[[1,1],[3,1],[3,3],[1,3],[1,1]]],256)
  86 + polygon.should be_instance_of GeoRuby::SimpleFeatures::Polygon
  87 + polygon.should == GeoRuby::SimpleFeatures::Polygon.from_coordinates([[[0,0],[4,0],[4,4],[0,4],[0,0]],[[1,1],[3,1],[3,3],[1,3],[1,1]]],256)
88 88
89 89 @ewkt_parser.parse("SRID=256;POLYGON( ( 0 0 2,4 0 2,4 4 2,0 4 2,0 0 2),(1 1 2,3 1 2,3 3 2,1 3 2,1 1 2))")
90 90 polygon = @factory.geometry
91   - polygon.should be_instance_of Polygon
92   - polygon.should == Polygon.from_coordinates([[[0,0,2],[4,0,2],[4,4,2],[0,4,2],[0,0,2]],[[1,1,2],[3,1,2],[3,3,2],[1,3,2],[1,1,2]]],256,true)
  91 + polygon.should be_instance_of GeoRuby::SimpleFeatures::Polygon
  92 + polygon.should == GeoRuby::SimpleFeatures::Polygon.from_coordinates([[[0,0,2],[4,0,2],[4,4,2],[0,4,2],[0,0,2]],[[1,1,2],[3,1,2],[3,3,2],[1,3,2],[1,1,2]]],256,true)
93 93
94 94 @ewkt_parser.parse("SRID=256;POLYGONM((0 0 2,4 0 2,4 4 2,0 4 2,0 0 2),(1 1 2,3 1 2,3 3 2,1 3 2,1 1 2))")
95 95 polygon = @factory.geometry
96   - polygon.should be_instance_of Polygon
97   - polygon.should == Polygon.from_coordinates([[[0,0,2],[4,0,2],[4,4,2],[0,4,2],[0,0,2]],[[1,1,2],[3,1,2],[3,3,2],[1,3,2],[1,1,2]]],256,false,true)
  96 + polygon.should be_instance_of GeoRuby::SimpleFeatures::Polygon
  97 + polygon.should == GeoRuby::SimpleFeatures::Polygon.from_coordinates([[[0,0,2],[4,0,2],[4,4,2],[0,4,2],[0,0,2]],[[1,1,2],[3,1,2],[3,3,2],[1,3,2],[1,1,2]]],256,false,true)
98 98
99