voruby 1.1.1 → 2.0.0
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/Rakefile.rb +107 -224
- data/lib/misc.rb +1 -0
- data/lib/misc/misc.rb +60 -0
- data/lib/misc/propertyfile.rb +31 -0
- data/lib/symphony.rb +1 -0
- data/lib/symphony/symphony.rb +247 -0
- data/lib/voruby.rb +186 -0
- data/lib/voruby/active_votable/active_votable.rb +468 -347
- data/lib/voruby/adql/1.0/adql.rb +2418 -0
- data/lib/voruby/adql/support.rb +2 -0
- data/lib/voruby/misc.rb +351 -0
- data/lib/voruby/misc/connection_monitor.rb +97 -0
- data/lib/voruby/misc/libxml_ext.rb +121 -0
- data/lib/voruby/misc/rexml_ext.rb +223 -0
- data/lib/voruby/resolver/resolver.rb +12 -0
- data/lib/voruby/resolver/sesame.rb +299 -0
- data/lib/voruby/sky_query/sky_query.rb +192 -0
- data/lib/voruby/stc/1.10/coords.rb +2272 -0
- data/lib/voruby/stc/1.10/region.rb +892 -0
- data/lib/voruby/stc/1.10/stc.rb +3271 -0
- data/lib/voruby/stc/1.30/stc.rb +8666 -0
- data/lib/voruby/stc/support.rb +2 -0
- data/lib/voruby/ucd/ucd.rb +173 -0
- data/lib/voruby/voevent/1.1/voevent.rb +1124 -0
- data/lib/voruby/voevent/support.rb +5 -0
- data/lib/voruby/votable/1.0/votable.rb +1807 -0
- data/lib/voruby/votable/1.1/votable.rb +2100 -0
- data/lib/voruby/votable/votable.rb +305 -0
- data/lib/voruby/wesix/wesix.rb +491 -0
- data/lib/voruby/xlink/1.2/xlink.rb +21 -0
- data/test/voruby/active_votable/complex.vot +60 -0
- data/test/voruby/active_votable/error.vot +6 -0
- data/test/voruby/active_votable/large.vot +130040 -0
- data/test/voruby/active_votable/simple1.vot +38 -0
- data/test/voruby/active_votable/simple2.vot +38 -0
- data/test/voruby/active_votable/test.rb +193 -0
- data/test/voruby/adql/1.0/adql-alias.sql +1 -0
- data/test/voruby/adql/1.0/adql-alias.xml +26 -0
- data/test/voruby/adql/1.0/adql-avg.sql +1 -0
- data/test/voruby/adql/1.0/adql-avg.xml +31 -0
- data/test/voruby/adql/1.0/adql-circle.sql +1 -0
- data/test/voruby/adql/1.0/adql-circle.xml +46 -0
- data/test/voruby/adql/1.0/adql-expr.sql +1 -0
- data/test/voruby/adql/1.0/adql-expr.xml +34 -0
- data/test/voruby/adql/1.0/adql-function.sql +1 -0
- data/test/voruby/adql/1.0/adql-function.xml +41 -0
- data/test/voruby/adql/1.0/adql-group.sql +1 -0
- data/test/voruby/adql/1.0/adql-group.xml +51 -0
- data/test/voruby/adql/1.0/adql-having.sql +1 -0
- data/test/voruby/adql/1.0/adql-having.xml +25 -0
- data/test/voruby/adql/1.0/adql-like.sql +1 -0
- data/test/voruby/adql/1.0/adql-like.xml +17 -0
- data/test/voruby/adql/1.0/adql-order.sql +1 -0
- data/test/voruby/adql/1.0/adql-order.xml +37 -0
- data/test/voruby/adql/1.0/adql-simple.sql +1 -0
- data/test/voruby/adql/1.0/adql-simple.xml +12 -0
- data/test/voruby/adql/1.0/adql-top.sql +1 -0
- data/test/voruby/adql/1.0/adql-top.xml +33 -0
- data/test/voruby/adql/1.0/test.rb +2220 -0
- data/test/voruby/misc/test.rb +32 -0
- data/test/voruby/resolver/sesame/test.rb +56 -0
- data/test/voruby/sky_query/test.rb +107 -0
- data/test/voruby/stc/1.10/coords_test.rb +3704 -0
- data/test/voruby/stc/1.10/region_test.rb +993 -0
- data/test/voruby/stc/1.10/stc-catalog-entry-location.xml +112 -0
- data/test/voruby/stc/1.10/stc-obs-data-location.xml +126 -0
- data/test/voruby/stc/1.10/stc-region-circle.xml +5 -0
- data/test/voruby/stc/1.10/stc-region-convex.xml +11 -0
- data/test/voruby/stc/1.10/stc-region-convexhull.xml +5 -0
- data/test/voruby/stc/1.10/stc-region-ellipse.xml +7 -0
- data/test/voruby/stc/1.10/stc-region-intersection.xml +25 -0
- data/test/voruby/stc/1.10/stc-region-negation.xml +7 -0
- data/test/voruby/stc/1.10/stc-region-polygon.xml +13 -0
- data/test/voruby/stc/1.10/stc-region-sector.xml +6 -0
- data/test/voruby/stc/1.10/stc-region-union.xml +25 -0
- data/test/voruby/stc/1.10/stc-resource-profile.xml +60 -0
- data/test/voruby/stc/1.10/stc-search-location.xml +54 -0
- data/test/voruby/stc/1.10/stc_test.rb +4626 -0
- data/test/voruby/stc/1.30/stc-catalog-entry-location.xml +210 -0
- data/test/voruby/stc/1.30/stc-obs-data-location-arecibo.xml +353 -0
- data/test/voruby/stc/1.30/stc-obs-data-location-fits.xml +250 -0
- data/test/voruby/stc/1.30/stc-obs-data-location-xlink.xml +63 -0
- data/test/voruby/stc/1.30/stc-obs-data-location.xml +216 -0
- data/test/voruby/stc/1.30/stc-resource-profile-unusual-ref-pos.xml +39 -0
- data/test/voruby/stc/1.30/stc-resource-profile.xml +129 -0
- data/test/voruby/stc/1.30/stc-search-location-arecibo.xml +86 -0
- data/test/voruby/stc/1.30/stc-search-location.xml +101 -0
- data/test/voruby/stc/1.30/test.rb +6274 -0
- data/test/voruby/ucd/test.rb +48 -0
- data/test/voruby/voevent/1.1/test.rb +812 -0
- data/test/{voevent/voevent_v1_1.xml → voruby/voevent/1.1/voevent.xml} +2 -2
- data/test/voruby/voregistry/0.3/test.rb +137 -0
- data/test/voruby/votable/1.0/test.rb +714 -0
- data/test/voruby/votable/1.0/votable.basic.xml +660 -0
- data/test/voruby/votable/1.0/votable.html +86 -0
- data/test/voruby/votable/1.0/votable.ns.xml +56 -0
- data/test/voruby/votable/1.1/test.rb +785 -0
- data/test/voruby/votable/1.1/votable.basic.xml +38 -0
- data/test/voruby/votable/1.1/votable.html +86 -0
- data/test/voruby/votable/1.1/votable.ns.xml +56 -0
- data/test/voruby/votable/test.rb +15 -0
- data/test/voruby/wesix/test.rb +268 -0
- data/test/voruby/wesix/testr.fits +28 -0
- metadata +234 -247
- data/REQUIREMENTS +0 -6
- data/lib/voruby/active_votable/loader.rb +0 -5
- data/lib/voruby/adql/adql.rb +0 -2787
- data/lib/voruby/adql/ext.rb +0 -14
- data/lib/voruby/adql/loader.rb +0 -6
- data/lib/voruby/adql/operations.rb +0 -54
- data/lib/voruby/adql/parser.rb +0 -160
- data/lib/voruby/adql/transforms.rb +0 -573
- data/lib/voruby/ext.rb +0 -17
- data/lib/voruby/loader.rb +0 -4
- data/lib/voruby/misc/propertyfile.rb +0 -36
- data/lib/voruby/plastic/applications.rb +0 -174
- data/lib/voruby/plastic/constants.rb +0 -30
- data/lib/voruby/plastic/loader.rb +0 -10
- data/lib/voruby/plastic/plastic.rb +0 -1
- data/lib/voruby/resources/conesearch/conesearch.rb +0 -9
- data/lib/voruby/resources/conesearch/conesearch_v0_2.rb +0 -55
- data/lib/voruby/resources/conesearch/conesearch_v0_3.rb +0 -50
- data/lib/voruby/resources/conesearch/conesearch_v1_0.rb +0 -72
- data/lib/voruby/resources/conesearch/loader.rb +0 -4
- data/lib/voruby/resources/loader.rb +0 -50
- data/lib/voruby/resources/nodes.rb +0 -190
- data/lib/voruby/resources/openskynode/loader.rb +0 -4
- data/lib/voruby/resources/openskynode/openskynode.rb +0 -9
- data/lib/voruby/resources/openskynode/openskynode_v0_1.rb +0 -54
- data/lib/voruby/resources/sia/loader.rb +0 -5
- data/lib/voruby/resources/sia/sia.rb +0 -9
- data/lib/voruby/resources/sia/sia_v0_6.rb +0 -90
- data/lib/voruby/resources/sia/sia_v0_7.rb +0 -89
- data/lib/voruby/resources/sia/sia_v1_0.rb +0 -122
- data/lib/voruby/resources/stsci.rb +0 -59
- data/lib/voruby/resources/vodataservice/coverage_v0_2.rb +0 -195
- data/lib/voruby/resources/vodataservice/coverage_v0_3.rb +0 -158
- data/lib/voruby/resources/vodataservice/loader.rb +0 -5
- data/lib/voruby/resources/vodataservice/vodataservice.rb +0 -9
- data/lib/voruby/resources/vodataservice/vodataservice_v0_4.rb +0 -189
- data/lib/voruby/resources/vodataservice/vodataservice_v0_5.rb +0 -163
- data/lib/voruby/resources/vodataservice/vodataservice_v1_0.rb +0 -221
- data/lib/voruby/resources/voregistry/loader.rb +0 -4
- data/lib/voruby/resources/voregistry/voregistry.rb +0 -9
- data/lib/voruby/resources/voregistry/voregistry_v0_2.rb +0 -40
- data/lib/voruby/resources/voregistry/voregistry_v0_3.rb +0 -30
- data/lib/voruby/resources/voregistry/voregistry_v1_0.rb +0 -86
- data/lib/voruby/resources/voresource/loader.rb +0 -17
- data/lib/voruby/resources/voresource/voresource.rb +0 -9
- data/lib/voruby/resources/voresource/voresource_v0_10.rb +0 -327
- data/lib/voruby/resources/voresource/voresource_v0_9.rb +0 -405
- data/lib/voruby/resources/voresource/voresource_v1_0.rb +0 -230
- data/lib/voruby/services/ext.rb +0 -11
- data/lib/voruby/services/gestalt/footprint.rb +0 -95
- data/lib/voruby/services/gestalt/wcs_fixer.rb +0 -105
- data/lib/voruby/services/gestalt/wesix.rb +0 -155
- data/lib/voruby/services/loader.rb +0 -7
- data/lib/voruby/services/registry/registry.rb +0 -53
- data/lib/voruby/services/resolver/resolver.rb +0 -35
- data/lib/voruby/services/schema/schema.rb +0 -644
- data/lib/voruby/sesame/loader.rb +0 -6
- data/lib/voruby/sesame/sesame_v1_0.rb +0 -64
- data/lib/voruby/simple/loader.rb +0 -6
- data/lib/voruby/simple/parameters.rb +0 -196
- data/lib/voruby/simple/sap.rb +0 -446
- data/lib/voruby/spacetime/loader.rb +0 -3
- data/lib/voruby/spacetime/spacetime.rb +0 -607
- data/lib/voruby/stc/coords_v1_20.rb +0 -900
- data/lib/voruby/stc/loader.rb +0 -55
- data/lib/voruby/stc/region_v1_20.rb +0 -274
- data/lib/voruby/stc/stc_v1_20.rb +0 -1196
- data/lib/voruby/util.rb +0 -27
- data/lib/voruby/voevent/loader.rb +0 -7
- data/lib/voruby/voevent/voevent_v1_0.rb +0 -213
- data/lib/voruby/voevent/voevent_v1_1.rb +0 -196
- data/lib/voruby/votables/chandra.rb +0 -373
- data/lib/voruby/votables/data.rb +0 -179
- data/lib/voruby/votables/galex.rb +0 -377
- data/lib/voruby/votables/int.rb +0 -354
- data/lib/voruby/votables/libxml_parser.rb +0 -411
- data/lib/voruby/votables/libxml_votable.rb +0 -67
- data/lib/voruby/votables/loader.rb +0 -10
- data/lib/voruby/votables/meta.rb +0 -763
- data/lib/voruby/votables/misc.rb +0 -51
- data/lib/voruby/votables/nsa.rb +0 -410
- data/lib/voruby/votables/rexml_parser.rb +0 -408
- data/lib/voruby/votables/rexml_votable.rb +0 -67
- data/lib/voruby/votables/sdss.rb +0 -356
- data/lib/voruby/votables/transforms.rb +0 -388
- data/lib/voruby/votables/tree.rb +0 -45
- data/lib/voruby/votables/types.rb +0 -391
- data/lib/voruby/votables/votable.rb +0 -687
- data/test/active_votable/database.yml +0 -6
- data/test/active_votable/test.vot +0 -168492
- data/test/active_votable/unittest.rb +0 -41
- data/test/adql/test1.adql +0 -49
- data/test/adql/test2.adql +0 -51
- data/test/adql/test3.adql +0 -81
- data/test/adql/test4.adql +0 -53
- data/test/adql/test5.adql +0 -55
- data/test/adql/test6.adql +0 -18
- data/test/adql/test7.adql +0 -48
- data/test/adql/unittest.rb +0 -1672
- data/test/plastic/test.rb +0 -44
- data/test/plastic/test.vot +0 -5385
- data/test/plastic/unittest.rb +0 -66
- data/test/resources/conesearch/conesearch_v0_3.xml +0 -31
- data/test/resources/conesearch/conesearch_v1_0.xml +0 -86
- data/test/resources/conesearch/unittest_v0_3.rb +0 -22
- data/test/resources/conesearch/unittest_v1_0.rb +0 -24
- data/test/resources/openskynode/open_sky_node_v0_1.xml +0 -32
- data/test/resources/openskynode/unittest_v0_1.rb +0 -31
- data/test/resources/sia/simple_image_access_v0_7.xml +0 -36
- data/test/resources/sia/simple_image_access_v1_0.xml +0 -122
- data/test/resources/sia/unittest_v0_7.rb +0 -24
- data/test/resources/sia/unittest_v1_0.rb +0 -29
- data/test/resources/stsci.xml +0 -336
- data/test/resources/unittest_stsci.rb +0 -25
- data/test/resources/vodataservice/catalog_service_resource_v1_0.xml +0 -128
- data/test/resources/vodataservice/data_collection_resource_v0_5.xml +0 -54
- data/test/resources/vodataservice/data_collection_resource_v1_0.xml +0 -117
- data/test/resources/vodataservice/data_service_resource_v1_0.xml +0 -115
- data/test/resources/vodataservice/sky_service_resource_v0_10.xml +0 -45
- data/test/resources/vodataservice/table_service_resource_v1_0.xml +0 -122
- data/test/resources/vodataservice/tabular_sky_service_resource_v0_10.xml +0 -60
- data/test/resources/vodataservice/unittest_v0_5.rb +0 -126
- data/test/resources/vodataservice/unittest_v1_0.rb +0 -151
- data/test/resources/voregistry/authority_resource_v0_3.xml +0 -20
- data/test/resources/voregistry/authority_resource_v1_0.xml +0 -82
- data/test/resources/voregistry/registry_service_v0_3.xml +0 -20
- data/test/resources/voregistry/registry_service_v1_0.xml +0 -107
- data/test/resources/voregistry/unittest_v0_3.rb +0 -31
- data/test/resources/voregistry/unittest_v1_0.rb +0 -34
- data/test/resources/voresource/organisation_resource_v1_0.xml +0 -90
- data/test/resources/voresource/resource_organisation_v0_10.xml +0 -22
- data/test/resources/voresource/resource_service_v0_10.xml +0 -19
- data/test/resources/voresource/resource_v0_10.xml +0 -19
- data/test/resources/voresource/resource_v1_0.xml +0 -79
- data/test/resources/voresource/service_resource_v1_0.xml +0 -91
- data/test/resources/voresource/unittest_v0_10.rb +0 -61
- data/test/resources/voresource/unittest_v0_9.rb +0 -4
- data/test/resources/voresource/unittest_v1_0.rb +0 -190
- data/test/services/gestalt/unittest.rb +0 -74
- data/test/services/registry/unittest.rb +0 -34
- data/test/services/resolver/unittest.rb +0 -38
- data/test/simple/unittest.rb +0 -46
- data/test/spacetime/unittest.rb +0 -39
- data/test/stc/catalog_entry_location_v1_20.xml +0 -112
- data/test/stc/obs_data_location_v1_20.xml +0 -108
- data/test/stc/search_location_v1_20.xml +0 -54
- data/test/stc/stc_resource_profile_v1_20.xml +0 -60
- data/test/stc/unittest_v1_20.rb +0 -620
- data/test/voevent/unittest_v1_0.rb +0 -79
- data/test/voevent/unittest_v1_1.rb +0 -70
- data/test/voevent/voevent_v1_0.xml +0 -96
- data/test/votables/test.vot +0 -366
- data/test/votables/unittest.rb +0 -54
@@ -0,0 +1,993 @@
|
|
1
|
+
require 'voruby/stc/1.10/region'
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
include VORuby::STC::V1_10::Region
|
5
|
+
|
6
|
+
module VORuby
|
7
|
+
module STC
|
8
|
+
module V1_10
|
9
|
+
module Region
|
10
|
+
module Test
|
11
|
+
|
12
|
+
class RegionTypeTest < ::Test::Unit::TestCase
|
13
|
+
def test_construction
|
14
|
+
assert_nothing_raised {
|
15
|
+
RegionType.new(:fill_factor => 0.1, :note => 'My note')
|
16
|
+
RegionType.new(:fill_factor => 0.1)
|
17
|
+
RegionType.new(:note => 'My Note')
|
18
|
+
RegionType.new
|
19
|
+
}
|
20
|
+
|
21
|
+
assert_raises ArgumentError do
|
22
|
+
RegionType.new(:fill_factor => 2.0)
|
23
|
+
end
|
24
|
+
|
25
|
+
assert_raises ArgumentError do
|
26
|
+
RegionType.new(:fill_factor => 'blah')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_accessors
|
31
|
+
reg = RegionType.new(:fill_factor => 0.4, :note => 'My note')
|
32
|
+
|
33
|
+
assert_equal 0.4, reg.fill_factor
|
34
|
+
assert_equal 'My note', reg.note
|
35
|
+
|
36
|
+
reg.fill_factor = 0.5
|
37
|
+
assert_equal 0.5, reg.fill_factor
|
38
|
+
reg.note = 'A note'
|
39
|
+
assert_equal 'A note', reg.note
|
40
|
+
|
41
|
+
reg = RegionType.new
|
42
|
+
assert_equal 1.0, reg.fill_factor
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
class ShapeTest < ::Test::Unit::TestCase
|
47
|
+
def test_construction
|
48
|
+
assert_nothing_raised {
|
49
|
+
Shape.new(:coord_system_id => 'system1', :unit => 'm')
|
50
|
+
}
|
51
|
+
|
52
|
+
assert_raises ArgumentError do
|
53
|
+
Shape.new(:unit => 'm')
|
54
|
+
end
|
55
|
+
assert_raises ArgumentError do
|
56
|
+
Shape.new
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_accessors
|
61
|
+
shape = Shape.new(:coord_system_id => 'system1', :unit => 'm')
|
62
|
+
|
63
|
+
assert_equal IdRef.new('system1'), shape.coord_system_id
|
64
|
+
assert_equal PosUnit.new('m'), shape.unit
|
65
|
+
|
66
|
+
shape.coord_system_id = IdRef.new('system2')
|
67
|
+
assert_equal IdRef.new('system2'), shape.coord_system_id
|
68
|
+
shape.unit = PosUnit.new('lyr')
|
69
|
+
assert_equal PosUnit.new('lyr'), shape.unit
|
70
|
+
|
71
|
+
#assert_equal(
|
72
|
+
# "<reg:Shape reg:coord_system_id='system2' reg:unit='lyr' reg:fill_factor='1.0' xmlns:reg='http://www.ivoa.net/xml/STC/STCregion/v1.10'/>",
|
73
|
+
# shape.to_xml.to_s
|
74
|
+
#)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
class CircleTypeTest < ::Test::Unit::TestCase
|
79
|
+
def test_construction
|
80
|
+
assert_nothing_raised {
|
81
|
+
CircleType.new(:coord_system_id => 'system1', :unit => 'm', :center => [1.1, 2.2], :radius => 100.1)
|
82
|
+
}
|
83
|
+
|
84
|
+
assert_raises TypeError do
|
85
|
+
CircleType.new(:coord_system_id => 'system1', :unit => 'm', :center => 'blah', :radius => 100.1)
|
86
|
+
end
|
87
|
+
assert_raises ArgumentError do
|
88
|
+
CircleType.new(:coord_system_id => 'system1', :unit => 'm', :center => [1.1, 2.2], :radius => 'blah')
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_accessors
|
93
|
+
circle = CircleType.new(:coord_system_id => 'system1', :unit => 'm', :center => [1.1, 2.2], :radius => 100.1)
|
94
|
+
|
95
|
+
assert_equal Double2.new([1.1, 2.2]), circle.center
|
96
|
+
assert_equal 100.1, circle.radius
|
97
|
+
|
98
|
+
circle.center = Double2.new([5.5, 5.5])
|
99
|
+
assert_equal Double2.new([5.5, 5.5]), circle.center
|
100
|
+
circle.radius = 10.2
|
101
|
+
assert_equal 10.2, circle.radius
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_relationships
|
105
|
+
assert_kind_of Shape, CircleType.new(:coord_system_id => 'system1', :unit => 'm', :center => [1.1, 2.2], :radius => 100.1)
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_xml
|
109
|
+
c1 = CircleType.new(:coord_system_id => 'system1', :unit => 'm', :center => [1.1, 2.2], :radius => 100.1)
|
110
|
+
|
111
|
+
c2 = CircleType.from_xml(c1.to_xml)
|
112
|
+
assert_equal c1, c2
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_s
|
116
|
+
c = CircleType.new(:coord_system_id => 'J2000', :unit => 'm', :center => [1.1, 2.2], :radius => 100.1)
|
117
|
+
assert_equal 'CIRCLE J2000 1.1 2.2 100.1', c.to_s
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
class EllipseTypeTest < ::Test::Unit::TestCase
|
122
|
+
def test_construction
|
123
|
+
assert_nothing_raised {
|
124
|
+
EllipseType.new(
|
125
|
+
:coord_system_id => 'system1',
|
126
|
+
:unit => 'm',
|
127
|
+
:center => [1.1, 2.2],
|
128
|
+
:radius => 100.1,
|
129
|
+
:minor_radius => 50.2,
|
130
|
+
:pos_angle => 81.2,
|
131
|
+
:pos_angle_unit => 'rad'
|
132
|
+
)
|
133
|
+
|
134
|
+
EllipseType.new(
|
135
|
+
:coord_system_id => 'system1',
|
136
|
+
:unit => 'm',
|
137
|
+
:center => [1.1, 2.2],
|
138
|
+
:radius => 100.1,
|
139
|
+
:minor_radius => 50.2,
|
140
|
+
:pos_angle => 81.2
|
141
|
+
)
|
142
|
+
}
|
143
|
+
|
144
|
+
assert_raises ArgumentError do
|
145
|
+
EllipseType.new(
|
146
|
+
:coord_system_id => 'system1',
|
147
|
+
:unit => 'm',
|
148
|
+
:center => [1.1, 2.2],
|
149
|
+
:radius => 100.1,
|
150
|
+
:minor_radius => 50.2,
|
151
|
+
:pos_angle => 81.2,
|
152
|
+
:pos_angle_unit => PosUnit.new('m')
|
153
|
+
)
|
154
|
+
end
|
155
|
+
|
156
|
+
assert_raises ArgumentError do
|
157
|
+
EllipseType.new(
|
158
|
+
:coord_system_id => 'system1',
|
159
|
+
:unit => 'm',
|
160
|
+
:center => [1.1, 2.2],
|
161
|
+
:radius => 100.1,
|
162
|
+
:minor_radius => 50.2,
|
163
|
+
:pos_angle => 'blah',
|
164
|
+
:pos_angle_unit => 'rad'
|
165
|
+
)
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
def test_accessors
|
170
|
+
e = EllipseType.new(
|
171
|
+
:coord_system_id => 'system1',
|
172
|
+
:unit => 'm',
|
173
|
+
:center => [1.1, 2.2],
|
174
|
+
:radius => 100.1,
|
175
|
+
:minor_radius => 50.2,
|
176
|
+
:pos_angle => 81.2,
|
177
|
+
:pos_angle_unit => 'rad'
|
178
|
+
)
|
179
|
+
|
180
|
+
assert_equal IdRef.new('system1'), e.coord_system_id
|
181
|
+
assert_equal PosUnit.new('m'), e.unit
|
182
|
+
assert_equal [1.1, 2.2], e.center
|
183
|
+
assert_equal 100.1, e.radius
|
184
|
+
assert_equal 50.2, e.minor_radius
|
185
|
+
assert_equal 81.2, e.pos_angle
|
186
|
+
assert_equal AngleUnit.new('rad'), e.pos_angle_unit
|
187
|
+
|
188
|
+
e.minor_radius = 150.1
|
189
|
+
assert_equal 150.1, e.minor_radius
|
190
|
+
e.pos_angle = 12.2
|
191
|
+
assert_equal 12.2, e.pos_angle
|
192
|
+
e.pos_angle_unit = 'deg'
|
193
|
+
assert_equal AngleUnit.new('deg'), e.pos_angle_unit
|
194
|
+
end
|
195
|
+
|
196
|
+
def test_relationships
|
197
|
+
e = EllipseType.new(
|
198
|
+
:coord_system_id => 'system1',
|
199
|
+
:unit => 'm',
|
200
|
+
:center => [1.1, 2.2],
|
201
|
+
:radius => 100.1,
|
202
|
+
:minor_radius => 50.2,
|
203
|
+
:pos_angle => 81.2,
|
204
|
+
:pos_angle_unit => 'rad'
|
205
|
+
)
|
206
|
+
assert_kind_of CircleType, e
|
207
|
+
end
|
208
|
+
|
209
|
+
def test_xml
|
210
|
+
e1 = EllipseType.new(
|
211
|
+
:coord_system_id => 'system1',
|
212
|
+
:unit => 'm',
|
213
|
+
:center => [1.1, 2.2],
|
214
|
+
:radius => 100.1,
|
215
|
+
:minor_radius => 50.2,
|
216
|
+
:pos_angle => 81.2,
|
217
|
+
:pos_angle_unit => 'rad'
|
218
|
+
)
|
219
|
+
|
220
|
+
e2 = EllipseType.from_xml(e1.to_xml)
|
221
|
+
assert_equal e1, e2
|
222
|
+
end
|
223
|
+
|
224
|
+
def test_s
|
225
|
+
e = EllipseType.new(
|
226
|
+
:coord_system_id => 'J2000',
|
227
|
+
:unit => 'm',
|
228
|
+
:center => [1.1, 2.2],
|
229
|
+
:radius => 100.1,
|
230
|
+
:minor_radius => 50.2,
|
231
|
+
:pos_angle => 81.2,
|
232
|
+
:pos_angle_unit => 'rad'
|
233
|
+
)
|
234
|
+
assert_equal 'ELLIPSE J2000 1.1 2.2 100.1 50.2 81.2', e.to_s
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
class SmallCircleTypeTest < ::Test::Unit::TestCase
|
239
|
+
def test_construction
|
240
|
+
assert_nothing_raised {
|
241
|
+
SmallCircle.new
|
242
|
+
SmallCircle.new(Double2.new([1.1, 2.2]))
|
243
|
+
SmallCircle.new(:pole => Double2.new([1.1, 2.2]))
|
244
|
+
}
|
245
|
+
|
246
|
+
assert_raises TypeError do
|
247
|
+
SmallCircle.new(1.12)
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
def test_accessors
|
252
|
+
c = SmallCircle.new(Double2.new([1.1, 2.2]))
|
253
|
+
|
254
|
+
assert_equal Double2.new([1.1, 2.2]), c.pole
|
255
|
+
|
256
|
+
c.pole = Double2.new([2.2, 3.3])
|
257
|
+
assert_equal Double2.new([2.2, 3.3]), c.pole
|
258
|
+
end
|
259
|
+
|
260
|
+
def test_xml
|
261
|
+
c1 = SmallCircle.new(Double2.new([1.1, 2.2]))
|
262
|
+
|
263
|
+
c2 = SmallCircle.from_xml(c1.to_xml)
|
264
|
+
assert_equal c1, c2
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
class VertexTest < ::Test::Unit::TestCase
|
269
|
+
def test_construction
|
270
|
+
assert_nothing_raised {
|
271
|
+
Vertex.new(:position => Double2.new([1.2, 3.3]), :small_circle => SmallCircle.new([2.3, 4.5]))
|
272
|
+
Vertex.new(:position => Double2.new([1.2, 3.3]))
|
273
|
+
}
|
274
|
+
|
275
|
+
assert_raises ArgumentError do
|
276
|
+
Vertex.new
|
277
|
+
end
|
278
|
+
assert_raises ArgumentError do
|
279
|
+
Vertex.new(:small_circle => SmallCircle.new([2.3, 4.5]))
|
280
|
+
end
|
281
|
+
assert_raises TypeError do
|
282
|
+
Vertex.new(:position => 'blah')
|
283
|
+
end
|
284
|
+
assert_raises TypeError do
|
285
|
+
Vertex.new(:position => Double2.new([1.2, 3.3]), :small_circle => [1.1, 2.3])
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
def test_accessors
|
290
|
+
v = Vertex.new(:position => Double2.new([1.2, 3.3]), :small_circle => SmallCircle.new([2.3, 4.5]))
|
291
|
+
|
292
|
+
assert_equal Double2.new([1.2, 3.3]), v.position
|
293
|
+
assert_equal SmallCircle.new([2.3, 4.5]), v.small_circle
|
294
|
+
|
295
|
+
v.position = Double2.new([5.2, 9.1])
|
296
|
+
assert_equal Double2.new([5.2, 9.1]), v.position
|
297
|
+
v.small_circle = SmallCircle.new([8.2, 7.8])
|
298
|
+
assert_equal SmallCircle.new([8.2, 7.8]), v.small_circle
|
299
|
+
end
|
300
|
+
|
301
|
+
def test_xml
|
302
|
+
v1 = Vertex.new(:position => Double2.new([1.2, 3.3]), :small_circle => SmallCircle.new([2.3, 4.5]))
|
303
|
+
|
304
|
+
v2 = Vertex.from_xml(v1.to_xml)
|
305
|
+
assert_equal v1, v2
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
class PolygonTypeTest < ::Test::Unit::TestCase
|
310
|
+
def test_construction
|
311
|
+
assert_nothing_raised {
|
312
|
+
PolygonType.new(
|
313
|
+
:coord_system_id => 'system1',
|
314
|
+
:unit => 'm',
|
315
|
+
:vertices => [Vertex.new(:position => [1.1, 1.2]), Vertex.new(:position => [2.2, 3.4])]
|
316
|
+
)
|
317
|
+
}
|
318
|
+
|
319
|
+
assert_raises TypeError do
|
320
|
+
PolygonType.new(
|
321
|
+
:coord_system_id => 'system1',
|
322
|
+
:unit => 'm',
|
323
|
+
:vertices => 'blah'
|
324
|
+
)
|
325
|
+
end
|
326
|
+
end
|
327
|
+
|
328
|
+
def test_accessors
|
329
|
+
p = PolygonType.new(
|
330
|
+
:coord_system_id => 'system1',
|
331
|
+
:unit => 'm',
|
332
|
+
:vertices => [Vertex.new(:position => [1.1, 1.2]), Vertex.new(:position => [2.2, 3.4])]
|
333
|
+
)
|
334
|
+
|
335
|
+
assert_equal VertexList.new([Vertex.new(:position => [1.1, 1.2]), Vertex.new(:position => [2.2, 3.4])]), p.vertices
|
336
|
+
p.vertices = [Vertex.new(:position => [2.2, 2.3]), Vertex.new(:position => [3.3, 4.4])]
|
337
|
+
assert_equal [Vertex.new(:position => [2.2, 2.3]), Vertex.new(:position => [3.3, 4.4])], p.vertices
|
338
|
+
end
|
339
|
+
|
340
|
+
def test_relationships
|
341
|
+
assert_kind_of(
|
342
|
+
Shape,
|
343
|
+
PolygonType.new(
|
344
|
+
:coord_system_id => 'system1',
|
345
|
+
:unit => 'm',
|
346
|
+
:vertices => [Vertex.new(:position => [1.1, 1.2]), Vertex.new(:position => [2.2, 3.4])]
|
347
|
+
)
|
348
|
+
)
|
349
|
+
end
|
350
|
+
|
351
|
+
def test_xml
|
352
|
+
p1 = PolygonType.new(
|
353
|
+
:coord_system_id => 'system1',
|
354
|
+
:unit => 'm',
|
355
|
+
:vertices => [Vertex.new(:position => [1.1, 1.2]), Vertex.new(:position => [2.2, 3.4])]
|
356
|
+
)
|
357
|
+
|
358
|
+
p2 = PolygonType.from_xml(p1.to_xml)
|
359
|
+
assert_equal p1, p2
|
360
|
+
end
|
361
|
+
|
362
|
+
def test_s
|
363
|
+
p = PolygonType.new(
|
364
|
+
:coord_system_id => 'J2000',
|
365
|
+
:unit => 'm',
|
366
|
+
:vertices => [Vertex.new(:position => [1.1, 1.2]), Vertex.new(:position => [2.2, 3.4])]
|
367
|
+
)
|
368
|
+
|
369
|
+
assert_equal 'POLYGON J2000 1.1 1.2 2.2 3.4', p.to_s
|
370
|
+
end
|
371
|
+
end
|
372
|
+
|
373
|
+
class SectorTypeTest < ::Test::Unit::TestCase
|
374
|
+
def test_construction
|
375
|
+
assert_nothing_raised {
|
376
|
+
SectorType.new(
|
377
|
+
:coord_system_id => 'system1',
|
378
|
+
:position => [1.1, 2.3],
|
379
|
+
:pos_angle1 => 12.3,
|
380
|
+
:pos_angle2 => 4.5,
|
381
|
+
:pos_angle_unit => 'lyr'
|
382
|
+
)
|
383
|
+
|
384
|
+
SectorType.new(
|
385
|
+
:coord_system_id => 'system1',
|
386
|
+
:position => [1.1, 2.3],
|
387
|
+
:pos_angle1 => 12.3,
|
388
|
+
:pos_angle2 => 4.5
|
389
|
+
)
|
390
|
+
}
|
391
|
+
|
392
|
+
assert_raises ArgumentError do
|
393
|
+
SectorType.new(:coord_system_id => 'system1')
|
394
|
+
end
|
395
|
+
assert_raises ArgumentError do
|
396
|
+
SectorType.new(
|
397
|
+
:coord_system_id => 'system1',
|
398
|
+
:position => [1.1, 2.3]
|
399
|
+
)
|
400
|
+
end
|
401
|
+
assert_raises ArgumentError do
|
402
|
+
SectorType.new(
|
403
|
+
:coord_system_id => 'system1',
|
404
|
+
:position => [1.1, 2.3],
|
405
|
+
:pos_angle1 => 12.3
|
406
|
+
)
|
407
|
+
end
|
408
|
+
assert_raises ArgumentError do
|
409
|
+
SectorType.new(
|
410
|
+
:coord_system_id => 'system1',
|
411
|
+
:position => [1.1, 2.3],
|
412
|
+
:pos_angle1 => 12.3,
|
413
|
+
:pos_angle2 => 4.5,
|
414
|
+
:pos_angle_unit => 'blah'
|
415
|
+
)
|
416
|
+
end
|
417
|
+
end
|
418
|
+
|
419
|
+
def test_accessors
|
420
|
+
s = SectorType.new(
|
421
|
+
:coord_system_id => 'system1',
|
422
|
+
:position => [1.1, 2.3],
|
423
|
+
:pos_angle1 => 12.3,
|
424
|
+
:pos_angle2 => 4.5,
|
425
|
+
:pos_angle_unit => 'lyr'
|
426
|
+
)
|
427
|
+
|
428
|
+
assert_equal Double2.new([1.1, 2.3]), s.position
|
429
|
+
assert_equal 12.3, s.pos_angle1
|
430
|
+
assert_equal 4.5, s.pos_angle2
|
431
|
+
assert_equal PosUnit.new('lyr'), s.pos_angle_unit
|
432
|
+
|
433
|
+
s.position = [2.3, 4.5]
|
434
|
+
assert_equal Double2.new([2.3, 4.5]), s.position
|
435
|
+
s.pos_angle1 = 12.3
|
436
|
+
assert_equal 12.3, s.pos_angle1
|
437
|
+
s.pos_angle2 = 5.6
|
438
|
+
assert_equal 5.6, s. pos_angle2
|
439
|
+
s.pos_angle_unit = PosUnit.new('m')
|
440
|
+
assert_equal PosUnit.new('m'), s.pos_angle_unit
|
441
|
+
end
|
442
|
+
|
443
|
+
def test_relationships
|
444
|
+
assert_kind_of(
|
445
|
+
Shape,
|
446
|
+
SectorType.new(
|
447
|
+
:coord_system_id => 'system1',
|
448
|
+
:position => [1.1, 2.3],
|
449
|
+
:pos_angle1 => 12.3,
|
450
|
+
:pos_angle2 => 4.5,
|
451
|
+
:pos_angle_unit => 'lyr'
|
452
|
+
)
|
453
|
+
)
|
454
|
+
end
|
455
|
+
|
456
|
+
def test_xml
|
457
|
+
s1 = SectorType.new(
|
458
|
+
:coord_system_id => 'system1',
|
459
|
+
:position => [1.1, 2.3],
|
460
|
+
:pos_angle1 => 12.3,
|
461
|
+
:pos_angle2 => 4.5,
|
462
|
+
:pos_angle_unit => 'lyr'
|
463
|
+
)
|
464
|
+
|
465
|
+
s2 = SectorType.from_xml(s1.to_xml)
|
466
|
+
assert_equal s1.pos_angle_unit, s2.pos_angle_unit
|
467
|
+
end
|
468
|
+
|
469
|
+
def test_s
|
470
|
+
s = SectorType.new(
|
471
|
+
:coord_system_id => 'J2000',
|
472
|
+
:position => [1.1, 2.3],
|
473
|
+
:pos_angle1 => 12.3,
|
474
|
+
:pos_angle2 => 4.5,
|
475
|
+
:pos_angle_unit => 'lyr'
|
476
|
+
)
|
477
|
+
|
478
|
+
assert_equal 'SECTOR J2000 1.1 2.3 12.3 4.5', s.to_s
|
479
|
+
end
|
480
|
+
end
|
481
|
+
|
482
|
+
class ConstraintTest < ::Test::Unit::TestCase
|
483
|
+
def test_construction
|
484
|
+
assert_nothing_raised {
|
485
|
+
Constraint.new(:vector => [1.3, 5.3, 2.2], :offset => 10.2)
|
486
|
+
}
|
487
|
+
|
488
|
+
assert_raises ArgumentError do
|
489
|
+
Constraint.new(:vector => [1.3, 5.3, 2.2])
|
490
|
+
end
|
491
|
+
assert_raises ArgumentError do
|
492
|
+
Constraint.new(:offset => 10.2)
|
493
|
+
end
|
494
|
+
assert_raises ArgumentError do
|
495
|
+
Constraint.new
|
496
|
+
end
|
497
|
+
end
|
498
|
+
|
499
|
+
def test_accessors
|
500
|
+
c = Constraint.new(:vector => [1.3, 5.3, 2.2], :offset => 10.2)
|
501
|
+
|
502
|
+
assert_equal Double3.new([1.3, 5.3, 2.2]), c.vector
|
503
|
+
assert_equal 10.2, c.offset
|
504
|
+
|
505
|
+
c.vector = Double3.new([3.3, 5.6, 1.1])
|
506
|
+
assert_equal Double3.new([3.3, 5.6, 1.1]), c.vector
|
507
|
+
c.offset = 1.2
|
508
|
+
assert_equal 1.2, c.offset
|
509
|
+
end
|
510
|
+
|
511
|
+
def test_xml
|
512
|
+
c1 = Constraint.new(:vector => [1.3, 5.3, 1.1], :offset => 10.2)
|
513
|
+
|
514
|
+
c2 = Constraint.from_xml(c1.to_xml)
|
515
|
+
assert_equal c1, c2
|
516
|
+
end
|
517
|
+
end
|
518
|
+
|
519
|
+
class ConvexTypeTest < ::Test::Unit::TestCase
|
520
|
+
def test_construction
|
521
|
+
assert_nothing_raised {
|
522
|
+
ConvexType.new(:coord_system_id => 'system1', :constraints => [Constraint.new(:vector => [1.1, 2.2, 3.3], :offset => 1.2)])
|
523
|
+
}
|
524
|
+
|
525
|
+
assert_raises TypeError do
|
526
|
+
ConvexType.new(:coord_system_id => 'system1', :constraints => 'blah')
|
527
|
+
end
|
528
|
+
assert_raises RuntimeError do
|
529
|
+
ConvexType.new(:coord_system_id => 'system1', :constraints => [])
|
530
|
+
end
|
531
|
+
end
|
532
|
+
|
533
|
+
def test_accessors
|
534
|
+
c = ConvexType.new(:coord_system_id => 'system1', :constraints => [Constraint.new(:vector => [1.1, 2.2, 3.3], :offset => 1.2)])
|
535
|
+
|
536
|
+
assert_equal(
|
537
|
+
ConstraintList.new([Constraint.new(:vector => [1.1, 2.2, 3.3], :offset => 1.2)]),
|
538
|
+
c.constraints
|
539
|
+
)
|
540
|
+
|
541
|
+
c.constraints = [Constraint.new(:vector => [2.2, 3.3, 4.4], :offset => 6.1)]
|
542
|
+
assert_equal(
|
543
|
+
ConstraintList.new([Constraint.new(:vector => [2.2, 3.3, 4.4], :offset => 6.1)]),
|
544
|
+
c.constraints
|
545
|
+
)
|
546
|
+
end
|
547
|
+
|
548
|
+
def test_relationships
|
549
|
+
assert_kind_of(
|
550
|
+
Shape,
|
551
|
+
ConvexType.new(:coord_system_id => 'system1', :constraints => [Constraint.new(:vector => [1.1, 2.2, 3.3], :offset => 1.2)])
|
552
|
+
)
|
553
|
+
end
|
554
|
+
|
555
|
+
def test_xml
|
556
|
+
c1 = ConvexType.new(:coord_system_id => 'system1', :constraints => [Constraint.new(:vector => [1.1, 2.2, 3.3], :offset => 1.2)])
|
557
|
+
|
558
|
+
c2 = ConvexType.from_xml(c1.to_xml)
|
559
|
+
assert_equal c1, c2
|
560
|
+
end
|
561
|
+
|
562
|
+
def test_s
|
563
|
+
c = ConvexType.new(:coord_system_id => 'J2000', :constraints => [Constraint.new(:vector => [1.1, 2.2, 3.3], :offset => 1.2)])
|
564
|
+
assert_equal 'CONVEX J2000 1.1 2.2 3.3 1.2', c.to_s
|
565
|
+
end
|
566
|
+
end
|
567
|
+
|
568
|
+
class ConvexHullTypeTest < ::Test::Unit::TestCase
|
569
|
+
def test_construction
|
570
|
+
assert_nothing_raised {
|
571
|
+
ConvexHullType.new(
|
572
|
+
:coord_system_id => 'system1',
|
573
|
+
:points => [Double3.new([1.1, 2.2, 3.3])]
|
574
|
+
)
|
575
|
+
}
|
576
|
+
|
577
|
+
assert_raises TypeError do
|
578
|
+
ConvexHullType.new(:coord_system_id => 'system1', :points => 'blah')
|
579
|
+
end
|
580
|
+
assert_raises RuntimeError do
|
581
|
+
ConvexHullType.new(:coord_system_id => 'system1', :points => [])
|
582
|
+
end
|
583
|
+
end
|
584
|
+
|
585
|
+
def test_accessors
|
586
|
+
c = ConvexHullType.new(
|
587
|
+
:coord_system_id => 'system1',
|
588
|
+
:points => [Double3.new([1.1, 2.2, 3.3])]
|
589
|
+
)
|
590
|
+
|
591
|
+
assert_equal IdRef.new('system1'), c.coord_system_id
|
592
|
+
assert_equal PointList.new([Double3.new([1.1, 2.2, 3.3])]), c.points
|
593
|
+
|
594
|
+
c.points = [Double3.new([1.1, 2.2, 3.3]), Double3.new([4.4, 5.5, 6.6])]
|
595
|
+
assert_equal(
|
596
|
+
PointList.new([Double3.new([1.1, 2.2, 3.3]), Double3.new([4.4, 5.5, 6.6])]),
|
597
|
+
c.points
|
598
|
+
)
|
599
|
+
end
|
600
|
+
|
601
|
+
def test_relationships
|
602
|
+
assert_kind_of(
|
603
|
+
Shape,
|
604
|
+
ConvexHullType.new(
|
605
|
+
:coord_system_id => 'system1',
|
606
|
+
:points => [Double3.new([1.1, 2.2, 3.3])]
|
607
|
+
)
|
608
|
+
)
|
609
|
+
end
|
610
|
+
|
611
|
+
def test_xml
|
612
|
+
c1 = ConvexHullType.new(
|
613
|
+
:coord_system_id => 'system1',
|
614
|
+
:points => [Double3.new([1.1, 2.2, 3.3]), Double3.new([4.4, 5.5, 6.6])]
|
615
|
+
)
|
616
|
+
|
617
|
+
c2 = ConvexHullType.from_xml(c1.to_xml)
|
618
|
+
assert_equal c1, c2
|
619
|
+
end
|
620
|
+
|
621
|
+
def test_s
|
622
|
+
c = ConvexHullType.new(
|
623
|
+
:coord_system_id => 'J2000',
|
624
|
+
:points => [Double3.new([1.1, 2.2, 3.3]), Double3.new([4.4, 5.5, 6.6])]
|
625
|
+
)
|
626
|
+
|
627
|
+
assert_equal 'CHULL J2000 1.1 2.2 3.3 4.4 5.5 6.6', c.to_s
|
628
|
+
end
|
629
|
+
end
|
630
|
+
|
631
|
+
class UnionTypeTest < ::Test::Unit::TestCase
|
632
|
+
def test_construction
|
633
|
+
assert_nothing_raised {
|
634
|
+
UnionType.new(
|
635
|
+
:regions => [
|
636
|
+
Circle.new(:coord_system_id => 'system1', :center => [1.1, 2.2], :radius => 100.1),
|
637
|
+
Circle.new(:coord_system_id => 'system1', :center => [3.3, 4.4], :radius => 51.2)
|
638
|
+
]
|
639
|
+
)
|
640
|
+
}
|
641
|
+
|
642
|
+
assert_raises TypeError do
|
643
|
+
UnionType.new(
|
644
|
+
:regions => [
|
645
|
+
CircleType.new(:coord_system_id => 'system1', :center => [1.1, 2.2], :radius => 100.1),
|
646
|
+
Circle.new(:coord_system_id => 'system1', :center => [3.3, 4.4], :radius => 51.2)
|
647
|
+
]
|
648
|
+
)
|
649
|
+
assert_raises ArgumentError do
|
650
|
+
UnionType.new(
|
651
|
+
:regions => [
|
652
|
+
CircleType.new(:coord_system_id => 'system1', :center => [1.1, 2.2], :radius => 100.1)
|
653
|
+
]
|
654
|
+
)
|
655
|
+
end
|
656
|
+
end
|
657
|
+
end
|
658
|
+
|
659
|
+
def test_accessors
|
660
|
+
u = UnionType.new(
|
661
|
+
:regions => [
|
662
|
+
Circle.new(:coord_system_id => 'system1', :center => [1.1, 2.2], :radius => 100.1),
|
663
|
+
Circle.new(:coord_system_id => 'system1', :center => [3.3, 4.4], :radius => 51.2)
|
664
|
+
]
|
665
|
+
)
|
666
|
+
|
667
|
+
assert_equal(
|
668
|
+
RegionList.new([
|
669
|
+
Circle.new(:coord_system_id => 'system1', :center => [1.1, 2.2], :radius => 100.1),
|
670
|
+
Circle.new(:coord_system_id => 'system1', :center => [3.3, 4.4], :radius => 51.2)
|
671
|
+
]),
|
672
|
+
u.regions
|
673
|
+
)
|
674
|
+
|
675
|
+
u.regions = [
|
676
|
+
Circle.new(:coord_system_id => 'system1', :center => [1.1, 2.2], :radius => 100.1),
|
677
|
+
Ellipse.new(
|
678
|
+
:coord_system_id => 'system1',
|
679
|
+
:unit => 'm',
|
680
|
+
:center => [1.1, 2.2],
|
681
|
+
:radius => 100.1,
|
682
|
+
:minor_radius => 50.2,
|
683
|
+
:pos_angle => 81.2,
|
684
|
+
:pos_angle_unit => 'rad'
|
685
|
+
)
|
686
|
+
]
|
687
|
+
assert_equal(
|
688
|
+
RegionList.new([
|
689
|
+
Circle.new(:coord_system_id => 'system1', :center => [1.1, 2.2], :radius => 100.1),
|
690
|
+
Ellipse.new(
|
691
|
+
:coord_system_id => 'system1',
|
692
|
+
:unit => 'm',
|
693
|
+
:center => [1.1, 2.2],
|
694
|
+
:radius => 100.1,
|
695
|
+
:minor_radius => 50.2,
|
696
|
+
:pos_angle => 81.2,
|
697
|
+
:pos_angle_unit => 'rad'
|
698
|
+
)
|
699
|
+
]),
|
700
|
+
u.regions
|
701
|
+
)
|
702
|
+
end
|
703
|
+
|
704
|
+
def test_relationships
|
705
|
+
u = UnionType.new(
|
706
|
+
:regions => [
|
707
|
+
Circle.new(:coord_system_id => 'system1', :center => [1.1, 2.2], :radius => 100.1),
|
708
|
+
Circle.new(:coord_system_id => 'system1', :center => [3.3, 4.4], :radius => 51.2)
|
709
|
+
]
|
710
|
+
)
|
711
|
+
|
712
|
+
assert_kind_of RegionType, u
|
713
|
+
assert_kind_of BooleanOperatorType, u
|
714
|
+
end
|
715
|
+
|
716
|
+
def test_xml
|
717
|
+
u1 = UnionType.new(
|
718
|
+
:regions => [
|
719
|
+
Circle.new(:coord_system_id => 'system1', :center => [1.1, 2.2], :radius => 100.1),
|
720
|
+
Ellipse.new(
|
721
|
+
:coord_system_id => 'system1',
|
722
|
+
:unit => 'm',
|
723
|
+
:center => [1.1, 2.2],
|
724
|
+
:radius => 100.1,
|
725
|
+
:minor_radius => 50.2,
|
726
|
+
:pos_angle => 81.2,
|
727
|
+
:pos_angle_unit => 'rad'
|
728
|
+
)
|
729
|
+
]
|
730
|
+
)
|
731
|
+
|
732
|
+
u2 = UnionType.from_xml(u1.to_xml)
|
733
|
+
assert_equal u1, u2
|
734
|
+
end
|
735
|
+
|
736
|
+
def test_s
|
737
|
+
u = UnionType.new(
|
738
|
+
:regions => [
|
739
|
+
Circle.new(:coord_system_id => 'J2000', :center => [1.1, 2.2], :radius => 100.1),
|
740
|
+
Ellipse.new(
|
741
|
+
:coord_system_id => 'J2000',
|
742
|
+
:unit => 'm',
|
743
|
+
:center => [1.1, 2.2],
|
744
|
+
:radius => 100.1,
|
745
|
+
:minor_radius => 50.2,
|
746
|
+
:pos_angle => 81.2,
|
747
|
+
:pos_angle_unit => 'rad'
|
748
|
+
)
|
749
|
+
]
|
750
|
+
)
|
751
|
+
|
752
|
+
assert_equal 'UNION(CIRCLE J2000 1.1 2.2 100.1 ELLIPSE J2000 1.1 2.2 100.1 50.2 81.2)', u.to_s
|
753
|
+
end
|
754
|
+
end
|
755
|
+
|
756
|
+
class IntersectionTypeTest < ::Test::Unit::TestCase
|
757
|
+
def test_construction
|
758
|
+
assert_nothing_raised {
|
759
|
+
IntersectionType.new(
|
760
|
+
:regions => [
|
761
|
+
Circle.new(:coord_system_id => 'system1', :center => [1.1, 2.2], :radius => 100.1),
|
762
|
+
Circle.new(:coord_system_id => 'system1', :center => [3.3, 4.4], :radius => 51.2)
|
763
|
+
]
|
764
|
+
)
|
765
|
+
}
|
766
|
+
|
767
|
+
assert_raises TypeError do
|
768
|
+
IntersectionType.new(
|
769
|
+
:regions => [
|
770
|
+
CircleType.new(:coord_system_id => 'system1', :center => [1.1, 2.2], :radius => 100.1),
|
771
|
+
Circle.new(:coord_system_id => 'system1', :center => [3.3, 4.4], :radius => 51.2)
|
772
|
+
]
|
773
|
+
)
|
774
|
+
assert_raises ArgumentError do
|
775
|
+
IntersectionType.new(
|
776
|
+
:regions => [
|
777
|
+
CircleType.new(:coord_system_id => 'system1', :center => [1.1, 2.2], :radius => 100.1)
|
778
|
+
]
|
779
|
+
)
|
780
|
+
end
|
781
|
+
end
|
782
|
+
end
|
783
|
+
|
784
|
+
def test_accessors
|
785
|
+
u = IntersectionType.new(
|
786
|
+
:regions => [
|
787
|
+
Circle.new(:coord_system_id => 'system1', :center => [1.1, 2.2], :radius => 100.1),
|
788
|
+
Circle.new(:coord_system_id => 'system1', :center => [3.3, 4.4], :radius => 51.2)
|
789
|
+
]
|
790
|
+
)
|
791
|
+
|
792
|
+
assert_equal(
|
793
|
+
RegionList.new([
|
794
|
+
Circle.new(:coord_system_id => 'system1', :center => [1.1, 2.2], :radius => 100.1),
|
795
|
+
Circle.new(:coord_system_id => 'system1', :center => [3.3, 4.4], :radius => 51.2)
|
796
|
+
]),
|
797
|
+
u.regions
|
798
|
+
)
|
799
|
+
|
800
|
+
u.regions = [
|
801
|
+
Circle.new(:coord_system_id => 'system1', :center => [1.1, 2.2], :radius => 100.1),
|
802
|
+
Ellipse.new(
|
803
|
+
:coord_system_id => 'system1',
|
804
|
+
:unit => 'm',
|
805
|
+
:center => [1.1, 2.2],
|
806
|
+
:radius => 100.1,
|
807
|
+
:minor_radius => 50.2,
|
808
|
+
:pos_angle => 81.2,
|
809
|
+
:pos_angle_unit => 'rad'
|
810
|
+
)
|
811
|
+
]
|
812
|
+
assert_equal(
|
813
|
+
RegionList.new([
|
814
|
+
Circle.new(:coord_system_id => 'system1', :center => [1.1, 2.2], :radius => 100.1),
|
815
|
+
Ellipse.new(
|
816
|
+
:coord_system_id => 'system1',
|
817
|
+
:unit => 'm',
|
818
|
+
:center => [1.1, 2.2],
|
819
|
+
:radius => 100.1,
|
820
|
+
:minor_radius => 50.2,
|
821
|
+
:pos_angle => 81.2,
|
822
|
+
:pos_angle_unit => 'rad'
|
823
|
+
)
|
824
|
+
]),
|
825
|
+
u.regions
|
826
|
+
)
|
827
|
+
end
|
828
|
+
|
829
|
+
def test_relationships
|
830
|
+
i = IntersectionType.new(
|
831
|
+
:regions => [
|
832
|
+
Circle.new(:coord_system_id => 'system1', :center => [1.1, 2.2], :radius => 100.1),
|
833
|
+
Circle.new(:coord_system_id => 'system1', :center => [3.3, 4.4], :radius => 51.2)
|
834
|
+
]
|
835
|
+
)
|
836
|
+
|
837
|
+
assert_kind_of RegionType, i
|
838
|
+
assert_kind_of BooleanOperatorType, i
|
839
|
+
end
|
840
|
+
|
841
|
+
def test_xml
|
842
|
+
u1 = IntersectionType.new(
|
843
|
+
:regions => [
|
844
|
+
Circle.new(:coord_system_id => 'system1', :center => [1.1, 2.2], :radius => 100.1),
|
845
|
+
Ellipse.new(
|
846
|
+
:coord_system_id => 'system1',
|
847
|
+
:unit => 'm',
|
848
|
+
:center => [1.1, 2.2],
|
849
|
+
:radius => 100.1,
|
850
|
+
:minor_radius => 50.2,
|
851
|
+
:pos_angle => 81.2,
|
852
|
+
:pos_angle_unit => 'rad'
|
853
|
+
)
|
854
|
+
]
|
855
|
+
)
|
856
|
+
|
857
|
+
u2 = IntersectionType.from_xml(u1.to_xml)
|
858
|
+
assert_equal u1, u2
|
859
|
+
end
|
860
|
+
|
861
|
+
def test_s
|
862
|
+
u = IntersectionType.new(
|
863
|
+
:regions => [
|
864
|
+
Circle.new(:coord_system_id => 'J2000', :center => [1.1, 2.2], :radius => 100.1),
|
865
|
+
Ellipse.new(
|
866
|
+
:coord_system_id => 'J2000',
|
867
|
+
:unit => 'm',
|
868
|
+
:center => [1.1, 2.2],
|
869
|
+
:radius => 100.1,
|
870
|
+
:minor_radius => 50.2,
|
871
|
+
:pos_angle => 81.2,
|
872
|
+
:pos_angle_unit => 'rad'
|
873
|
+
)
|
874
|
+
]
|
875
|
+
)
|
876
|
+
|
877
|
+
assert_equal 'INTERSECT(CIRCLE J2000 1.1 2.2 100.1 ELLIPSE J2000 1.1 2.2 100.1 50.2 81.2)', u.to_s
|
878
|
+
end
|
879
|
+
end
|
880
|
+
|
881
|
+
class NegationTypeTest < ::Test::Unit::TestCase
|
882
|
+
def test_construction
|
883
|
+
assert_nothing_raised {
|
884
|
+
NegationType.new(
|
885
|
+
:region => Circle.new(:coord_system_id => 'system1', :center => [1.1, 2.2], :radius => 100.1)
|
886
|
+
)
|
887
|
+
}
|
888
|
+
|
889
|
+
assert_raises TypeError do
|
890
|
+
NegationType.new(:region => 'blah')
|
891
|
+
end
|
892
|
+
end
|
893
|
+
|
894
|
+
def test_accessors
|
895
|
+
n = NegationType.new(
|
896
|
+
:region => Circle.new(:coord_system_id => 'system1', :center => [1.1, 2.2], :radius => 100.1)
|
897
|
+
)
|
898
|
+
|
899
|
+
assert_equal Circle.new(:coord_system_id => 'system1', :center => [1.1, 2.2], :radius => 100.1), n.region
|
900
|
+
|
901
|
+
n.region = Circle.new(:coord_system_id => 'system1', :center => [5.5, 6.6], :radius => 50.1)
|
902
|
+
assert_equal Circle.new(:coord_system_id => 'system1', :center => [5.5, 6.6], :radius => 50.1), n.region
|
903
|
+
end
|
904
|
+
|
905
|
+
def test_relationships
|
906
|
+
assert_kind_of(
|
907
|
+
RegionType,
|
908
|
+
NegationType.new(
|
909
|
+
:region => Circle.new(:coord_system_id => 'system1', :center => [1.1, 2.2], :radius => 100.1)
|
910
|
+
)
|
911
|
+
)
|
912
|
+
end
|
913
|
+
|
914
|
+
def test_xml
|
915
|
+
n1 = NegationType.new(
|
916
|
+
:region => Circle.new(:coord_system_id => 'system1', :center => [1.1, 2.2], :radius => 100.1)
|
917
|
+
)
|
918
|
+
|
919
|
+
n2 = NegationType.from_xml(n1.to_xml)
|
920
|
+
assert_equal n1, n2
|
921
|
+
end
|
922
|
+
|
923
|
+
def test_s
|
924
|
+
n = NegationType.new(
|
925
|
+
:region => Circle.new(:coord_system_id => 'J2000', :center => [1.1, 2.2], :radius => 100.1)
|
926
|
+
)
|
927
|
+
|
928
|
+
assert_equal 'NOT(CIRCLE J2000 1.1 2.2 100.1)', n.to_s
|
929
|
+
end
|
930
|
+
end
|
931
|
+
|
932
|
+
class RealWorldRegionTest < ::Test::Unit::TestCase
|
933
|
+
def test_circle
|
934
|
+
assert_nothing_raised {
|
935
|
+
Circle.from_xml(File.open('test/voruby/stc/1.10/stc-region-circle.xml'))
|
936
|
+
}
|
937
|
+
end
|
938
|
+
|
939
|
+
def test_convex
|
940
|
+
assert_nothing_raised {
|
941
|
+
Convex.from_xml(File.open('test/voruby/stc/1.10/stc-region-convex.xml'))
|
942
|
+
}
|
943
|
+
end
|
944
|
+
|
945
|
+
def test_convex_hull
|
946
|
+
assert_nothing_raised {
|
947
|
+
ConvexHull.from_xml(File.open('test/voruby/stc/1.10/stc-region-convexhull.xml'))
|
948
|
+
}
|
949
|
+
end
|
950
|
+
|
951
|
+
def test_ellipse
|
952
|
+
assert_nothing_raised {
|
953
|
+
Ellipse.from_xml(File.open('test/voruby/stc/1.10/stc-region-ellipse.xml'))
|
954
|
+
}
|
955
|
+
end
|
956
|
+
|
957
|
+
def test_intersection
|
958
|
+
assert_nothing_raised {
|
959
|
+
Intersection.from_xml(File.open('test/voruby/stc/1.10/stc-region-intersection.xml'))
|
960
|
+
}
|
961
|
+
end
|
962
|
+
|
963
|
+
def test_negation
|
964
|
+
assert_nothing_raised {
|
965
|
+
Negation.from_xml(File.open('test/voruby/stc/1.10/stc-region-negation.xml'))
|
966
|
+
}
|
967
|
+
end
|
968
|
+
|
969
|
+
def test_polygon
|
970
|
+
assert_nothing_raised {
|
971
|
+
Polygon.from_xml(File.open('test/voruby/stc/1.10/stc-region-polygon.xml'))
|
972
|
+
}
|
973
|
+
end
|
974
|
+
|
975
|
+
def test_sector
|
976
|
+
assert_nothing_raised {
|
977
|
+
Sector.from_xml(File.open('test/voruby/stc/1.10/stc-region-sector.xml'))
|
978
|
+
}
|
979
|
+
end
|
980
|
+
|
981
|
+
def test_union
|
982
|
+
assert_nothing_raised {
|
983
|
+
Union.from_xml(File.open('test/voruby/stc/1.10/stc-region-union.xml'))
|
984
|
+
}
|
985
|
+
end
|
986
|
+
end
|
987
|
+
|
988
|
+
end
|
989
|
+
|
990
|
+
end
|
991
|
+
end
|
992
|
+
end
|
993
|
+
end
|