rgeo 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,76 @@
1
+ # -----------------------------------------------------------------------------
2
+ #
3
+ # Tests for OGC CS classes
4
+ #
5
+ # -----------------------------------------------------------------------------
6
+ # Copyright 2010 Daniel Azuma
7
+ #
8
+ # All rights reserved.
9
+ #
10
+ # Redistribution and use in source and binary forms, with or without
11
+ # modification, are permitted provided that the following conditions are met:
12
+ #
13
+ # * Redistributions of source code must retain the above copyright notice,
14
+ # this list of conditions and the following disclaimer.
15
+ # * Redistributions in binary form must reproduce the above copyright notice,
16
+ # this list of conditions and the following disclaimer in the documentation
17
+ # and/or other materials provided with the distribution.
18
+ # * Neither the name of the copyright holder, nor the names of any other
19
+ # contributors to this software, may be used to endorse or promote products
20
+ # derived from this software without specific prior written permission.
21
+ #
22
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
+ # POSSIBILITY OF SUCH DAMAGE.
33
+ # -----------------------------------------------------------------------------
34
+ ;
35
+
36
+
37
+ require 'test/unit'
38
+ require 'rgeo'
39
+
40
+
41
+ module RGeo
42
+ module Tests # :nodoc:
43
+ module CoordSys # :nodoc:
44
+
45
+ class TestProj4SRSData < ::Test::Unit::TestCase # :nodoc:
46
+
47
+
48
+ def test_epsg_4326
49
+ db_ = ::RGeo::CoordSys::SRSDatabase::Proj4Data.new('epsg')
50
+ entry_ = db_.get(4326)
51
+ assert_equal('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs', entry_.proj4.original_str)
52
+ assert_equal('WGS 84', entry_.name)
53
+ end
54
+
55
+
56
+ def test_epsg_3785
57
+ db_ = ::RGeo::CoordSys::SRSDatabase::Proj4Data.new('epsg')
58
+ entry_ = db_.get(3785)
59
+ assert_equal('+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs', entry_.proj4.original_str)
60
+ assert_equal('Popular Visualisation CRS / Mercator (deprecated)', entry_.name)
61
+ end
62
+
63
+
64
+ def test_nad83_4601
65
+ db_ = ::RGeo::CoordSys::SRSDatabase::Proj4Data.new('nad83')
66
+ entry_ = db_.get(4601)
67
+ assert_equal('+proj=lcc +datum=NAD83 +lon_0=-120d50 +lat_1=48d44 +lat_2=47d30 +lat_0=47 +x_0=500000 +y_0=0 +no_defs', entry_.proj4.original_str)
68
+ assert_equal('4601: washington north: nad83', entry_.name)
69
+ end
70
+
71
+
72
+ end
73
+
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,70 @@
1
+ # -----------------------------------------------------------------------------
2
+ #
3
+ # Tests for OGC CS classes
4
+ #
5
+ # -----------------------------------------------------------------------------
6
+ # Copyright 2010 Daniel Azuma
7
+ #
8
+ # All rights reserved.
9
+ #
10
+ # Redistribution and use in source and binary forms, with or without
11
+ # modification, are permitted provided that the following conditions are met:
12
+ #
13
+ # * Redistributions of source code must retain the above copyright notice,
14
+ # this list of conditions and the following disclaimer.
15
+ # * Redistributions in binary form must reproduce the above copyright notice,
16
+ # this list of conditions and the following disclaimer in the documentation
17
+ # and/or other materials provided with the distribution.
18
+ # * Neither the name of the copyright holder, nor the names of any other
19
+ # contributors to this software, may be used to endorse or promote products
20
+ # derived from this software without specific prior written permission.
21
+ #
22
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
+ # POSSIBILITY OF SUCH DAMAGE.
33
+ # -----------------------------------------------------------------------------
34
+ ;
35
+
36
+
37
+ require 'test/unit'
38
+ require 'rgeo'
39
+
40
+
41
+ module RGeo
42
+ module Tests # :nodoc:
43
+ module CoordSys # :nodoc:
44
+
45
+ class TestSrOrg < ::Test::Unit::TestCase # :nodoc:
46
+
47
+
48
+ def test_epsg_4326
49
+ db_ = ::RGeo::CoordSys::SRSDatabase::SrOrg.new('epsg')
50
+ entry_ = db_.get(4326)
51
+ assert_equal('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs', entry_.proj4.original_str)
52
+ assert_kind_of(::RGeo::CoordSys::CS::GeographicCoordinateSystem, entry_.coord_sys)
53
+ assert_equal('WGS 84', entry_.name)
54
+ end
55
+
56
+
57
+ def test_epsg_3785
58
+ db_ = ::RGeo::CoordSys::SRSDatabase::SrOrg.new('epsg')
59
+ entry_ = db_.get(3785)
60
+ assert_equal('+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378137 +b=6378137 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs', entry_.proj4.original_str)
61
+ assert_kind_of(::RGeo::CoordSys::CS::ProjectedCoordinateSystem, entry_.coord_sys)
62
+ assert_equal('Popular Visualisation CRS / Mercator', entry_.name)
63
+ end
64
+
65
+
66
+ end
67
+
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,82 @@
1
+ # -----------------------------------------------------------------------------
2
+ #
3
+ # Tests for OGC CS classes
4
+ #
5
+ # -----------------------------------------------------------------------------
6
+ # Copyright 2010 Daniel Azuma
7
+ #
8
+ # All rights reserved.
9
+ #
10
+ # Redistribution and use in source and binary forms, with or without
11
+ # modification, are permitted provided that the following conditions are met:
12
+ #
13
+ # * Redistributions of source code must retain the above copyright notice,
14
+ # this list of conditions and the following disclaimer.
15
+ # * Redistributions in binary form must reproduce the above copyright notice,
16
+ # this list of conditions and the following disclaimer in the documentation
17
+ # and/or other materials provided with the distribution.
18
+ # * Neither the name of the copyright holder, nor the names of any other
19
+ # contributors to this software, may be used to endorse or promote products
20
+ # derived from this software without specific prior written permission.
21
+ #
22
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
+ # POSSIBILITY OF SUCH DAMAGE.
33
+ # -----------------------------------------------------------------------------
34
+ ;
35
+
36
+
37
+ require 'test/unit'
38
+ require 'rgeo'
39
+
40
+
41
+ module RGeo
42
+ module Tests # :nodoc:
43
+ module CoordSys # :nodoc:
44
+
45
+ class TestUrlReader < ::Test::Unit::TestCase # :nodoc:
46
+
47
+
48
+ def test_sr_org_epsg_4326_ogcwkt
49
+ db_ = ::RGeo::CoordSys::SRSDatabase::UrlReader.new
50
+ entry_ = db_.get('http://spatialreference.org/ref/epsg/4326/ogcwkt/')
51
+ assert_kind_of(::RGeo::CoordSys::CS::GeographicCoordinateSystem, entry_.coord_sys)
52
+ assert_equal('WGS 84', entry_.name)
53
+ end
54
+
55
+
56
+ def test_sr_org_epsg_4326_proj4
57
+ db_ = ::RGeo::CoordSys::SRSDatabase::UrlReader.new
58
+ entry_ = db_.get('http://spatialreference.org/ref/epsg/4326/proj4/')
59
+ assert_equal('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs', entry_.proj4.original_str)
60
+ end
61
+
62
+
63
+ def test_sr_org_epsg_3785_ogcwkt
64
+ db_ = ::RGeo::CoordSys::SRSDatabase::UrlReader.new
65
+ entry_ = db_.get('http://spatialreference.org/ref/epsg/3785/ogcwkt/')
66
+ assert_kind_of(::RGeo::CoordSys::CS::ProjectedCoordinateSystem, entry_.coord_sys)
67
+ assert_equal('Popular Visualisation CRS / Mercator', entry_.name)
68
+ end
69
+
70
+
71
+ def test_sr_org_epsg_3785_proj4
72
+ db_ = ::RGeo::CoordSys::SRSDatabase::UrlReader.new
73
+ entry_ = db_.get('http://spatialreference.org/ref/epsg/3785/proj4/')
74
+ assert_equal('+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378137 +b=6378137 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs', entry_.proj4.original_str)
75
+ end
76
+
77
+
78
+ end
79
+
80
+ end
81
+ end
82
+ end
@@ -55,6 +55,30 @@ module RGeo
55
55
  include ::RGeo::Tests::Common::PolygonTests
56
56
 
57
57
 
58
+ def test_intersection
59
+ point1_ = @factory.point(0, 0)
60
+ point2_ = @factory.point(0, 2)
61
+ point3_ = @factory.point(2, 2)
62
+ point4_ = @factory.point(2, 0)
63
+ poly1_ = @factory.polygon(@factory.linear_ring([point1_, point2_, point3_, point4_]))
64
+ poly2_ = @factory.polygon(@factory.linear_ring([point1_, point2_, point4_]))
65
+ poly3_ = poly1_.intersection(poly2_)
66
+ assert_equal(poly2_, poly3_)
67
+ end
68
+
69
+
70
+ def test_union
71
+ point1_ = @factory.point(0, 0)
72
+ point2_ = @factory.point(0, 2)
73
+ point3_ = @factory.point(2, 2)
74
+ point4_ = @factory.point(2, 0)
75
+ poly1_ = @factory.polygon(@factory.linear_ring([point1_, point2_, point3_, point4_]))
76
+ poly2_ = @factory.polygon(@factory.linear_ring([point1_, point2_, point4_]))
77
+ poly3_ = poly1_.union(poly2_)
78
+ assert_equal(poly1_, poly3_)
79
+ end
80
+
81
+
58
82
  end
59
83
 
60
84
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 1
9
- version: 0.2.1
8
+ - 2
9
+ version: 0.2.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Daniel Azuma
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-09 00:00:00 -08:00
17
+ date: 2010-12-15 00:00:00 -08:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
@@ -38,7 +38,15 @@ files:
38
38
  - lib/rgeo/cartesian/feature_methods.rb
39
39
  - lib/rgeo/cartesian/interface.rb
40
40
  - lib/rgeo/cartesian.rb
41
+ - lib/rgeo/coord_sys/cs/entities.rb
42
+ - lib/rgeo/coord_sys/cs/factories.rb
43
+ - lib/rgeo/coord_sys/cs/wkt_parser.rb
41
44
  - lib/rgeo/coord_sys/proj4.rb
45
+ - lib/rgeo/coord_sys/srs_database/active_record_table.rb
46
+ - lib/rgeo/coord_sys/srs_database/interface.rb
47
+ - lib/rgeo/coord_sys/srs_database/proj4_data.rb
48
+ - lib/rgeo/coord_sys/srs_database/sr_org.rb
49
+ - lib/rgeo/coord_sys/srs_database/url_reader.rb
42
50
  - lib/rgeo/coord_sys.rb
43
51
  - lib/rgeo/error.rb
44
52
  - lib/rgeo/feature/curve.rb
@@ -100,7 +108,12 @@ files:
100
108
  - test/common/multi_polygon_tests.rb
101
109
  - test/common/point_tests.rb
102
110
  - test/common/polygon_tests.rb
111
+ - test/coord_sys/tc_active_record_table.rb
112
+ - test/coord_sys/tc_ogc_cs.rb
103
113
  - test/coord_sys/tc_proj4.rb
114
+ - test/coord_sys/tc_proj4_srs_data.rb
115
+ - test/coord_sys/tc_sr_org.rb
116
+ - test/coord_sys/tc_url_reader.rb
104
117
  - test/geos/tc_factory.rb
105
118
  - test/geos/tc_geometry_collection.rb
106
119
  - test/geos/tc_line_string.rb
@@ -201,7 +214,12 @@ signing_key:
201
214
  specification_version: 3
202
215
  summary: RGeo is a spatial data library for Ruby.
203
216
  test_files:
217
+ - test/coord_sys/tc_active_record_table.rb
218
+ - test/coord_sys/tc_ogc_cs.rb
204
219
  - test/coord_sys/tc_proj4.rb
220
+ - test/coord_sys/tc_proj4_srs_data.rb
221
+ - test/coord_sys/tc_sr_org.rb
222
+ - test/coord_sys/tc_url_reader.rb
205
223
  - test/geos/tc_factory.rb
206
224
  - test/geos/tc_geometry_collection.rb
207
225
  - test/geos/tc_line_string.rb