georuby 1.9.9 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,22 +1,22 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
2
 
3
- describe LinearRing do
3
+ describe GeoRuby::SimpleFeatures::LinearRing do
4
4
 
5
5
  it "should instantiate" do
6
- lr = LinearRing.new(4326)
7
- lr.should be_instance_of(LinearRing)
6
+ lr = GeoRuby::SimpleFeatures::LinearRing.new(4326)
7
+ lr.should be_instance_of(GeoRuby::SimpleFeatures::LinearRing)
8
8
  end
9
9
 
10
10
  describe "Instance" do
11
11
 
12
- let(:lr) { LinearRing.from_coordinates([[10,10],[20,45],[45,10],[10, 10]],256) }
12
+ let(:lr) { GeoRuby::SimpleFeatures::LinearRing.from_coordinates([[10,10],[20,45],[45,10],[10, 10]],256) }
13
13
 
14
14
  it "should test if contains a point" do
15
- lr.contains_point?(Point.from_x_y(21,21)).should be_true
15
+ lr.contains_point?(GeoRuby::SimpleFeatures::Point.from_x_y(21,21)).should be_true
16
16
  end
17
17
 
18
18
  it "should test if not contains a point" do
19
- lr.contains_point?(Point.from_x_y(21,51)).should be_false
19
+ lr.contains_point?(GeoRuby::SimpleFeatures::Point.from_x_y(21,51)).should be_false
20
20
  end
21
21
 
22
22
  end
@@ -1,40 +1,40 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
2
 
3
- describe MultiLineString do
3
+ describe GeoRuby::SimpleFeatures::MultiLineString do
4
4
 
5
5
  it "test_multi_line_string_creation" do
6
- multi_line_string1 = 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)
7
- multi_line_string1.should be_instance_of(MultiLineString)
6
+ multi_line_string1 = 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)
7
+ multi_line_string1.should be_instance_of(GeoRuby::SimpleFeatures::MultiLineString)
8
8
  multi_line_string1.length.should eql(2)
9
- multi_line_string1[0].should == LineString.from_coordinates([[1.5,45.2],[-54.12312,-0.012]],256)
9
+ multi_line_string1[0].should == GeoRuby::SimpleFeatures::LineString.from_coordinates([[1.5,45.2],[-54.12312,-0.012]],256)
10
10
 
11
- multi_line_string2= MultiLineString.from_coordinates([[[1.5,45.2],[-54.12312,-0.012]],[[1.5,45.2],[-54.12312,-0.012],[45.123,123.3]]],256);
12
- multi_line_string1.should be_instance_of(MultiLineString)
11
+ multi_line_string2= GeoRuby::SimpleFeatures::MultiLineString.from_coordinates([[[1.5,45.2],[-54.12312,-0.012]],[[1.5,45.2],[-54.12312,-0.012],[45.123,123.3]]],256);
12
+ multi_line_string1.should be_instance_of(GeoRuby::SimpleFeatures::MultiLineString)
13
13
  multi_line_string1.length.should eql(2)
14
- multi_line_string2[0].should == LineString.from_coordinates([[1.5,45.2],[-54.12312,-0.012]],256)
14
+ multi_line_string2[0].should == GeoRuby::SimpleFeatures::LineString.from_coordinates([[1.5,45.2],[-54.12312,-0.012]],256)
15
15
 
16
16
  multi_line_string2.should == multi_line_string2
17
17
  end
18
18
 
19
19
  it "test_multi_line_string_binary" do
20
- multi_line_string = 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)
20
+ multi_line_string = 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)
21
21
  multi_line_string.as_hex_ewkb.should eql("01050000200001000002000000010200000002000000000000000000F83F9A99999999994640E4BD6A65C20F4BC0FA7E6ABC749388BF010200000003000000000000000000F83F9A99999999994640E4BD6A65C20F4BC0FA7E6ABC749388BF39B4C876BE8F46403333333333D35E40")
22
22
 
23
- multi_line_string = 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)
23
+ multi_line_string = 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)
24
24
  multi_line_string.as_hex_ewkb.should eql("0105000020000100000200000001020000C002000000000000000000F83F9A99999999994640CDCCCCCCCCCCF43F333333333333F33FE4BD6A65C20F4BC0FA7E6ABC749388BF333333333333F33F000000000000124001020000C003000000000000000000F83F9A99999999994640666666666666144000000000000012C0E4BD6A65C20F4BC0FA7E6ABC749388BF3333333333331BC03333333333330B4039B4C876BE8F46403333333333D35E40000000000000124033333333333315C0")
25
25
  end
26
26
 
27
27
  it "test_multi_line_string_text" do
28
- multi_line_string = 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)
28
+ multi_line_string = 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)
29
29
  multi_line_string.as_ewkt.should eql("SRID=256;MULTILINESTRING((1.5 45.2,-54.12312 -0.012),(1.5 45.2,-54.12312 -0.012,45.123 123.3))")
30
30
 
31
- multi_line_string = 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)
31
+ multi_line_string = 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)
32
32
  multi_line_string.as_ewkt.should eql("SRID=256;MULTILINESTRING((1.5 45.2 1.3 1.2,-54.12312 -0.012 1.2 4.5),(1.5 45.2 5.1 -4.5,-54.12312 -0.012 -6.8 3.4,45.123 123.3 4.5 -5.3))")
33
33
  end
34
34
 
35
35
  describe "Some More" do
36
36
  before do
37
- @mls = 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)
37
+ @mls = 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)
38
38
  end
39
39
 
40
40
  it "should have a accessor to all points" do
@@ -47,7 +47,7 @@ describe MultiLineString do
47
47
 
48
48
  it "should simplify to linestring" do
49
49
  ls = @mls.to_line_string
50
- ls.should be_instance_of(LineString)
50
+ ls.should be_instance_of(GeoRuby::SimpleFeatures::LineString)
51
51
  ls.should have(5).points
52
52
  end
53
53
  end
@@ -1,33 +1,33 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
2
 
3
- describe MultiPoint do
3
+ describe GeoRuby::SimpleFeatures::MultiPoint do
4
4
 
5
5
  it "test_multi_point_creation" do
6
- multi_point = MultiPoint.from_coordinates([[12.4,-123.3],[-65.1,123.4],[123.55555555,123]],444)
7
- multi_point.should be_instance_of(MultiPoint)
6
+ multi_point = GeoRuby::SimpleFeatures::MultiPoint.from_coordinates([[12.4,-123.3],[-65.1,123.4],[123.55555555,123]],444)
7
+ multi_point.should be_instance_of(GeoRuby::SimpleFeatures::MultiPoint)
8
8
  multi_point.length.should eql(3)
9
- multi_point[0].should == Point.from_x_y(12.4,-123.3,444)
10
- multi_point[2].should == Point.from_x_y(123.55555555,123,444)
9
+ multi_point[0].should == GeoRuby::SimpleFeatures::Point.from_x_y(12.4,-123.3,444)
10
+ multi_point[2].should == GeoRuby::SimpleFeatures::Point.from_x_y(123.55555555,123,444)
11
11
  end
12
12
 
13
13
  it "test_multi_point_binary" do
14
- multi_point = MultiPoint.from_coordinates([[12.4,-123.3],[-65.1,123.4],[123.55555555,123]],444)
14
+ multi_point = GeoRuby::SimpleFeatures::MultiPoint.from_coordinates([[12.4,-123.3],[-65.1,123.4],[123.55555555,123]],444)
15
15
  multi_point.as_hex_ewkb.should eql("0104000020BC010000030000000101000000CDCCCCCCCCCC28403333333333D35EC0010100000066666666664650C09A99999999D95E4001010000001F97DD388EE35E400000000000C05E40")
16
16
 
17
- multi_point = MultiPoint.from_coordinates([[12.4,-123.3,4.5],[-65.1,123.4,1.2],[123.55555555,123,2.3]],444,true)
17
+ multi_point = GeoRuby::SimpleFeatures::MultiPoint.from_coordinates([[12.4,-123.3,4.5],[-65.1,123.4,1.2],[123.55555555,123,2.3]],444,true)
18
18
  multi_point.as_hex_ewkb.should eql("01040000A0BC010000030000000101000080CDCCCCCCCCCC28403333333333D35EC00000000000001240010100008066666666664650C09A99999999D95E40333333333333F33F01010000801F97DD388EE35E400000000000C05E406666666666660240")
19
19
  end
20
20
 
21
21
  it "test_multi_point_text" do
22
- multi_point = MultiPoint.from_coordinates([[12.4,-123.3],[-65.1,123.4],[123.55555555,123]],444)
22
+ multi_point = GeoRuby::SimpleFeatures::MultiPoint.from_coordinates([[12.4,-123.3],[-65.1,123.4],[123.55555555,123]],444)
23
23
  multi_point.as_ewkt.should eql("SRID=444;MULTIPOINT((12.4 -123.3),(-65.1 123.4),(123.55555555 123))")
24
24
 
25
- multi_point = MultiPoint.from_coordinates([[12.4,-123.3,4.5],[-65.1,123.4,6.7],[123.55555555,123,7.8]],444,true)
25
+ multi_point = GeoRuby::SimpleFeatures::MultiPoint.from_coordinates([[12.4,-123.3,4.5],[-65.1,123.4,6.7],[123.55555555,123,7.8]],444,true)
26
26
  multi_point.as_ewkt.should eql("SRID=444;MULTIPOINT((12.4 -123.3 4.5),(-65.1 123.4 6.7),(123.55555555 123 7.8))")
27
27
  end
28
28
 
29
29
  it "should respond to points" do
30
- mp = MultiPoint.from_coordinates([[12.4,-123.3],[-65.1,123.4],[123.55555555,123]],444)
30
+ mp = GeoRuby::SimpleFeatures::MultiPoint.from_coordinates([[12.4,-123.3],[-65.1,123.4],[123.55555555,123]],444)
31
31
  mp.should have(3).geometries
32
32
  mp.should have(3).points
33
33
  end
@@ -1,45 +1,45 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
2
 
3
- describe MultiPolygon do
3
+ describe GeoRuby::SimpleFeatures::MultiPolygon do
4
4
 
5
5
  it "test_multi_polygon_creation" do
6
- multi_polygon1 = 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)
7
- multi_polygon1.should be_instance_of(MultiPolygon)
6
+ multi_polygon1 = 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)
7
+ multi_polygon1.should be_instance_of(GeoRuby::SimpleFeatures::MultiPolygon)
8
8
  multi_polygon1.length.should eql(2)
9
- multi_polygon1[0].should == 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)
9
+ multi_polygon1[0].should == 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)
10
10
 
11
- multi_polygon2 = MultiPolygon.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]]],[[[0,0],[4,0],[4,4],[0,4],[0,0]],[[1,1],[3,1],[3,3],[1,3],[1,1]]]],256)
12
- multi_polygon1.should be_instance_of(MultiPolygon)
11
+ multi_polygon2 = GeoRuby::SimpleFeatures::MultiPolygon.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]]],[[[0,0],[4,0],[4,4],[0,4],[0,0]],[[1,1],[3,1],[3,3],[1,3],[1,1]]]],256)
12
+ multi_polygon1.should be_instance_of(GeoRuby::SimpleFeatures::MultiPolygon)
13
13
  multi_polygon1.length.should eql(2)
14
14
 
15
- multi_polygon2[0].should == 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)
15
+ multi_polygon2[0].should == 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)
16
16
  multi_polygon1.should == multi_polygon2
17
17
  end
18
18
 
19
19
  it "test_multi_polygon_binary" do
20
- multi_polygon = 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)
20
+ multi_polygon = 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)
21
21
  multi_polygon.as_hex_ewkb.should eql("0106000020000100000200000001030000000200000004000000CDCCCCCCCCCC28406666666666A646C03333333333B34640CDCCCCCCCCCC44406DE7FBA9F1D211403D2CD49AE61DF13FCDCCCCCCCCCC28406666666666A646C004000000333333333333034033333333333315409A999999999915408A8EE4F21FD2F63FEC51B81E85EB2C40F6285C8FC2F5F03F3333333333330340333333333333154001030000000200000005000000000000000000000000000000000000000000000000001040000000000000000000000000000010400000000000001040000000000000000000000000000010400000000000000000000000000000000005000000000000000000F03F000000000000F03F0000000000000840000000000000F03F00000000000008400000000000000840000000000000F03F0000000000000840000000000000F03F000000000000F03F")
22
22
 
23
- multi_polygon = 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)
23
+ multi_polygon = 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)
24
24
  multi_polygon.as_hex_ewkb.should eql("0106000020000100000200000001030000400200000004000000CDCCCCCCCCCC28406666666666A646C0333333333333F33F3333333333B34640CDCCCCCCCCCC4440333333333333F33F6DE7FBA9F1D211403D2CD49AE61DF13F333333333333F33FCDCCCCCCCCCC28406666666666A646C0333333333333F33F0400000033333333333303403333333333331540333333333333F33F9A999999999915408A8EE4F21FD2F63F333333333333F33FEC51B81E85EB2C40F6285C8FC2F5F03F333333333333F33F33333333333303403333333333331540333333333333F33F0103000040020000000500000000000000000000000000000000000000333333333333F33F00000000000010400000000000000000333333333333F33F00000000000010400000000000001040666666666666024000000000000000000000000000001040333333333333F33F00000000000000000000000000000000333333333333F33F05000000000000000000F03F000000000000F03F9A999999999901400000000000000840000000000000F03F6666666666660A40000000000000084000000000000008409A9999999999F13F000000000000F03F00000000000008403333333333330340000000000000F03F000000000000F03F9A99999999990140")
25
25
  end
26
26
 
27
27
  it "test_multi_polygon_text" do
28
- multi_polygon = 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)
28
+ multi_polygon = 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)
29
29
  multi_polygon.as_ewkt.should eql("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)))")
30
30
 
31
- multi_polygon = MultiPolygon.from_polygons([Polygon.from_coordinates([[[12.4,-45.3,2],[45.4,41.6,3],[4.456,1.0698,4],[12.4,-45.3,2]],[[2.4,5.3,1],[5.4,1.4263,3.44],[14.46,1.06,4.5],[2.4,5.3,1]]],4326,true),Polygon.from_coordinates([[[0,0,5.6],[4,0,5.4],[4,4,1],[0,4,23],[0,0,5.6]],[[1,1,2.3],[3,1,4],[3,3,5],[1,3,6],[1,1,2.3]]],4326,true)],4326,true)
31
+ multi_polygon = GeoRuby::SimpleFeatures::MultiPolygon.from_polygons([GeoRuby::SimpleFeatures::Polygon.from_coordinates([[[12.4,-45.3,2],[45.4,41.6,3],[4.456,1.0698,4],[12.4,-45.3,2]],[[2.4,5.3,1],[5.4,1.4263,3.44],[14.46,1.06,4.5],[2.4,5.3,1]]],4326,true),GeoRuby::SimpleFeatures::Polygon.from_coordinates([[[0,0,5.6],[4,0,5.4],[4,4,1],[0,4,23],[0,0,5.6]],[[1,1,2.3],[3,1,4],[3,3,5],[1,3,6],[1,1,2.3]]],4326,true)],4326,true)
32
32
  multi_polygon.as_ewkt.should eql("SRID=4326;MULTIPOLYGON(((12.4 -45.3 2,45.4 41.6 3,4.456 1.0698 4,12.4 -45.3 2),(2.4 5.3 1,5.4 1.4263 3.44,14.46 1.06 4.5,2.4 5.3 1)),((0 0 5.6,4 0 5.4,4 4 1,0 4 23,0 0 5.6),(1 1 2.3,3 1 4,3 3 5,1 3 6,1 1 2.3)))")
33
33
  end
34
34
 
35
35
  describe "Counting" do
36
36
 
37
37
  before do
38
- @mp = 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)
38
+ @mp = 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)
39
39
  end
40
40
 
41
41
  it "should have a points method" do
42
- @mp.points[0].should be_instance_of(Point)
42
+ @mp.points[0].should be_instance_of(GeoRuby::SimpleFeatures::Point)
43
43
  end
44
44
 
45
45
  it "should flatten it right" do
@@ -1,12 +1,12 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
3
3
 
4
- describe Point do
5
- let(:point) { Point.new(4326) }
4
+ describe GeoRuby::SimpleFeatures::Point do
5
+ let(:point) { GeoRuby::SimpleFeatures::Point.new(4326) }
6
6
 
7
7
  it "should instantiatember" do
8
8
  violated unless point
9
- point.should be_instance_of(Point)
9
+ point.should be_instance_of(GeoRuby::SimpleFeatures::Point)
10
10
  end
11
11
 
12
12
  it "should have a nice matcher" do
@@ -18,15 +18,15 @@ describe Point do
18
18
  end
19
19
 
20
20
  it "should have a very nice matcher" do
21
- Point.from_x_y_z_m(1,2,3.33,"t").should be_a_point(1, 2, 3.33, "t")
21
+ GeoRuby::SimpleFeatures::Point.from_x_y_z_m(1,2,3.33,"t").should be_a_point(1, 2, 3.33, "t")
22
22
  end
23
23
 
24
24
  it "should have a dumb matcher" do
25
- Point.should be_geometric
25
+ GeoRuby::SimpleFeatures::Point.should be_geometric
26
26
  end
27
27
 
28
28
  it "should be subclassable" do
29
- place = Class.new(Point)
29
+ place = Class.new(GeoRuby::SimpleFeatures::Point)
30
30
  p = place.from_x_y(1,2)
31
31
  p.should be_a place
32
32
  end
@@ -54,18 +54,18 @@ describe Point do
54
54
  end
55
55
 
56
56
  it "should compare ok" do
57
- point1= Point::new
57
+ point1= GeoRuby::SimpleFeatures::Point::new
58
58
  point1.set_x_y(1.5,45.4)
59
- point2= Point::new
59
+ point2= GeoRuby::SimpleFeatures::Point::new
60
60
  point2.set_x_y(1.5,45.4)
61
- point3= Point::new
61
+ point3= GeoRuby::SimpleFeatures::Point::new
62
62
  point3.set_x_y(4.5,12.3)
63
- point4= Point::new
63
+ point4= GeoRuby::SimpleFeatures::Point::new
64
64
  point4.set_x_y_z(1.5,45.4,423)
65
- point5= Point::new
65
+ point5= GeoRuby::SimpleFeatures::Point::new
66
66
  point5.set_x_y(1.5,45.4)
67
67
  point5.m=15
68
- geometry= Geometry::new
68
+ geometry= GeoRuby::SimpleFeatures::Geometry::new
69
69
 
70
70
  point1.should == point2
71
71
  point1.should_not == point3
@@ -77,7 +77,7 @@ describe Point do
77
77
  describe "> Instantiation" do
78
78
 
79
79
  it "should instantiate a 2d point" do
80
- point = Point.from_x_y(10,20,123)
80
+ point = GeoRuby::SimpleFeatures::Point.from_x_y(10,20,123)
81
81
  point.x.should eql(10)
82
82
  point.y.should eql(20)
83
83
  point.srid.should eql(123)
@@ -85,21 +85,21 @@ describe Point do
85
85
  end
86
86
 
87
87
  it "should instantiate a 2d easily" do
88
- point = Point.xy(10,20,123)
88
+ point = GeoRuby::SimpleFeatures::Point.xy(10,20,123)
89
89
  point.x.should eql(10)
90
90
  point.y.should eql(20)
91
91
  point.srid.should eql(123)
92
92
  end
93
93
 
94
94
  it "should instantiate a 3d point" do
95
- point = Point.from_x_y_z(-10,-20,-30)
95
+ point = GeoRuby::SimpleFeatures::Point.from_x_y_z(-10,-20,-30)
96
96
  point.x.should eql(-10)
97
97
  point.y.should eql(-20)
98
98
  point.z.should eql(-30)
99
99
  end
100
100
 
101
101
  it "should instantiate a 3d(m) point" do
102
- point = Point.from_x_y_m(10,20,30)
102
+ point = GeoRuby::SimpleFeatures::Point.from_x_y_m(10,20,30)
103
103
  point.x.should eql(10)
104
104
  point.y.should eql(20)
105
105
  point.m.should eql(30)
@@ -107,7 +107,7 @@ describe Point do
107
107
  end
108
108
 
109
109
  it "should instantiate a 4d point" do
110
- point = Point.from_x_y_z_m(10,20,30,40,123)
110
+ point = GeoRuby::SimpleFeatures::Point.from_x_y_z_m(10,20,30,40,123)
111
111
  point.x.should eql(10)
112
112
  point.y.should eql(20)
113
113
  point.z.should eql(30)
@@ -116,13 +116,13 @@ describe Point do
116
116
  end
117
117
 
118
118
  it "should instantiate a point from polar coordinates" do
119
- point = Point.from_r_t(1.4142,45)
119
+ point = GeoRuby::SimpleFeatures::Point.from_r_t(1.4142,45)
120
120
  point.y.should be_within(0.1).of(1)
121
121
  point.x.should be_within(0.1).of(1)
122
122
  end
123
123
 
124
124
  it "should instantiate from coordinates x,y" do
125
- point = Point.from_coordinates([1.6,2.8],123)
125
+ point = GeoRuby::SimpleFeatures::Point.from_coordinates([1.6,2.8],123)
126
126
  point.x.should eql(1.6)
127
127
  point.y.should eql(2.8)
128
128
  point.should_not be_with_z
@@ -131,7 +131,7 @@ describe Point do
131
131
  end
132
132
 
133
133
  it "should instantiate from coordinates x,y,z" do
134
- point = Point.from_coordinates([1.6,2.8,3.4],123, true)
134
+ point = GeoRuby::SimpleFeatures::Point.from_coordinates([1.6,2.8,3.4],123, true)
135
135
  point.x.should eql(1.6)
136
136
  point.y.should eql(2.8)
137
137
  point.z.should eql(3.4)
@@ -140,7 +140,7 @@ describe Point do
140
140
  end
141
141
 
142
142
  it "should instantiate from coordinates x,y,z,m" do
143
- point = Point.from_coordinates([1.6,2.8,3.4,15],123, true, true)
143
+ point = GeoRuby::SimpleFeatures::Point.from_coordinates([1.6,2.8,3.4,15],123, true, true)
144
144
  point.x.should eql(1.6)
145
145
  point.y.should eql(2.8)
146
146
  point.z.should eql(3.4)
@@ -151,65 +151,65 @@ describe Point do
151
151
  end
152
152
 
153
153
  it "should have a bbox" do
154
- bbox = Point.from_x_y_z_m(-1.6,2.8,-3.4,15,123).bounding_box
154
+ bbox = GeoRuby::SimpleFeatures::Point.from_x_y_z_m(-1.6,2.8,-3.4,15,123).bounding_box
155
155
  bbox.length.should eql(2)
156
- bbox[0].should == Point.from_x_y_z(-1.6,2.8,-3.4)
157
- bbox[1].should == Point.from_x_y_z(-1.6,2.8,-3.4)
156
+ bbox[0].should == GeoRuby::SimpleFeatures::Point.from_x_y_z(-1.6,2.8,-3.4)
157
+ bbox[1].should == GeoRuby::SimpleFeatures::Point.from_x_y_z(-1.6,2.8,-3.4)
158
158
  end
159
159
 
160
160
  it "should parse lat long" do
161
- Point.from_latlong("-20° 47' 26.37","-20° 47' 26.37").x.should be_within(0.00001).of(-20.790658)
162
- Point.from_latlong("20° 47' 26.378","20° 47' 26.378").y.should be_within(0.00001).of(20.790658)
161
+ GeoRuby::SimpleFeatures::Point.from_latlong("-20° 47' 26.37","-20° 47' 26.37").x.should be_within(0.00001).of(-20.790658)
162
+ GeoRuby::SimpleFeatures::Point.from_latlong("20° 47' 26.378","20° 47' 26.378").y.should be_within(0.00001).of(20.790658)
163
163
  end
164
164
 
165
165
  it "should parse lat long w/o sec" do
166
- Point.from_latlong("-20°47′26″","-20°47′26″").x.should be_within(0.00001).of(-20.790555)
167
- Point.from_latlong("20°47′26″","20°47′26″").y.should be_within(0.00001).of(20.790555)
166
+ GeoRuby::SimpleFeatures::Point.from_latlong("-20°47′26″","-20°47′26″").x.should be_within(0.00001).of(-20.790555)
167
+ GeoRuby::SimpleFeatures::Point.from_latlong("20°47′26″","20°47′26″").y.should be_within(0.00001).of(20.790555)
168
168
  end
169
169
 
170
170
  it "should accept with W or S notation" do
171
- Point.from_latlong("20° 47' 26.37 W","20° 47' 26.37 S").x.should be_within(0.00001).of(-20.790658)
172
- Point.from_latlong("20° 47' 26.37 W","20° 47' 26.37 S").y.should be_within(0.00001).of(-20.790658)
171
+ GeoRuby::SimpleFeatures::Point.from_latlong("20° 47' 26.37 W","20° 47' 26.37 S").x.should be_within(0.00001).of(-20.790658)
172
+ GeoRuby::SimpleFeatures::Point.from_latlong("20° 47' 26.37 W","20° 47' 26.37 S").y.should be_within(0.00001).of(-20.790658)
173
173
  end
174
174
 
175
175
  it "should instantiate a point from positive degrees" do
176
- point = Point.from_latlong('47`20 06.09E','22`50 77.35N')
176
+ point = GeoRuby::SimpleFeatures::Point.from_latlong('47`20 06.09E','22`50 77.35N')
177
177
  point.y.should be_within(0.000001).of(22.8548194)
178
178
  point.x.should be_within(0.000001).of(47.335025)
179
179
  end
180
180
 
181
181
  it "should instantiate a point from negative degrees" do
182
- point = Point.from_latlong('47`20 06.09W','22`50 77.35S')
182
+ point = GeoRuby::SimpleFeatures::Point.from_latlong('47`20 06.09W','22`50 77.35S')
183
183
  point.y.should be_within(0.000001).of(-22.8548194)
184
184
  point.x.should be_within(0.000001).of(-47.335025)
185
185
  end
186
186
 
187
187
  it "should print out nicely" do
188
- Point.from_x_y(47.88, -20.1).as_latlong.should eql("47°52′48″, -20°06′00″")
188
+ GeoRuby::SimpleFeatures::Point.from_x_y(47.88, -20.1).as_latlong.should eql("47°52′48″, -20°06′00″")
189
189
  end
190
190
 
191
191
  it "should print out nicely" do
192
- Point.from_x_y(-20.78, 20.78).as_latlong(:full => true).should eql("-20°46′48.00″, 20°46′48.00″")
192
+ GeoRuby::SimpleFeatures::Point.from_x_y(-20.78, 20.78).as_latlong(:full => true).should eql("-20°46′48.00″, 20°46′48.00″")
193
193
  end
194
194
 
195
195
  it "should print out nicely" do
196
- Point.from_x_y(47.11, -20.2).as_latlong(:full => true).should eql("47°06′36.00″, -20°11′60.00″")
196
+ GeoRuby::SimpleFeatures::Point.from_x_y(47.11, -20.2).as_latlong(:full => true).should eql("47°06′36.00″, -20°11′60.00″")
197
197
  end
198
198
 
199
199
  it "should print out nicely" do
200
- Point.from_x_y(47.11, -20.2).as_latlong(:coord => true).should eql("47°06′36″N, 20°11′60″W")
200
+ GeoRuby::SimpleFeatures::Point.from_x_y(47.11, -20.2).as_latlong(:coord => true).should eql("47°06′36″N, 20°11′60″W")
201
201
  end
202
202
 
203
203
  it "should print out nicely" do
204
- Point.from_x_y(-47.11, 20.2).as_latlong(:full => true,:coord => true).should eql("47°06′36.00″S, 20°11′60.00″E")
204
+ GeoRuby::SimpleFeatures::Point.from_x_y(-47.11, 20.2).as_latlong(:full => true,:coord => true).should eql("47°06′36.00″S, 20°11′60.00″E")
205
205
  end
206
206
 
207
207
  end
208
208
 
209
209
  describe " > Distance & Bearing" do
210
210
 
211
- let(:p1) { Point.from_x_y(1,1) }
212
- let(:p2) { Point.from_x_y(2,2) }
211
+ let(:p1) { GeoRuby::SimpleFeatures::Point.from_x_y(1,1) }
212
+ let(:p2) { GeoRuby::SimpleFeatures::Point.from_x_y(2,2) }
213
213
 
214
214
  it "and a 3th grade child should calculate euclidian distance" do
215
215
  p1.euclidian_distance(p2).
@@ -227,8 +227,8 @@ describe Point do
227
227
  end
228
228
 
229
229
  describe "Orthogonal Distance" do
230
- let(:line) { LineString.from_coordinates([[0,0],[1,3]], 4326) }
231
- let(:line2) { LineString.from_coordinates([[1,1],[1,2]], 4326) }
230
+ let(:line) { GeoRuby::SimpleFeatures::LineString.from_coordinates([[0,0],[1,3]], 4326) }
231
+ let(:line2) { GeoRuby::SimpleFeatures::LineString.from_coordinates([[1,1],[1,2]], 4326) }
232
232
 
233
233
  it "should calcula orthogonal distance from a line (90 deg)" do
234
234
  p1.orthogonal_distance(line).should be_within(0.001).of(1.414)
@@ -257,22 +257,22 @@ describe Point do
257
257
  end
258
258
 
259
259
  it "should calculate the bearing from apoint to another in degrees" do
260
- p3 = Point.from_x_y(1,-1)
260
+ p3 = GeoRuby::SimpleFeatures::Point.from_x_y(1,-1)
261
261
  p1.bearing_to(p3).should be_within(0.01).of(180.0)
262
262
  end
263
263
 
264
264
  it "should calculate the bearing from apoint to another in degrees" do
265
- p3 = Point.from_x_y(-1,-1)
265
+ p3 = GeoRuby::SimpleFeatures::Point.from_x_y(-1,-1)
266
266
  p1.bearing_to(p3).should be_within(0.01).of(225.0)
267
267
  end
268
268
 
269
269
  it "should calculate the bearing from apoint to another in degrees" do
270
- p3 = Point.from_x_y(-1,1)
270
+ p3 = GeoRuby::SimpleFeatures::Point.from_x_y(-1,1)
271
271
  p1.bearing_to(p3).should be_within(0.01).of(270.0)
272
272
  end
273
273
 
274
274
  it "should calculate the bearing from apoint to another in degrees" do
275
- p3 = Point.from_x_y(2,-1)
275
+ p3 = GeoRuby::SimpleFeatures::Point.from_x_y(2,-1)
276
276
  p1.bearing_to(p3).should be_within(0.0001).of(153.4349488)
277
277
  end
278
278
 
@@ -285,7 +285,7 @@ describe Point do
285
285
  end
286
286
 
287
287
  it "should calculate the bearing from apoint to another in degrees" do
288
- p3 = Point.from_x_y(-1,1)
288
+ p3 = GeoRuby::SimpleFeatures::Point.from_x_y(-1,1)
289
289
  p1.bearing_text(p3).should eql(:w)
290
290
  end
291
291
 
@@ -293,7 +293,7 @@ describe Point do
293
293
 
294
294
  describe "> Export Formats" do
295
295
 
296
- let(:point) { Point.from_x_y( -11.2431, 32.3141 ) }
296
+ let(:point) { GeoRuby::SimpleFeatures::Point.from_x_y( -11.2431, 32.3141 ) }
297
297
 
298
298
  it "should print out as array" do
299
299
 
@@ -304,19 +304,19 @@ describe Point do
304
304
  end
305
305
 
306
306
  it "should printoout as binary" do
307
- Point.from_x_y(12.4,45.3,123).as_hex_ewkb.should eql("01010000207B000000CDCCCCCCCCCC28406666666666A64640")
308
- point = Point.from_x_y_z_m(12.4,45.3,-3.5,15,123)
307
+ GeoRuby::SimpleFeatures::Point.from_x_y(12.4,45.3,123).as_hex_ewkb.should eql("01010000207B000000CDCCCCCCCCCC28406666666666A64640")
308
+ point = GeoRuby::SimpleFeatures::Point.from_x_y_z_m(12.4,45.3,-3.5,15,123)
309
309
  point.as_hex_ewkb.should eql("01010000E07B000000CDCCCCCCCCCC28406666666666A646400000000000000CC00000000000002E40")
310
310
  point.as_hex_wkb.should eql("0101000000CDCCCCCCCCCC28406666666666A64640")
311
311
  end
312
312
 
313
313
  it "should printoout as text" do
314
- Point.from_x_y(12.4,45.3,123).as_ewkt.should eql("SRID=123;POINT(12.4 45.3)")
315
- point = Point.from_x_y_z(12.4,45.3,-3.5,123)
314
+ GeoRuby::SimpleFeatures::Point.from_x_y(12.4,45.3,123).as_ewkt.should eql("SRID=123;POINT(12.4 45.3)")
315
+ point = GeoRuby::SimpleFeatures::Point.from_x_y_z(12.4,45.3,-3.5,123)
316
316
  point.as_ewkt.should eql("SRID=123;POINT(12.4 45.3 -3.5)")
317
317
  point.as_wkt.should eql("POINT(12.4 45.3)")
318
318
  point.as_ewkt(false,true).should eql("POINT(12.4 45.3 -3.5)")
319
- point = Point.from_x_y_m(12.4,45.3,-3.5,123)
319
+ point = GeoRuby::SimpleFeatures::Point.from_x_y_m(12.4,45.3,-3.5,123)
320
320
  point.as_ewkt.should eql("SRID=123;POINTM(12.4 45.3 -3.5)")
321
321
  point.as_ewkt(true,true,false).should eql("SRID=123;POINT(12.4 45.3)")
322
322
  end