GeoRuby 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/MIT-LICENSE +7 -0
- data/README +22 -0
- data/lib/geo_ruby/simple_features/ewkb_parser.rb +185 -0
- data/lib/geo_ruby/simple_features/geometry.rb +87 -0
- data/lib/geo_ruby/simple_features/geometry_collection.rb +94 -0
- data/lib/geo_ruby/simple_features/geometry_factory.rb +51 -0
- data/lib/geo_ruby/simple_features/line_string.rb +109 -0
- data/lib/geo_ruby/simple_features/linear_ring.rb +27 -0
- data/lib/geo_ruby/simple_features/multi_line_string.rb +35 -0
- data/lib/geo_ruby/simple_features/multi_point.rb +40 -0
- data/lib/geo_ruby/simple_features/multi_polygon.rb +38 -0
- data/lib/geo_ruby/simple_features/point.rb +85 -0
- data/lib/geo_ruby/simple_features/polygon.rb +103 -0
- data/lib/geo_ruby.rb +12 -0
- data/rakefile.rb +50 -0
- data/test/test_ewkb_parser.rb +91 -0
- data/test/test_simple_features.rb +303 -0
- metadata +62 -0
| @@ -0,0 +1,303 @@ | |
| 1 | 
            +
            $:.unshift(File.dirname(__FILE__) + '/../lib')
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'geo_ruby'
         | 
| 4 | 
            +
            require 'test/unit'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            include GeoRuby::SimpleFeatures
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            class TestSimpleFeatures < Test::Unit::TestCase
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              def test_geometry_creation
         | 
| 11 | 
            +
                geometry = Geometry::new
         | 
| 12 | 
            +
                assert_equal(DEFAULT_SRID,geometry.srid)
         | 
| 13 | 
            +
                
         | 
| 14 | 
            +
                geometry = Geometry::new(225)
         | 
| 15 | 
            +
                assert_equal(225,geometry.srid)
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                point = Geometry.from_hexewkb("01010000207B000000CDCCCCCCCCCC28406666666666A64640")
         | 
| 18 | 
            +
                assert_equal(Point,point.class)
         | 
| 19 | 
            +
                assert_equal(12.4,point.x)
         | 
| 20 | 
            +
                
         | 
| 21 | 
            +
                
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
              def test_point_creation
         | 
| 24 | 
            +
                point= Point::new(456)
         | 
| 25 | 
            +
                assert_equal(456,point.srid)
         | 
| 26 | 
            +
                assert_equal(0.0,point.x)
         | 
| 27 | 
            +
                assert_equal(0.0,point.y)
         | 
| 28 | 
            +
                assert_nil(point.z)
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                point.set_x_y_z(2.6,56.6,12)
         | 
| 31 | 
            +
                assert_equal(2.6,point.x)
         | 
| 32 | 
            +
                assert_equal(56.6,point.y)
         | 
| 33 | 
            +
                assert_equal(12.0,point.z)
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                point= Point.from_coordinates([1.6,2.8],123)
         | 
| 36 | 
            +
                assert_equal(1.6,point.x)
         | 
| 37 | 
            +
                assert_equal(2.8,point.y)
         | 
| 38 | 
            +
                assert_nil(point.z)
         | 
| 39 | 
            +
                assert_equal(123,point.srid)
         | 
| 40 | 
            +
                
         | 
| 41 | 
            +
                point=Point.from_coordinates([1.6,2.8,3.4],123)
         | 
| 42 | 
            +
                assert_equal(1.6,point.x)
         | 
| 43 | 
            +
                assert_equal(2.8,point.y)
         | 
| 44 | 
            +
                assert_equal(3.4,point.z)
         | 
| 45 | 
            +
                assert_equal(123,point.srid)
         | 
| 46 | 
            +
                
         | 
| 47 | 
            +
                point= Point.from_x_y(1.6,2.8,123)
         | 
| 48 | 
            +
                assert_equal(1.6,point.x)
         | 
| 49 | 
            +
                assert_equal(2.8,point.y)
         | 
| 50 | 
            +
                assert_nil(point.z)
         | 
| 51 | 
            +
                assert_equal(123,point.srid)
         | 
| 52 | 
            +
                
         | 
| 53 | 
            +
                point= Point.from_x_y_z(-1.6,2.8,-3.4,123)
         | 
| 54 | 
            +
                assert_equal(-1.6,point.x)
         | 
| 55 | 
            +
                assert_equal(2.8,point.y)
         | 
| 56 | 
            +
                assert_equal(-3.4,point.z)
         | 
| 57 | 
            +
                assert_equal(123,point.srid)
         | 
| 58 | 
            +
              end
         | 
| 59 | 
            +
              def test_point_equal
         | 
| 60 | 
            +
                point1= Point::new
         | 
| 61 | 
            +
                point1.set_x_y(1.5,45.4)
         | 
| 62 | 
            +
                point2= Point::new
         | 
| 63 | 
            +
                point2.set_x_y(1.5,45.4)
         | 
| 64 | 
            +
                point3= Point::new
         | 
| 65 | 
            +
                point3.set_x_y(4.5,12.3)
         | 
| 66 | 
            +
                point4= Point::new
         | 
| 67 | 
            +
                point4.set_x_y_z(1.5,45.4,423)
         | 
| 68 | 
            +
                geometry= Geometry::new
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                assert(point1==point2)
         | 
| 71 | 
            +
                assert(point1!=point3)
         | 
| 72 | 
            +
                assert(point1!=point4)
         | 
| 73 | 
            +
                assert(point1!=geometry)
         | 
| 74 | 
            +
              end
         | 
| 75 | 
            +
              def test_point_binary
         | 
| 76 | 
            +
                point = Point.from_x_y(12.4,45.3,123)
         | 
| 77 | 
            +
                #test value is the result of "select 'SRID=123;POINT(12.4 45.3)'::geometry;" in PostGIS
         | 
| 78 | 
            +
                assert_equal("01010000207B000000CDCCCCCCCCCC28406666666666A64640", point.as_hex_binary)
         | 
| 79 | 
            +
                
         | 
| 80 | 
            +
                point = Point.from_x_y_z(12.4,45.3,-3.5,123)
         | 
| 81 | 
            +
                #test value is the result of "select 'SRID=123;POINT(12.4 45.3 -3.5)'::geometry;" in PostGIS
         | 
| 82 | 
            +
                assert_equal("01010000A07B000000CDCCCCCCCCCC28406666666666A646400000000000000CC0", point.as_hex_binary(3))
         | 
| 83 | 
            +
              end
         | 
| 84 | 
            +
              def test_point_text
         | 
| 85 | 
            +
                point = Point.from_x_y(12.4,45.3,123)
         | 
| 86 | 
            +
                assert_equal("SRID=123;POINT(12.4 45.3)", point.as_text)
         | 
| 87 | 
            +
                
         | 
| 88 | 
            +
                point = Point.from_x_y_z(12.4,45.3,-3.5,123)
         | 
| 89 | 
            +
                assert_equal("SRID=123;POINT(12.4 45.3 -3.5)", point.as_text(3))
         | 
| 90 | 
            +
              end
         | 
| 91 | 
            +
              def test_line_string_creation
         | 
| 92 | 
            +
                line_string = LineString::new
         | 
| 93 | 
            +
                line_string.concat([Point.from_x_y(12.4,45.3),Point.from_x_y(45.4,41.6)])
         | 
| 94 | 
            +
                
         | 
| 95 | 
            +
                assert_equal(2,line_string.length)
         | 
| 96 | 
            +
                assert_equal(Point.from_x_y(12.4,45.3),line_string[0])
         | 
| 97 | 
            +
             | 
| 98 | 
            +
                point=Point.from_x_y(123,45.8777)
         | 
| 99 | 
            +
                line_string[0]=point
         | 
| 100 | 
            +
                assert_equal(point,line_string[0])
         | 
| 101 | 
            +
             | 
| 102 | 
            +
                points=[Point.from_x_y(123,45.8777),Point.from_x_y(45.4,41.6)]
         | 
| 103 | 
            +
                line_string.each_index {|i| assert_equal(points[i],line_string[i]) }
         | 
| 104 | 
            +
             | 
| 105 | 
            +
                point=Point.from_x_y(22.4,13.56)
         | 
| 106 | 
            +
                line_string << point
         | 
| 107 | 
            +
                assert_equal(3,line_string.length)
         | 
| 108 | 
            +
                assert_equal(point,line_string[2])
         | 
| 109 | 
            +
             | 
| 110 | 
            +
                line_string = LineString.from_points([Point.from_x_y(12.4,-45.3),Point.from_x_y(45.4,41.6)],123)
         | 
| 111 | 
            +
                assert_equal(LineString,line_string.class)
         | 
| 112 | 
            +
                assert_equal(2,line_string.length)
         | 
| 113 | 
            +
                assert_equal(Point.from_x_y(12.4,-45.3),line_string[0])
         | 
| 114 | 
            +
                assert_equal(Point.from_x_y(45.4,41.6),line_string[1])
         | 
| 115 | 
            +
                
         | 
| 116 | 
            +
                line_string = LineString.from_raw_point_sequence([[12.4,-45.3],[45.4,41.6],[4.456,1.0698]],123)
         | 
| 117 | 
            +
                assert_equal(LineString,line_string.class)
         | 
| 118 | 
            +
                assert_equal(3,line_string.length)
         | 
| 119 | 
            +
                assert_equal(Point.from_x_y(12.4,-45.3),line_string[0])
         | 
| 120 | 
            +
                assert_equal(Point.from_x_y(45.4,41.6),line_string[1])
         | 
| 121 | 
            +
              end
         | 
| 122 | 
            +
              def test_line_string_equal
         | 
| 123 | 
            +
                line_string1 = LineString.from_raw_point_sequence([[12.4,-45.3],[45.4,41.6],[4.456,1.0698]],123)
         | 
| 124 | 
            +
                line_string2 = LineString.from_raw_point_sequence([[12.4,-45.3],[45.4,41.6]],123)
         | 
| 125 | 
            +
                point = Point.from_x_y(12.4,-45.3,123)
         | 
| 126 | 
            +
                
         | 
| 127 | 
            +
                assert(LineString.from_raw_point_sequence([[12.4,-45.3],[45.4,41.6],[4.456,1.0698]],123) == line_string1)
         | 
| 128 | 
            +
                assert(line_string1 != line_string2)
         | 
| 129 | 
            +
                assert(line_string1 != point)
         | 
| 130 | 
            +
              end
         | 
| 131 | 
            +
              def test_line_string_binary
         | 
| 132 | 
            +
                line_string = LineString.from_raw_point_sequence([[12.4,-45.3],[45.4,41.6]],256)
         | 
| 133 | 
            +
                #test value is the result of "select 'SRID=256;LINESTRING(12.4 -45.3,45.4 41.6)'::geometry;" in PostGIS
         | 
| 134 | 
            +
                assert_equal("01020000200001000002000000CDCCCCCCCCCC28406666666666A646C03333333333B34640CDCCCCCCCCCC4440",line_string.as_hex_binary)
         | 
| 135 | 
            +
             | 
| 136 | 
            +
                line_string = LineString.from_raw_point_sequence([[12.4,-45.3,35.3],[45.4,41.6,12.3]],256)
         | 
| 137 | 
            +
                #test value is the result of "select 'SRID=256;LINESTRING(12.4 -45.3 35.3,45.4 41.6 12.3)'::geometry;" in PostGIS
         | 
| 138 | 
            +
                assert_equal("01020000A00001000002000000CDCCCCCCCCCC28406666666666A646C06666666666A641403333333333B34640CDCCCCCCCCCC44409A99999999992840",line_string.as_hex_binary(3))
         | 
| 139 | 
            +
              end
         | 
| 140 | 
            +
              def test_line_string_text
         | 
| 141 | 
            +
                line_string = LineString.from_raw_point_sequence([[12.4,-45.3],[45.4,41.6]],256)
         | 
| 142 | 
            +
                assert_equal("SRID=256;LINESTRING(12.4 -45.3,45.4 41.6)",line_string.as_text)
         | 
| 143 | 
            +
             | 
| 144 | 
            +
                line_string = LineString.from_raw_point_sequence([[12.4,-45.3,35.3],[45.4,41.6,12.3]],256)
         | 
| 145 | 
            +
                assert_equal("SRID=256;LINESTRING(12.4 -45.3 35.3,45.4 41.6 12.3)",line_string.as_text(3))
         | 
| 146 | 
            +
              end
         | 
| 147 | 
            +
              
         | 
| 148 | 
            +
              def test_linear_ring_creation
         | 
| 149 | 
            +
                #testing just the constructor helpers since the rest is the same as for line_string
         | 
| 150 | 
            +
                linear_ring = LinearRing.from_raw_point_sequence([[12.4,-45.3],[45.4,41.6],[4.456,1.0698],[12.4,-45.3]],345)
         | 
| 151 | 
            +
                assert_equal(LinearRing,linear_ring.class)
         | 
| 152 | 
            +
                assert_equal(4,linear_ring.length)
         | 
| 153 | 
            +
                assert(linear_ring.is_closed)
         | 
| 154 | 
            +
                assert_equal(Point.from_x_y(45.4,41.6,345),linear_ring[1])
         | 
| 155 | 
            +
              end
         | 
| 156 | 
            +
              #no test of the binary representation for linear_rings : always with polygons and like line_string
         | 
| 157 | 
            +
              def test_polygon_creation
         | 
| 158 | 
            +
                linear_ring1 = LinearRing.from_raw_point_sequence([[12.4,-45.3],[45.4,41.6],[4.456,1.0698],[12.4,-45.3]],256) 
         | 
| 159 | 
            +
                linear_ring2 = LinearRing.from_raw_point_sequence([[2.4,5.3],[5.4,1.4263],[14.46,1.06],[2.4,5.3]],256) 
         | 
| 160 | 
            +
                
         | 
| 161 | 
            +
                polygon = Polygon::new(256)
         | 
| 162 | 
            +
                assert_equal(0,polygon.length)
         | 
| 163 | 
            +
                
         | 
| 164 | 
            +
                polygon << linear_ring1
         | 
| 165 | 
            +
                assert_equal(1,polygon.length)
         | 
| 166 | 
            +
                assert_equal(linear_ring1,polygon[0])
         | 
| 167 | 
            +
                
         | 
| 168 | 
            +
                #the validity of the hole is not checked : just for the sake of example
         | 
| 169 | 
            +
                polygon << linear_ring2
         | 
| 170 | 
            +
                assert_equal(2,polygon.length)
         | 
| 171 | 
            +
                assert_equal(linear_ring2,polygon[1])
         | 
| 172 | 
            +
                
         | 
| 173 | 
            +
                polygon = Polygon.from_linear_rings([linear_ring1,linear_ring2],256)
         | 
| 174 | 
            +
                assert_equal(Polygon,polygon.class)
         | 
| 175 | 
            +
                assert_equal(2,polygon.length)
         | 
| 176 | 
            +
                assert_equal(linear_ring1,polygon[0])
         | 
| 177 | 
            +
                assert_equal(linear_ring2,polygon[1])
         | 
| 178 | 
            +
                
         | 
| 179 | 
            +
                polygon = Polygon.from_raw_point_sequences([[[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)
         | 
| 180 | 
            +
                assert_equal(Polygon,polygon.class)
         | 
| 181 | 
            +
                assert_equal(2,polygon.length)
         | 
| 182 | 
            +
                assert_equal(linear_ring1,polygon[0])
         | 
| 183 | 
            +
                assert_equal(linear_ring2,polygon[1])
         | 
| 184 | 
            +
              end
         | 
| 185 | 
            +
              def test_polygon_equal
         | 
| 186 | 
            +
                polygon1 = Polygon.from_raw_point_sequences([[[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)
         | 
| 187 | 
            +
                polygon2 = Polygon.from_raw_point_sequences([[[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]]])
         | 
| 188 | 
            +
                point = Point.from_x_y(12.4,-45.3,123)
         | 
| 189 | 
            +
             | 
| 190 | 
            +
                assert(polygon1 == Polygon.from_raw_point_sequences([[[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))
         | 
| 191 | 
            +
                assert(polygon1 != polygon2)
         | 
| 192 | 
            +
                assert(polygon1 != point)
         | 
| 193 | 
            +
              end
         | 
| 194 | 
            +
              def test_polygon_binary
         | 
| 195 | 
            +
                polygon = Polygon.from_raw_point_sequences([[[0,0],[4,0],[4,4],[0,4],[0,0]],[[1,1],[3,1],[3,3],[1,3],[1,1]]],256)
         | 
| 196 | 
            +
                #taken from PostGIS answer
         | 
| 197 | 
            +
                assert_equal("0103000020000100000200000005000000000000000000000000000000000000000000000000001040000000000000000000000000000010400000000000001040000000000000000000000000000010400000000000000000000000000000000005000000000000000000F03F000000000000F03F0000000000000840000000000000F03F00000000000008400000000000000840000000000000F03F0000000000000840000000000000F03F000000000000F03F",polygon.as_hex_binary)
         | 
| 198 | 
            +
                
         | 
| 199 | 
            +
                polygon = Polygon.from_raw_point_sequences([[[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)
         | 
| 200 | 
            +
                #taken from PostGIS answer
         | 
| 201 | 
            +
                assert_equal("01030000A000010000020000000500000000000000000000000000000000000000000000000000004000000000000010400000000000000000000000000000004000000000000010400000000000001040000000000000004000000000000000000000000000001040000000000000004000000000000000000000000000000000000000000000004005000000000000000000F03F000000000000F03F00000000000000400000000000000840000000000000F03F0000000000000040000000000000084000000000000008400000000000000040000000000000F03F00000000000008400000000000000040000000000000F03F000000000000F03F0000000000000040",polygon.as_hex_binary(3));
         | 
| 202 | 
            +
              end
         | 
| 203 | 
            +
              def test_polygon_text
         | 
| 204 | 
            +
                polygon = Polygon.from_raw_point_sequences([[[0,0],[4,0],[4,4],[0,4],[0,0]],[[1,1],[3,1],[3,3],[1,3],[1,1]]],256)
         | 
| 205 | 
            +
                assert_equal("SRID=256;POLYGON((0 0,4 0,4 4,0 4,0 0),(1 1,3 1,3 3,1 3,1 1))",polygon.as_text)
         | 
| 206 | 
            +
                
         | 
| 207 | 
            +
                polygon = Polygon.from_raw_point_sequences([[[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)
         | 
| 208 | 
            +
                assert_equal("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))",polygon.as_text(3));
         | 
| 209 | 
            +
              end
         | 
| 210 | 
            +
              def test_geometry_collection_creation
         | 
| 211 | 
            +
                geometry_collection = GeometryCollection::new(256)
         | 
| 212 | 
            +
                geometry_collection << Point.from_x_y(4.67,45.4,256)
         | 
| 213 | 
            +
             | 
| 214 | 
            +
                assert_equal(1,geometry_collection.length)
         | 
| 215 | 
            +
                assert_equal(Point.from_x_y(4.67,45.4,256),geometry_collection[0])
         | 
| 216 | 
            +
                
         | 
| 217 | 
            +
                geometry_collection[0]=LineString.from_raw_point_sequence([[5.7,12.45],[67.55,54]],256)
         | 
| 218 | 
            +
                geometry_collection << Polygon.from_raw_point_sequences([[[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)
         | 
| 219 | 
            +
                assert_equal(2,geometry_collection.length)
         | 
| 220 | 
            +
                assert_equal(LineString.from_raw_point_sequence([[5.7,12.45],[67.55,54]],256),geometry_collection[0])
         | 
| 221 | 
            +
                
         | 
| 222 | 
            +
                geometry_collection = GeometryCollection.from_geometries([Point.from_x_y(4.67,45.4,256),LineString.from_raw_point_sequence([[5.7,12.45],[67.55,54]],256)],256)
         | 
| 223 | 
            +
                assert_equal(GeometryCollection,geometry_collection.class)
         | 
| 224 | 
            +
                assert_equal(256,geometry_collection.srid)
         | 
| 225 | 
            +
                assert_equal(2,geometry_collection.length)
         | 
| 226 | 
            +
                assert_equal(LineString.from_raw_point_sequence([[5.7,12.45],[67.55,54]],256),geometry_collection[1])
         | 
| 227 | 
            +
              end
         | 
| 228 | 
            +
              def test_geometry_collection_equal
         | 
| 229 | 
            +
                geometry_collection1 = GeometryCollection.from_geometries([Point.from_x_y(4.67,45.4,256),LineString.from_raw_point_sequence([[5.7,12.45],[67.55,54]],256)],256)
         | 
| 230 | 
            +
                geometry_collection2 = GeometryCollection.from_geometries([Point.from_x_y(4.67,45.4,256),LineString.from_raw_point_sequence([[5.7,12.45],[67.55,54]],256),Polygon.from_raw_point_sequences([[[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)],256)
         | 
| 231 | 
            +
                line_string=LineString.from_raw_point_sequence([[5.7,12.45],[67.55,54]],256)
         | 
| 232 | 
            +
             | 
| 233 | 
            +
                assert(GeometryCollection.from_geometries([Point.from_x_y(4.67,45.4,256),LineString.from_raw_point_sequence([[5.7,12.45],[67.55,54]],256)],256) == geometry_collection1)
         | 
| 234 | 
            +
                assert(geometry_collection1 != geometry_collection2)
         | 
| 235 | 
            +
                assert(geometry_collection1 != line_string)
         | 
| 236 | 
            +
              end
         | 
| 237 | 
            +
              def test_geometry_collection_binary
         | 
| 238 | 
            +
                geometry_collection = GeometryCollection.from_geometries([Point.from_x_y(4.67,45.4,256),LineString.from_raw_point_sequence([[5.7,12.45],[67.55,54]],256)],256)
         | 
| 239 | 
            +
                assert_equal("010700002000010000020000000101000000AE47E17A14AE12403333333333B34640010200000002000000CDCCCCCCCCCC16406666666666E628403333333333E350400000000000004B40",geometry_collection.as_hex_binary)
         | 
| 240 | 
            +
              end
         | 
| 241 | 
            +
              def test_geometry_collection_text
         | 
| 242 | 
            +
                geometry_collection = GeometryCollection.from_geometries([Point.from_x_y(4.67,45.4,256),LineString.from_raw_point_sequence([[5.7,12.45],[67.55,54]],256)],256)
         | 
| 243 | 
            +
                assert_equal("SRID=256;GEOMETRYCOLLECTION(POINT(4.67 45.4),LINESTRING(5.7 12.45,67.55 54))",geometry_collection.as_text)
         | 
| 244 | 
            +
              end
         | 
| 245 | 
            +
              def test_multi_point_creation
         | 
| 246 | 
            +
                multi_point = MultiPoint.from_raw_point_sequence([[12.4,-123.3],[-65.1,123.4],[123.55555555,123]],444)
         | 
| 247 | 
            +
                assert(multi_point.instance_of?(MultiPoint))
         | 
| 248 | 
            +
                assert_equal(3,multi_point.length)
         | 
| 249 | 
            +
                assert_equal(Point.from_x_y(12.4,-123.3,444),multi_point[0])
         | 
| 250 | 
            +
                assert_equal(Point.from_x_y(123.55555555,123,444),multi_point[2])
         | 
| 251 | 
            +
              end
         | 
| 252 | 
            +
              def test_multi_point_binary
         | 
| 253 | 
            +
                multi_point = MultiPoint.from_raw_point_sequence([[12.4,-123.3],[-65.1,123.4],[123.55555555,123]],444)
         | 
| 254 | 
            +
                assert_equal("0104000020BC010000030000000101000000CDCCCCCCCCCC28403333333333D35EC0010100000066666666664650C09A99999999D95E4001010000001F97DD388EE35E400000000000C05E40",multi_point.as_hex_binary)
         | 
| 255 | 
            +
              end
         | 
| 256 | 
            +
              def test_multi_point_text
         | 
| 257 | 
            +
                multi_point = MultiPoint.from_raw_point_sequence([[12.4,-123.3],[-65.1,123.4],[123.55555555,123]],444)
         | 
| 258 | 
            +
                assert_equal("SRID=444;MULTIPOINT(12.4 -123.3,-65.1 123.4,123.55555555 123)",multi_point.as_text)
         | 
| 259 | 
            +
              end
         | 
| 260 | 
            +
              def test_multi_line_string_creation
         | 
| 261 | 
            +
                multi_line_string1 = MultiLineString.from_line_strings([LineString.from_raw_point_sequence([[1.5,45.2],[-54.12312,-0.012]],256),LineString.from_raw_point_sequence([[1.5,45.2],[-54.12312,-0.012],[45.123,123.3]],256)],256)
         | 
| 262 | 
            +
                assert(multi_line_string1.instance_of?(MultiLineString))
         | 
| 263 | 
            +
                assert_equal(2,multi_line_string1.length)
         | 
| 264 | 
            +
                assert_equal(LineString.from_raw_point_sequence([[1.5,45.2],[-54.12312,-0.012]],256),multi_line_string1[0])
         | 
| 265 | 
            +
              
         | 
| 266 | 
            +
                multi_line_string2= MultiLineString.from_raw_point_sequences([[[1.5,45.2],[-54.12312,-0.012]],[[1.5,45.2],[-54.12312,-0.012],[45.123,123.3]]],256);
         | 
| 267 | 
            +
                assert(multi_line_string2.instance_of?(MultiLineString))
         | 
| 268 | 
            +
                assert_equal(2,multi_line_string2.length)
         | 
| 269 | 
            +
                assert_equal(LineString.from_raw_point_sequence([[1.5,45.2],[-54.12312,-0.012]],256),multi_line_string2[0])
         | 
| 270 | 
            +
                assert(multi_line_string2 == multi_line_string2)
         | 
| 271 | 
            +
              end
         | 
| 272 | 
            +
              def test_multi_line_string_binary
         | 
| 273 | 
            +
                multi_line_string = MultiLineString.from_line_strings([LineString.from_raw_point_sequence([[1.5,45.2],[-54.12312,-0.012]],256),LineString.from_raw_point_sequence([[1.5,45.2],[-54.12312,-0.012],[45.123,123.3]],256)],256)
         | 
| 274 | 
            +
             | 
| 275 | 
            +
                assert_equal("01050000200001000002000000010200000002000000000000000000F83F9A99999999994640E4BD6A65C20F4BC0FA7E6ABC749388BF010200000003000000000000000000F83F9A99999999994640E4BD6A65C20F4BC0FA7E6ABC749388BF39B4C876BE8F46403333333333D35E40",multi_line_string.as_hex_binary)
         | 
| 276 | 
            +
              end
         | 
| 277 | 
            +
              def test_multi_line_string_text
         | 
| 278 | 
            +
                multi_line_string = MultiLineString.from_line_strings([LineString.from_raw_point_sequence([[1.5,45.2],[-54.12312,-0.012]],256),LineString.from_raw_point_sequence([[1.5,45.2],[-54.12312,-0.012],[45.123,123.3]],256)],256)
         | 
| 279 | 
            +
                assert_equal("SRID=256;MULTILINESTRING((1.5 45.2,-54.12312 -0.012),(1.5 45.2,-54.12312 -0.012,45.123 123.3))",multi_line_string.as_text)
         | 
| 280 | 
            +
              end
         | 
| 281 | 
            +
             | 
| 282 | 
            +
              def test_multi_polygon_creation
         | 
| 283 | 
            +
                multi_polygon1 = MultiPolygon.from_polygons([Polygon.from_raw_point_sequences([[[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_raw_point_sequences([[[0,0],[4,0],[4,4],[0,4],[0,0]],[[1,1],[3,1],[3,3],[1,3],[1,1]]],256)],256)
         | 
| 284 | 
            +
                assert(multi_polygon1.instance_of?(MultiPolygon))
         | 
| 285 | 
            +
                assert_equal(2,multi_polygon1.length)
         | 
| 286 | 
            +
                assert_equal(Polygon.from_raw_point_sequences([[[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),multi_polygon1[0])
         | 
| 287 | 
            +
             | 
| 288 | 
            +
                multi_polygon2 = MultiPolygon.from_raw_point_sequences([[[[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]]],[[[0,0],[4,0],[4,4],[0,4],[0,0]],[[1,1],[3,1],[3,3],[1,3],[1,1]]]],256)
         | 
| 289 | 
            +
                assert(multi_polygon2.instance_of?(MultiPolygon))
         | 
| 290 | 
            +
                assert_equal(2,multi_polygon2.length)
         | 
| 291 | 
            +
                assert_equal(Polygon.from_raw_point_sequences([[[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),multi_polygon2[0])
         | 
| 292 | 
            +
                assert(multi_polygon1 == multi_polygon2)
         | 
| 293 | 
            +
              end
         | 
| 294 | 
            +
              def test_multi_polygon_binary
         | 
| 295 | 
            +
                multi_polygon = MultiPolygon.from_polygons([Polygon.from_raw_point_sequences([[[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_raw_point_sequences([[[0,0],[4,0],[4,4],[0,4],[0,0]],[[1,1],[3,1],[3,3],[1,3],[1,1]]],256)],256)
         | 
| 296 | 
            +
                assert_equal("0106000020000100000200000001030000000200000004000000CDCCCCCCCCCC28406666666666A646C03333333333B34640CDCCCCCCCCCC44406DE7FBA9F1D211403D2CD49AE61DF13FCDCCCCCCCCCC28406666666666A646C004000000333333333333034033333333333315409A999999999915408A8EE4F21FD2F63FEC51B81E85EB2C40F6285C8FC2F5F03F3333333333330340333333333333154001030000000200000005000000000000000000000000000000000000000000000000001040000000000000000000000000000010400000000000001040000000000000000000000000000010400000000000000000000000000000000005000000000000000000F03F000000000000F03F0000000000000840000000000000F03F00000000000008400000000000000840000000000000F03F0000000000000840000000000000F03F000000000000F03F",multi_polygon.as_hex_binary)
         | 
| 297 | 
            +
              end
         | 
| 298 | 
            +
              def test_multi_polygon_text
         | 
| 299 | 
            +
                multi_polygon = MultiPolygon.from_polygons([Polygon.from_raw_point_sequences([[[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_raw_point_sequences([[[0,0],[4,0],[4,4],[0,4],[0,0]],[[1,1],[3,1],[3,3],[1,3],[1,1]]],256)],256)
         | 
| 300 | 
            +
                assert_equal("SRID=256;MULTIPOLYGON(((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)),((0 0,4 0,4 4,0 4,0 0),(1 1,3 1,3 3,1 3,1 1)))",multi_polygon.as_text)
         | 
| 301 | 
            +
              end
         | 
| 302 | 
            +
              
         | 
| 303 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,62 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification 
         | 
| 2 | 
            +
            rubygems_version: 0.8.10
         | 
| 3 | 
            +
            specification_version: 1
         | 
| 4 | 
            +
            name: GeoRuby
         | 
| 5 | 
            +
            version: !ruby/object:Gem::Version 
         | 
| 6 | 
            +
              version: 0.0.1
         | 
| 7 | 
            +
            date: 2006-01-28
         | 
| 8 | 
            +
            summary: Ruby data holder for OGC Simple Features
         | 
| 9 | 
            +
            require_paths: 
         | 
| 10 | 
            +
              - lib
         | 
| 11 | 
            +
            email: guilhem.vellut+georuby@gmail.com
         | 
| 12 | 
            +
            homepage: http://thepochisuperstarmegashow.com
         | 
| 13 | 
            +
            rubyforge_project: 
         | 
| 14 | 
            +
            description: "GeoRuby is intended as a holder for data returned from PostGIS queries.
         | 
| 15 | 
            +
              Therefore, the data model roughly follows the OGC \"Simple Features for SQL\"
         | 
| 16 | 
            +
              specification (see www.opengis.org/docs/99-049.pdf), although without any kind
         | 
| 17 | 
            +
              of advanced functionalities (such as geometric operators or reprojections)"
         | 
| 18 | 
            +
            autorequire: 
         | 
| 19 | 
            +
            default_executable: 
         | 
| 20 | 
            +
            bindir: bin
         | 
| 21 | 
            +
            has_rdoc: true
         | 
| 22 | 
            +
            required_ruby_version: !ruby/object:Gem::Version::Requirement 
         | 
| 23 | 
            +
              requirements: 
         | 
| 24 | 
            +
                - 
         | 
| 25 | 
            +
                  - ">"
         | 
| 26 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 27 | 
            +
                    version: 0.0.0
         | 
| 28 | 
            +
              version: 
         | 
| 29 | 
            +
            platform: ruby
         | 
| 30 | 
            +
            authors: 
         | 
| 31 | 
            +
              - Guilhem Vellut
         | 
| 32 | 
            +
            files: 
         | 
| 33 | 
            +
              - lib/geo_ruby.rb
         | 
| 34 | 
            +
              - lib/geo_ruby/simple_features/ewkb_parser.rb
         | 
| 35 | 
            +
              - lib/geo_ruby/simple_features/geometry.rb
         | 
| 36 | 
            +
              - lib/geo_ruby/simple_features/geometry_collection.rb
         | 
| 37 | 
            +
              - lib/geo_ruby/simple_features/geometry_factory.rb
         | 
| 38 | 
            +
              - lib/geo_ruby/simple_features/linear_ring.rb
         | 
| 39 | 
            +
              - lib/geo_ruby/simple_features/line_string.rb
         | 
| 40 | 
            +
              - lib/geo_ruby/simple_features/multi_line_string.rb
         | 
| 41 | 
            +
              - lib/geo_ruby/simple_features/multi_point.rb
         | 
| 42 | 
            +
              - lib/geo_ruby/simple_features/multi_polygon.rb
         | 
| 43 | 
            +
              - lib/geo_ruby/simple_features/point.rb
         | 
| 44 | 
            +
              - lib/geo_ruby/simple_features/polygon.rb
         | 
| 45 | 
            +
              - test/test_ewkb_parser.rb
         | 
| 46 | 
            +
              - test/test_simple_features.rb
         | 
| 47 | 
            +
              - README
         | 
| 48 | 
            +
              - MIT-LICENSE
         | 
| 49 | 
            +
              - rakefile.rb
         | 
| 50 | 
            +
            test_files: 
         | 
| 51 | 
            +
              - test/test_ewkb_parser.rb
         | 
| 52 | 
            +
              - test/test_simple_features.rb
         | 
| 53 | 
            +
            rdoc_options: 
         | 
| 54 | 
            +
              - "--main"
         | 
| 55 | 
            +
              - README
         | 
| 56 | 
            +
            extra_rdoc_files: 
         | 
| 57 | 
            +
              - README
         | 
| 58 | 
            +
            executables: []
         | 
| 59 | 
            +
            extensions: []
         | 
| 60 | 
            +
            requirements: 
         | 
| 61 | 
            +
              - none
         | 
| 62 | 
            +
            dependencies: []
         |