globegit-postgresql-plruby 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Changes +121 -0
- data/README.markdown +155 -0
- data/Rakefile +48 -0
- data/docs/plruby.rb +1931 -0
- data/ex_trans.sql +33 -0
- data/extconf.rb +267 -0
- data/plruby.html +1454 -0
- data/plruby.rd +1571 -0
- data/postgresql-plruby.gemspec +56 -0
- data/src/conversions.h +5 -0
- data/src/conversions/basic/conversions.h +25 -0
- data/src/conversions/basic/extconf.rb +8 -0
- data/src/conversions/basic/plruby_basic.c +357 -0
- data/src/conversions/bitstring/bitstring.sql +75 -0
- data/src/conversions/bitstring/conversions.h +15 -0
- data/src/conversions/bitstring/extconf.rb +8 -0
- data/src/conversions/bitstring/plruby_bitstring.c +579 -0
- data/src/conversions/convcommon.h +129 -0
- data/src/conversions/datetime/conversions.h +13 -0
- data/src/conversions/datetime/extconf.rb +8 -0
- data/src/conversions/datetime/plruby_datetime.c +269 -0
- data/src/conversions/geometry/conversions.h +37 -0
- data/src/conversions/geometry/extconf.rb +8 -0
- data/src/conversions/geometry/geometry.sql +196 -0
- data/src/conversions/geometry/plruby_geometry.c +2494 -0
- data/src/conversions/network/conversions.h +21 -0
- data/src/conversions/network/extconf.rb +8 -0
- data/src/conversions/network/network.sql +63 -0
- data/src/conversions/network/plruby_network.c +537 -0
- data/src/package.h +20 -0
- data/src/plpl.c +1708 -0
- data/src/plplan.c +893 -0
- data/src/plruby.c +1676 -0
- data/src/plruby.h +324 -0
- data/src/pltrans.c +388 -0
- data/test/conv_bitstring/b.rb +45 -0
- data/test/conv_bitstring/runtest +26 -0
- data/test/conv_bitstring/test.expected.73 +148 -0
- data/test/conv_bitstring/test.expected.74 +148 -0
- data/test/conv_bitstring/test.expected.80 +148 -0
- data/test/conv_bitstring/test.expected.81 +148 -0
- data/test/conv_bitstring/test.expected.82 +148 -0
- data/test/conv_bitstring/test.expected.83 +148 -0
- data/test/conv_bitstring/test.expected.84 +148 -0
- data/test/conv_bitstring/test.out +148 -0
- data/test/conv_bitstring/test_mklang.sql +8 -0
- data/test/conv_bitstring/test_queries.sql +63 -0
- data/test/conv_bitstring/test_queries.sql.in +63 -0
- data/test/conv_geometry/b.rb +45 -0
- data/test/conv_geometry/runtest +26 -0
- data/test/conv_geometry/test.expected.73 +265 -0
- data/test/conv_geometry/test.expected.74 +265 -0
- data/test/conv_geometry/test.expected.80 +265 -0
- data/test/conv_geometry/test.expected.81 +265 -0
- data/test/conv_geometry/test.expected.82 +265 -0
- data/test/conv_geometry/test.expected.83 +265 -0
- data/test/conv_geometry/test.expected.84 +265 -0
- data/test/conv_geometry/test.out +265 -0
- data/test/conv_geometry/test_mklang.sql +8 -0
- data/test/conv_geometry/test_queries.sql +194 -0
- data/test/conv_geometry/test_queries.sql.in +194 -0
- data/test/conv_network/b.rb +45 -0
- data/test/conv_network/runtest +26 -0
- data/test/conv_network/test.expected.73 +213 -0
- data/test/conv_network/test.expected.74 +237 -0
- data/test/conv_network/test.expected.80 +237 -0
- data/test/conv_network/test.expected.81 +237 -0
- data/test/conv_network/test.expected.82 +237 -0
- data/test/conv_network/test.expected.83 +237 -0
- data/test/conv_network/test.expected.84 +237 -0
- data/test/conv_network/test.out +237 -0
- data/test/conv_network/test_mklang.sql +8 -0
- data/test/conv_network/test_queries.sql +60 -0
- data/test/conv_network/test_queries.sql.in +60 -0
- data/test/plp/b.rb +34 -0
- data/test/plp/runtest +29 -0
- data/test/plp/test.expected.73 +472 -0
- data/test/plp/test.expected.74 +472 -0
- data/test/plp/test.expected.75 +472 -0
- data/test/plp/test.expected.80 +472 -0
- data/test/plp/test.expected.81 +472 -0
- data/test/plp/test.expected.82 +472 -0
- data/test/plp/test.expected.83 +472 -0
- data/test/plp/test.expected.84 +472 -0
- data/test/plp/test.out +472 -0
- data/test/plp/test_mklang.sql +8 -0
- data/test/plp/test_queries.sql +273 -0
- data/test/plp/test_setup.sql +931 -0
- data/test/plp/test_setup.sql.in +931 -0
- data/test/plt/b.rb +34 -0
- data/test/plt/runtest +29 -0
- data/test/plt/test.expected.73 +178 -0
- data/test/plt/test.expected.74 +178 -0
- data/test/plt/test.expected.75 +178 -0
- data/test/plt/test.expected.80 +178 -0
- data/test/plt/test.expected.81 +178 -0
- data/test/plt/test.expected.82 +178 -0
- data/test/plt/test.expected.83 +164 -0
- data/test/plt/test.expected.84 +168 -0
- data/test/plt/test.out +168 -0
- data/test/plt/test_mklang.sql +8 -0
- data/test/plt/test_queries.sql +72 -0
- data/test/plt/test_setup.sql +252 -0
- data/test/plt/test_setup.sql.in +252 -0
- data/test/range/b.rb +45 -0
- data/test/range/runtest +26 -0
- data/test/range/test.expected.73 +396 -0
- data/test/range/test.expected.73.in +396 -0
- data/test/range/test.expected.74 +396 -0
- data/test/range/test.expected.74.in +396 -0
- data/test/range/test.expected.75 +396 -0
- data/test/range/test.expected.75.in +396 -0
- data/test/range/test.expected.80 +396 -0
- data/test/range/test.expected.81 +397 -0
- data/test/range/test.expected.82 +397 -0
- data/test/range/test.expected.83 +397 -0
- data/test/range/test.expected.84 +399 -0
- data/test/range/test.out +399 -0
- data/test/range/test_mklang.sql +8 -0
- data/test/range/test_queries.sql +249 -0
- data/test/range/test_queries.sql.in +249 -0
- metadata +207 -0
@@ -0,0 +1,265 @@
|
|
1
|
+
set client_min_messages = 'WARNING';
|
2
|
+
create table pl_box (
|
3
|
+
data box, barea float, boverlaps bool, boverleft bool, boverright bool,
|
4
|
+
bleft bool, bright bool
|
5
|
+
);
|
6
|
+
create or replace function box_val(box[]) returns setof pl_box as '
|
7
|
+
b1 = Box.new(2.5,2.5,1.0,1.0)
|
8
|
+
b2 = Box.new(2.0,2.0,2.5,2.5)
|
9
|
+
b3 = Box.new(3.0,3.0,5.0,5.0)
|
10
|
+
args[0].each do |b|
|
11
|
+
yield [b, b.area, b.overlap?(b1), b.overleft?(b2),
|
12
|
+
b.overright?(b2), b.left?(b3), b3.right?(b)]
|
13
|
+
end
|
14
|
+
' language 'plruby';
|
15
|
+
select * from
|
16
|
+
box_val('{(2.0,2.0,0.0,0.0);(1.0,1.0,3.0,3.0);(2.5,2.5,2.5,3.5);(3.0,3.0,3.0,3.0)}'::box[]);
|
17
|
+
data | barea | boverlaps | boverleft | boverright | bleft | bright
|
18
|
+
---------------------+-------+-----------+-----------+------------+-------+--------
|
19
|
+
(2,2),(0,0) | 4 | t | t | f | t | t
|
20
|
+
(3,3),(1,1) | 4 | t | f | f | f | f
|
21
|
+
(2.5,3.5),(2.5,2.5) | 0 | t | t | t | t | t
|
22
|
+
(3,3),(3,3) | 0 | f | f | t | f | f
|
23
|
+
(4 rows)
|
24
|
+
|
25
|
+
drop table pl_box cascade;
|
26
|
+
create table pl_box (
|
27
|
+
b box, bcmp1 int, bcmp2 int, bin bool, bcontain bool, bcenter point
|
28
|
+
);
|
29
|
+
create or replace function box_val(box[]) returns setof pl_box as '
|
30
|
+
b1 = Box.new(3.0,3.0,5.0,5.0)
|
31
|
+
b2 = Box.new(3.5,3.0,4.5,3.0)
|
32
|
+
b3 = Box.new(0,0,3,3)
|
33
|
+
args[0].each do |b|
|
34
|
+
yield [b, b <=> b1, b <=> b2, b.in?(b3), b.contain?(b3), b.center]
|
35
|
+
end
|
36
|
+
' language 'plruby';
|
37
|
+
select * from
|
38
|
+
box_val('{(2.0,2.0,0.0,0.0);(1.0,1.0,3.0,3.0);(2.5,2.5,2.5,3.5);(3.0,3.0,3.0,3.0)}'::box[]);
|
39
|
+
b | bcmp1 | bcmp2 | bin | bcontain | bcenter
|
40
|
+
---------------------+-------+-------+-----+----------+---------
|
41
|
+
(2,2),(0,0) | 0 | 1 | t | f | (1,1)
|
42
|
+
(3,3),(1,1) | 0 | 1 | t | f | (2,2)
|
43
|
+
(2.5,3.5),(2.5,2.5) | -1 | 0 | f | f | (2.5,3)
|
44
|
+
(3,3),(3,3) | -1 | 0 | t | f | (3,3)
|
45
|
+
(4 rows)
|
46
|
+
|
47
|
+
drop table pl_box cascade;
|
48
|
+
create table pl_box (
|
49
|
+
b0 box, b1 box, b2 box, b3 box
|
50
|
+
);
|
51
|
+
create or replace function box_val(box[]) returns setof pl_box as '
|
52
|
+
p0 = [Point.new(-10.0,0.0), Point.new(-3.0,4.0),
|
53
|
+
Point.new(5.1, 34.5), Point.new(-5.0,-12.0)]
|
54
|
+
args[0].each do |b|
|
55
|
+
p0.each do |p|
|
56
|
+
yield [b + p, b - p, b * p, b / p]
|
57
|
+
end
|
58
|
+
p0.each do |p|
|
59
|
+
yield [p + b, p - b, p * b, p / b]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
' language 'plruby';
|
63
|
+
select * from
|
64
|
+
box_val('{(2.0,2.0,0.0,0.0);(1.0,1.0,3.0,3.0);(2.5,2.5,2.5,3.5);(3.0,3.0,3.0,3.0)}'::box[]);
|
65
|
+
b0 | b1 | b2 | b3
|
66
|
+
-------------------------+---------------------------+-----------------------------+-----------------------------------------------------------------------------------
|
67
|
+
(-8,2),(-10,0) | (12,2),(10,0) | (-0,0),(-20,-20) | (0,-0),(-0.2,-0.2)
|
68
|
+
(-1,6),(-3,4) | (5,-2),(3,-4) | (-0,2),(-14,0) | (0.08,-0),(0,-0.56)
|
69
|
+
(7.1,36.5),(5.1,34.5) | (-3.1,-32.5),(-5.1,-34.5) | (0,79.2),(-58.8,0) | (0.0651176557643925,0),(0,-0.0483449262493217)
|
70
|
+
(-3,-10),(-5,-12) | (7,14),(5,12) | (14,-0),(0,-34) | (-0,0.0828402366863905),(-0.201183431952663,0)
|
71
|
+
(-8,2),(-10,0) | (12,2),(10,0) | (-0,0),(-20,-20) | (0,-0),(-0.2,-0.2)
|
72
|
+
(-1,6),(-3,4) | (5,-2),(3,-4) | (-0,2),(-14,0) | (0.08,-0),(0,-0.56)
|
73
|
+
(7.1,36.5),(5.1,34.5) | (-3.1,-32.5),(-5.1,-34.5) | (0,79.2),(-58.8,0) | (0.0651176557643925,0),(0,-0.0483449262493217)
|
74
|
+
(-3,-10),(-5,-12) | (7,14),(5,12) | (14,-0),(0,-34) | (-0,0.0828402366863905),(-0.201183431952663,0)
|
75
|
+
(-7,3),(-9,1) | (13,3),(11,1) | (-10,-10),(-30,-30) | (-0.1,-0.1),(-0.3,-0.3)
|
76
|
+
(0,7),(-2,5) | (6,-1),(4,-3) | (-7,3),(-21,1) | (0.12,-0.28),(0.04,-0.84)
|
77
|
+
(8.1,37.5),(6.1,35.5) | (-2.1,-31.5),(-4.1,-33.5) | (-29.4,118.8),(-88.2,39.6) | (0.0976764836465887,-0.0241724631246608),(0.0325588278821962,-0.0725173893739825)
|
78
|
+
(-2,-9),(-4,-11) | (8,15),(6,13) | (21,-17),(7,-51) | (-0.100591715976331,0.124260355029586),(-0.301775147928994,0.0414201183431953)
|
79
|
+
(-7,3),(-9,1) | (13,3),(11,1) | (-10,-10),(-30,-30) | (-0.1,-0.1),(-0.3,-0.3)
|
80
|
+
(0,7),(-2,5) | (6,-1),(4,-3) | (-7,3),(-21,1) | (0.12,-0.28),(0.04,-0.84)
|
81
|
+
(8.1,37.5),(6.1,35.5) | (-2.1,-31.5),(-4.1,-33.5) | (-29.4,118.8),(-88.2,39.6) | (0.0976764836465887,-0.0241724631246608),(0.0325588278821962,-0.0725173893739825)
|
82
|
+
(-2,-9),(-4,-11) | (8,15),(6,13) | (21,-17),(7,-51) | (-0.100591715976331,0.124260355029586),(-0.301775147928994,0.0414201183431953)
|
83
|
+
(-7.5,3.5),(-7.5,2.5) | (12.5,3.5),(12.5,2.5) | (-25,-25),(-25,-35) | (-0.25,-0.25),(-0.25,-0.35)
|
84
|
+
(-0.5,7.5),(-0.5,6.5) | (5.5,-0.5),(5.5,-1.5) | (-17.5,2.5),(-21.5,-0.5) | (0.26,-0.7),(0.1,-0.82)
|
85
|
+
(7.6,38),(7.6,37) | (-2.6,-31),(-2.6,-32) | (-73.5,104.1),(-108,99) | (0.109762715208919,-0.0562379754328844),(0.0813970697054906,-0.0604311578116521)
|
86
|
+
(-2.5,-8.5),(-2.5,-9.5) | (7.5,15.5),(7.5,14.5) | (29.5,-42.5),(17.5,-47.5) | (-0.251479289940828,0.103550295857988),(-0.322485207100592,0.0739644970414201)
|
87
|
+
(-7.5,3.5),(-7.5,2.5) | (12.5,3.5),(12.5,2.5) | (-25,-25),(-25,-35) | (-0.25,-0.25),(-0.25,-0.35)
|
88
|
+
(-0.5,7.5),(-0.5,6.5) | (5.5,-0.5),(5.5,-1.5) | (-17.5,2.5),(-21.5,-0.5) | (0.26,-0.7),(0.1,-0.82)
|
89
|
+
(7.6,38),(7.6,37) | (-2.6,-31),(-2.6,-32) | (-73.5,104.1),(-108,99) | (0.109762715208919,-0.0562379754328844),(0.0813970697054906,-0.0604311578116521)
|
90
|
+
(-2.5,-8.5),(-2.5,-9.5) | (7.5,15.5),(7.5,14.5) | (29.5,-42.5),(17.5,-47.5) | (-0.251479289940828,0.103550295857988),(-0.322485207100592,0.0739644970414201)
|
91
|
+
(-7,3),(-7,3) | (13,3),(13,3) | (-30,-30),(-30,-30) | (-0.3,-0.3),(-0.3,-0.3)
|
92
|
+
(0,7),(0,7) | (6,-1),(6,-1) | (-21,3),(-21,3) | (0.12,-0.84),(0.12,-0.84)
|
93
|
+
(8.1,37.5),(8.1,37.5) | (-2.1,-31.5),(-2.1,-31.5) | (-88.2,118.8),(-88.2,118.8) | (0.0976764836465887,-0.0725173893739825),(0.0976764836465887,-0.0725173893739825)
|
94
|
+
(-2,-9),(-2,-9) | (8,15),(8,15) | (21,-51),(21,-51) | (-0.301775147928994,0.124260355029586),(-0.301775147928994,0.124260355029586)
|
95
|
+
(-7,3),(-7,3) | (13,3),(13,3) | (-30,-30),(-30,-30) | (-0.3,-0.3),(-0.3,-0.3)
|
96
|
+
(0,7),(0,7) | (6,-1),(6,-1) | (-21,3),(-21,3) | (0.12,-0.84),(0.12,-0.84)
|
97
|
+
(8.1,37.5),(8.1,37.5) | (-2.1,-31.5),(-2.1,-31.5) | (-88.2,118.8),(-88.2,118.8) | (0.0976764836465887,-0.0725173893739825),(0.0976764836465887,-0.0725173893739825)
|
98
|
+
(-2,-9),(-2,-9) | (8,15),(8,15) | (21,-51),(21,-51) | (-0.301775147928994,0.124260355029586),(-0.301775147928994,0.124260355029586)
|
99
|
+
(32 rows)
|
100
|
+
|
101
|
+
drop table pl_box cascade;
|
102
|
+
create table pl_box (
|
103
|
+
p point, dp float, d0 float, c circle, w float, h float
|
104
|
+
);
|
105
|
+
create or replace function box_val(box[]) returns setof pl_box as '
|
106
|
+
p = Point.new(6,4)
|
107
|
+
args[0].each do |b|
|
108
|
+
p0 = b.center
|
109
|
+
yield [p0, Geometry::distance(p, b),Geometry::distance(p, p0),
|
110
|
+
b.to_circle, b.height, b.width]
|
111
|
+
end
|
112
|
+
' language 'plruby';
|
113
|
+
select * from
|
114
|
+
box_val('{(2.0,2.0,0.0,0.0);(1.0,1.0,3.0,3.0);(2.5,2.5,2.5,3.5);(3.0,3.0,3.0,3.0)}'::box[]);
|
115
|
+
p | dp | d0 | c | w | h
|
116
|
+
---------+------------------+------------------+-------------------------+---+---
|
117
|
+
(1,1) | 4.47213595499958 | 5.8309518948453 | <(1,1),1.4142135623731> | 2 | 2
|
118
|
+
(2,2) | 3.16227766016838 | 4.47213595499958 | <(2,2),1.4142135623731> | 2 | 2
|
119
|
+
(2.5,3) | 3.53553390593274 | 3.64005494464026 | <(2.5,3),0.5> | 1 | 0
|
120
|
+
(3,3) | 3.16227766016838 | 3.16227766016838 | <(3,3),0> | 0 | 0
|
121
|
+
(4 rows)
|
122
|
+
|
123
|
+
drop table pl_box cascade;
|
124
|
+
create table pl_box (
|
125
|
+
nb int, ll float, pc bool
|
126
|
+
);
|
127
|
+
create or replace function path_val(path[]) returns setof pl_box as '
|
128
|
+
args[0].each do |b|
|
129
|
+
yield [b.npoints, b.length, b.closed?]
|
130
|
+
end
|
131
|
+
' language 'plruby';
|
132
|
+
select * from
|
133
|
+
path_val('{"[1,2,3,4]","(0,0),(3,0),(4,5),(1,6)","11,12,13,14,25,12"}'::path[]);
|
134
|
+
nb | ll | pc
|
135
|
+
----+------------------+----
|
136
|
+
2 | 2.82842712474619 | f
|
137
|
+
4 | 17.3440597040594 | t
|
138
|
+
3 | 28.9939521853426 | t
|
139
|
+
(3 rows)
|
140
|
+
|
141
|
+
drop table pl_box cascade;
|
142
|
+
create table pl_box (
|
143
|
+
p path, p0 path, p1 path
|
144
|
+
);
|
145
|
+
create or replace function path_val(path[]) returns setof pl_box as '
|
146
|
+
p0 = Point.new(6,7)
|
147
|
+
args[0].each do |b|
|
148
|
+
yield [b, b + p0, b - p0]
|
149
|
+
end
|
150
|
+
' language 'plruby';
|
151
|
+
select * from
|
152
|
+
path_val('{"[1,2,3,4]","(0,0),(3,0),(4,5),(1,6)","11,12,13,14,25,12"}'::path[]);
|
153
|
+
p | p0 | p1
|
154
|
+
---------------------------+------------------------------+-----------------------------------
|
155
|
+
[(1,2),(3,4)] | [(7,9),(9,11)] | [(-5,-5),(-3,-3)]
|
156
|
+
((0,0),(3,0),(4,5),(1,6)) | ((6,7),(9,7),(10,12),(7,13)) | ((-6,-7),(-3,-7),(-2,-2),(-5,-1))
|
157
|
+
((11,12),(13,14),(25,12)) | ((17,19),(19,21),(31,19)) | ((5,5),(7,7),(19,5))
|
158
|
+
(3 rows)
|
159
|
+
|
160
|
+
drop table pl_box cascade;
|
161
|
+
create table pl_box (
|
162
|
+
p path, p0 path, p1 path
|
163
|
+
);
|
164
|
+
create or replace function path_val(path[]) returns setof pl_box as '
|
165
|
+
p0 = Point.new(6,7)
|
166
|
+
args[0].each do |b|
|
167
|
+
yield [b, b * p0, b / p0]
|
168
|
+
end
|
169
|
+
' language 'plruby';
|
170
|
+
select * from
|
171
|
+
path_val('{"[1,2,3,4]","(0,0),(3,0),(4,5),(1,6)","11,12,13,14,25,12"}'::path[]);
|
172
|
+
p | p0 | p1
|
173
|
+
---------------------------+-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------
|
174
|
+
[(1,2),(3,4)] | [(-8,19),(-10,45)] | [(0.235294117647059,0.0588235294117647),(0.541176470588235,0.0352941176470588)]
|
175
|
+
((0,0),(3,0),(4,5),(1,6)) | ((0,0),(18,21),(-11,58),(-36,43)) | ((0,0),(0.211764705882353,-0.247058823529412),(0.694117647058824,0.0235294117647059),(0.564705882352941,0.341176470588235))
|
176
|
+
((11,12),(13,14),(25,12)) | ((-18,149),(-20,175),(66,247)) | ((1.76470588235294,-0.0588235294117647),(2.07058823529412,-0.0823529411764706),(2.75294117647059,-1.21176470588235))
|
177
|
+
(3 rows)
|
178
|
+
|
179
|
+
drop table pl_box cascade;
|
180
|
+
create table pl_box (
|
181
|
+
center point, area float, radius float, diameter float
|
182
|
+
);
|
183
|
+
create or replace function circle_val(circle[]) returns setof pl_box as '
|
184
|
+
args[0].each do |b|
|
185
|
+
yield b.center, b.area, b.radius, b.diameter
|
186
|
+
end
|
187
|
+
' language 'plruby';
|
188
|
+
select * from
|
189
|
+
circle_val('{"<(5,1),3>","<(1,2),100>","<(100,200),10>","<(100,1),115>","1,3,5"}'::circle[]);
|
190
|
+
center | area | radius | diameter
|
191
|
+
-----------+------------------+--------+----------
|
192
|
+
(5,1) | 28.2743338823081 | 3 | 6
|
193
|
+
(1,2) | 31415.9265358979 | 100 | 200
|
194
|
+
(100,200) | 314.159265358979 | 10 | 20
|
195
|
+
(100,1) | 41547.562843725 | 115 | 230
|
196
|
+
(1,3) | 78.5398163397448 | 5 | 10
|
197
|
+
(5 rows)
|
198
|
+
|
199
|
+
drop table pl_box cascade;
|
200
|
+
create table pl_box (
|
201
|
+
p circle, p0 circle, p1 circle
|
202
|
+
);
|
203
|
+
create or replace function circle_val(circle[]) returns setof pl_box as '
|
204
|
+
p0 = Point.new(6,7)
|
205
|
+
args[0].each do |b|
|
206
|
+
yield [b, b + p0, b - p0]
|
207
|
+
end
|
208
|
+
' language 'plruby';
|
209
|
+
select * from
|
210
|
+
circle_val('{"<(5,1),3>","<(1,2),100>","<(100,200),10>","<(100,1),115>","1,3,5"}'::circle[]);
|
211
|
+
p | p0 | p1
|
212
|
+
----------------+----------------+---------------
|
213
|
+
<(5,1),3> | <(11,8),3> | <(-1,-6),3>
|
214
|
+
<(1,2),100> | <(7,9),100> | <(-5,-5),100>
|
215
|
+
<(100,200),10> | <(106,207),10> | <(94,193),10>
|
216
|
+
<(100,1),115> | <(106,8),115> | <(94,-6),115>
|
217
|
+
<(1,3),5> | <(7,10),5> | <(-5,-4),5>
|
218
|
+
(5 rows)
|
219
|
+
|
220
|
+
drop table pl_box cascade;
|
221
|
+
create table pl_box (
|
222
|
+
p circle, p0 circle, p1 circle
|
223
|
+
);
|
224
|
+
create or replace function circle_val(circle[]) returns setof pl_box as '
|
225
|
+
p0 = Point.new(6,7)
|
226
|
+
args[0].each do |b|
|
227
|
+
yield [b, p0 * b, p0 / b ]
|
228
|
+
end
|
229
|
+
' language 'plruby';
|
230
|
+
select * from
|
231
|
+
circle_val('{"<(5,1),3>","<(1,2),100>","<(100,200),10>","<(100,1),115>","1,3,5"}'::circle[]);
|
232
|
+
p | p0 | p1
|
233
|
+
----------------+--------------------------------+------------------------------------------------------------
|
234
|
+
<(5,1),3> | <(23,41),27.6586333718787> | <(0.435294117647059,-0.341176470588235),0.325395686727984>
|
235
|
+
<(1,2),100> | <(-8,19),921.954445729289> | <(0.235294117647059,0.0588235294117647),10.8465228909328>
|
236
|
+
<(100,200),10> | <(-800,1900),92.1954445729289> | <(23.5294117647059,5.88235294117647),1.08465228909328>
|
237
|
+
<(100,1),115> | <(593,706),1060.24761258868> | <(7.14117647058824,-8.16470588235294),12.4735013245727>
|
238
|
+
<(1,3),5> | <(-15,25),46.0977222864644> | <(0.317647058823529,0.129411764705882),0.54232614454664>
|
239
|
+
(5 rows)
|
240
|
+
|
241
|
+
drop table pl_box cascade;
|
242
|
+
create table pl_box (
|
243
|
+
overlap bool, overleft bool, overright bool,
|
244
|
+
bleft bool, bright bool, below bool, above bool
|
245
|
+
);
|
246
|
+
create or replace function circle_val(circle, circle) returns setof pl_box as '
|
247
|
+
b0 = args[0]
|
248
|
+
b1 = args[1]
|
249
|
+
yield b0.overlap?(b1), b0.overleft?(b1), b0.overright?(b1),
|
250
|
+
b0.left?(b1), b0.right?(b1), b0.below?(b1), b0.above?(b1)
|
251
|
+
' language 'plruby';
|
252
|
+
select * from
|
253
|
+
circle_val('<(5,1),3>'::circle, '<(1,2),100>'::circle);
|
254
|
+
overlap | overleft | overright | bleft | bright | below | above
|
255
|
+
---------+----------+-----------+-------+--------+-------+-------
|
256
|
+
t | t | t | f | f | f | f
|
257
|
+
(1 row)
|
258
|
+
|
259
|
+
select * from
|
260
|
+
circle_val('<(100,200),10>'::circle, '<(100,1),115>'::circle);
|
261
|
+
overlap | overleft | overright | bleft | bright | below | above
|
262
|
+
---------+----------+-----------+-------+--------+-------+-------
|
263
|
+
f | t | t | f | f | f | t
|
264
|
+
(1 row)
|
265
|
+
|
@@ -0,0 +1,194 @@
|
|
1
|
+
set client_min_messages = 'WARNING';
|
2
|
+
|
3
|
+
create table pl_box (
|
4
|
+
data box, barea float, boverlaps bool, boverleft bool, boverright bool,
|
5
|
+
bleft bool, bright bool
|
6
|
+
);
|
7
|
+
|
8
|
+
create or replace function box_val(box[]) returns setof pl_box as '
|
9
|
+
b1 = Box.new(2.5,2.5,1.0,1.0)
|
10
|
+
b2 = Box.new(2.0,2.0,2.5,2.5)
|
11
|
+
b3 = Box.new(3.0,3.0,5.0,5.0)
|
12
|
+
args[0].each do |b|
|
13
|
+
yield [b, b.area, b.overlap?(b1), b.overleft?(b2),
|
14
|
+
b.overright?(b2), b.left?(b3), b3.right?(b)]
|
15
|
+
end
|
16
|
+
' language 'plruby';
|
17
|
+
|
18
|
+
select * from
|
19
|
+
box_val('{(2.0,2.0,0.0,0.0);(1.0,1.0,3.0,3.0);(2.5,2.5,2.5,3.5);(3.0,3.0,3.0,3.0)}'::box[]);
|
20
|
+
|
21
|
+
drop table pl_box cascade;
|
22
|
+
|
23
|
+
create table pl_box (
|
24
|
+
b box, bcmp1 int, bcmp2 int, bin bool, bcontain bool, bcenter point
|
25
|
+
);
|
26
|
+
|
27
|
+
create or replace function box_val(box[]) returns setof pl_box as '
|
28
|
+
b1 = Box.new(3.0,3.0,5.0,5.0)
|
29
|
+
b2 = Box.new(3.5,3.0,4.5,3.0)
|
30
|
+
b3 = Box.new(0,0,3,3)
|
31
|
+
args[0].each do |b|
|
32
|
+
yield [b, b <=> b1, b <=> b2, b.in?(b3), b.contain?(b3), b.center]
|
33
|
+
end
|
34
|
+
' language 'plruby';
|
35
|
+
|
36
|
+
select * from
|
37
|
+
box_val('{(2.0,2.0,0.0,0.0);(1.0,1.0,3.0,3.0);(2.5,2.5,2.5,3.5);(3.0,3.0,3.0,3.0)}'::box[]);
|
38
|
+
|
39
|
+
drop table pl_box cascade;
|
40
|
+
|
41
|
+
create table pl_box (
|
42
|
+
b0 box, b1 box, b2 box, b3 box
|
43
|
+
);
|
44
|
+
|
45
|
+
create or replace function box_val(box[]) returns setof pl_box as '
|
46
|
+
p0 = [Point.new(-10.0,0.0), Point.new(-3.0,4.0),
|
47
|
+
Point.new(5.1, 34.5), Point.new(-5.0,-12.0)]
|
48
|
+
args[0].each do |b|
|
49
|
+
p0.each do |p|
|
50
|
+
yield [b + p, b - p, b * p, b / p]
|
51
|
+
end
|
52
|
+
p0.each do |p|
|
53
|
+
yield [p + b, p - b, p * b, p / b]
|
54
|
+
end
|
55
|
+
end
|
56
|
+
' language 'plruby';
|
57
|
+
|
58
|
+
select * from
|
59
|
+
box_val('{(2.0,2.0,0.0,0.0);(1.0,1.0,3.0,3.0);(2.5,2.5,2.5,3.5);(3.0,3.0,3.0,3.0)}'::box[]);
|
60
|
+
|
61
|
+
drop table pl_box cascade;
|
62
|
+
|
63
|
+
create table pl_box (
|
64
|
+
p point, dp float, d0 float, c circle, w float, h float
|
65
|
+
);
|
66
|
+
|
67
|
+
create or replace function box_val(box[]) returns setof pl_box as '
|
68
|
+
p = Point.new(6,4)
|
69
|
+
args[0].each do |b|
|
70
|
+
p0 = b.center
|
71
|
+
yield [p0, Geometry::distance(p, b),Geometry::distance(p, p0),
|
72
|
+
b.to_circle, b.height, b.width]
|
73
|
+
end
|
74
|
+
' language 'plruby';
|
75
|
+
|
76
|
+
select * from
|
77
|
+
box_val('{(2.0,2.0,0.0,0.0);(1.0,1.0,3.0,3.0);(2.5,2.5,2.5,3.5);(3.0,3.0,3.0,3.0)}'::box[]);
|
78
|
+
|
79
|
+
drop table pl_box cascade;
|
80
|
+
|
81
|
+
create table pl_box (
|
82
|
+
nb int, ll float, pc bool
|
83
|
+
);
|
84
|
+
|
85
|
+
create or replace function path_val(path[]) returns setof pl_box as '
|
86
|
+
args[0].each do |b|
|
87
|
+
yield [b.npoints, b.length, b.closed?]
|
88
|
+
end
|
89
|
+
' language 'plruby';
|
90
|
+
|
91
|
+
select * from
|
92
|
+
path_val('{"[1,2,3,4]","(0,0),(3,0),(4,5),(1,6)","11,12,13,14,25,12"}'::path[]);
|
93
|
+
|
94
|
+
drop table pl_box cascade;
|
95
|
+
|
96
|
+
create table pl_box (
|
97
|
+
p path, p0 path, p1 path
|
98
|
+
);
|
99
|
+
|
100
|
+
create or replace function path_val(path[]) returns setof pl_box as '
|
101
|
+
p0 = Point.new(6,7)
|
102
|
+
args[0].each do |b|
|
103
|
+
yield [b, b + p0, b - p0]
|
104
|
+
end
|
105
|
+
' language 'plruby';
|
106
|
+
|
107
|
+
select * from
|
108
|
+
path_val('{"[1,2,3,4]","(0,0),(3,0),(4,5),(1,6)","11,12,13,14,25,12"}'::path[]);
|
109
|
+
|
110
|
+
drop table pl_box cascade;
|
111
|
+
|
112
|
+
create table pl_box (
|
113
|
+
p path, p0 path, p1 path
|
114
|
+
);
|
115
|
+
|
116
|
+
create or replace function path_val(path[]) returns setof pl_box as '
|
117
|
+
p0 = Point.new(6,7)
|
118
|
+
args[0].each do |b|
|
119
|
+
yield [b, b * p0, b / p0]
|
120
|
+
end
|
121
|
+
' language 'plruby';
|
122
|
+
|
123
|
+
select * from
|
124
|
+
path_val('{"[1,2,3,4]","(0,0),(3,0),(4,5),(1,6)","11,12,13,14,25,12"}'::path[]);
|
125
|
+
|
126
|
+
drop table pl_box cascade;
|
127
|
+
|
128
|
+
create table pl_box (
|
129
|
+
center point, area float, radius float, diameter float
|
130
|
+
);
|
131
|
+
|
132
|
+
create or replace function circle_val(circle[]) returns setof pl_box as '
|
133
|
+
args[0].each do |b|
|
134
|
+
yield b.center, b.area, b.radius, b.diameter
|
135
|
+
end
|
136
|
+
' language 'plruby';
|
137
|
+
|
138
|
+
select * from
|
139
|
+
circle_val('{"<(5,1),3>","<(1,2),100>","<(100,200),10>","<(100,1),115>","1,3,5"}'::circle[]);
|
140
|
+
|
141
|
+
|
142
|
+
drop table pl_box cascade;
|
143
|
+
|
144
|
+
create table pl_box (
|
145
|
+
p circle, p0 circle, p1 circle
|
146
|
+
);
|
147
|
+
|
148
|
+
create or replace function circle_val(circle[]) returns setof pl_box as '
|
149
|
+
p0 = Point.new(6,7)
|
150
|
+
args[0].each do |b|
|
151
|
+
yield [b, b + p0, b - p0]
|
152
|
+
end
|
153
|
+
' language 'plruby';
|
154
|
+
|
155
|
+
select * from
|
156
|
+
circle_val('{"<(5,1),3>","<(1,2),100>","<(100,200),10>","<(100,1),115>","1,3,5"}'::circle[]);
|
157
|
+
|
158
|
+
drop table pl_box cascade;
|
159
|
+
|
160
|
+
create table pl_box (
|
161
|
+
p circle, p0 circle, p1 circle
|
162
|
+
);
|
163
|
+
|
164
|
+
create or replace function circle_val(circle[]) returns setof pl_box as '
|
165
|
+
p0 = Point.new(6,7)
|
166
|
+
args[0].each do |b|
|
167
|
+
yield [b, p0 * b, p0 / b ]
|
168
|
+
end
|
169
|
+
' language 'plruby';
|
170
|
+
|
171
|
+
select * from
|
172
|
+
circle_val('{"<(5,1),3>","<(1,2),100>","<(100,200),10>","<(100,1),115>","1,3,5"}'::circle[]);
|
173
|
+
|
174
|
+
drop table pl_box cascade;
|
175
|
+
|
176
|
+
create table pl_box (
|
177
|
+
overlap bool, overleft bool, overright bool,
|
178
|
+
bleft bool, bright bool, below bool, above bool
|
179
|
+
);
|
180
|
+
|
181
|
+
create or replace function circle_val(circle, circle) returns setof pl_box as '
|
182
|
+
b0 = args[0]
|
183
|
+
b1 = args[1]
|
184
|
+
yield b0.overlap?(b1), b0.overleft?(b1), b0.overright?(b1),
|
185
|
+
b0.left?(b1), b0.right?(b1), b0.below?(b1), b0.above?(b1)
|
186
|
+
' language 'plruby';
|
187
|
+
|
188
|
+
|
189
|
+
select * from
|
190
|
+
circle_val('<(5,1),3>'::circle, '<(1,2),100>'::circle);
|
191
|
+
|
192
|
+
select * from
|
193
|
+
circle_val('<(100,200),10>'::circle, '<(100,1),115>'::circle);
|
194
|
+
|