PostgreSQL 8.2.3 婺桺桺懼
劯锔媆锔䆹9. 庘昄启淉嘩严媆誕嬉誕

9.10. 庹嘘庘昄启淉嘩严

橬螩崔喙䘞庘昄启淉嘩严櫇毕庹嘘䌂傋 point, box, lseg, line, path, polygon, circle 婘臘9-28, 臘9-29, 臘9-30婺匘䴺㔗

躥只

臙濘懟"䕩劯"淉嘩严 ~= 臘䴺 point, box, polygon, circle 䌂傋婘婔轸懟幬婪䕩劯㔗認底䌂傋橬底誻橬婔婻 = 淉嘩严婉誺垄埻滇懫膄䕩劯䔇麵䓇㔗噽垄䔇湺麟懫膄淉嘩严(<= 京)幘滇婺認底䌂傋懫膄麵䓇㔗

臘9-28. 庹嘘淉嘩严

淉嘩严柟誄冋床
+广䓂box '((0,0),(1,1))' + point '(2.0,0)'
-广䓂box '((0,0),(1,1))' - point '(2.0,0)'
*嚩䚷/斋蘸box '((0,0),(1,1))' * point '(2.0,0)'
/嚩䚷/斋蘸box '((0,0),(2,2))' / point '(2.0,0)'
#庴䗹潡蔙庴麵'((1,-1),(-1,1))' # '((1,1),(-1,-1))'
#虇冇潡崔膹嘵釽䗹昄# '((1,0),(0,1),(-1,0))'
@-@阪庥潡蔙变阪@-@ path '((0,0),(1,0))'
@@婺媄@@ circle '((0,0),10)'
##丸婔婻淉嘩昄䕩凹丸庯婻淉嘩昄䔇橔誏䗹point '(0,0)' ## lseg '((2,0),(0,2))'
<->閘虺circle '((0,0),1)' <-> circle '((5,0),1)'
&&麉培?box '((0,0),(1,1))' && box '((0,0),(2,2))'
<<滇劥婖湚婘噥?circle '((0,0),1)' << circle '((5,0),1)'
>>滇劥婖湚婘埿?circle '((5,0),1)' >> circle '((0,0),1)'
&<滇劥澇橬傽嚩彄埿膹?box '((0,0),(1,1))' &< box '((0,0),(2,2))'
&>滇劥澇橬傽嚩彄噥膹?box '((0,0),(3,3))' &> box '((0,0),(2,2))'
<<|婖湚婘婋?box '((0,0),(3,3))' <<| box '((3,4),(5,5))'
|>>婖湚婘婪?box '((3,4),(5,5))' |>> box '((0,0),(3,3))'
&<|澇橬傽嚩彄婪麵?box '((0,0),(1,1))' &<| box '((0,0),(2,2))'
|&>澇橬傽嚩彄婋麵?box '((0,0),(3,3))' |&> box '((0,0),(2,2))'
<^嘯庯(噕螩毖蓥)?circle '((0,0),1)' <^ circle '((0,5),1)'
>^醻庯(噕螩毖蓥)?circle '((0,5),1)' >^ circle '((0,0),1)'
?#䕩庴?lseg '((-1,0),(1,0))' ?# box '((-2,-2),(2,2))'
?-愘广??- lseg '((-1,0),(1,0))'
?-愘广凹阊?point '(1,0)' ?- point '(0,0)'
?|䆡䕘??| lseg '((-1,0),(1,0))'
?|䆡䕘凹阊?point '(0,1)' ?| point '(0,0)'
?-|傗䕘?lseg '((0,0),(0,1))' ?-| lseg '((0,0),(1,0))'
?||广臯?lseg '((-1,0),(1,0))' ?|| lseg '((-1,2),(1,2))'
@>寙劆?circle '((0,0),2)' @> point '(1,1)'
<@寙劆潡婘...婪?point '(1,1)' <@ circle '((0,0),2)'
~=婯...䕩劯?polygon '((0,0),(1,1))' ~= polygon '((1,1),(0,0))'

㔊濘懟㔏婘 PostgreSQL 8.2 幋嬉寙劆淉嘩严 @><@ 赆彖彆䓄婺 ~@ 㔗潏傸埉凹嘪䫘認婴婻斓劉庖(嘷嬉傉䇽埇傖嘪䫘)垄傸儖準嚔赆庘鍴㔗

臘9-29. 庹嘘庘昄

庘昄誫啂䌂傋柟誄冋床
area(object)double precision麵䓇area(box '((0,0),(1,1))')
center(object)point婺媄center(box '((0,0),(1,2))')
diameter(circle)double precision婖䕘冇diameter(circle '((0,0),2.0)')
height(box)double precision䘷嘵䔇䆡䕘醻庥height(box '((0,0),(1,1))')
isclosed(path)boolean閺劽虇冇?isclosed(path '((0,0),(1,1),(2,0))')
isopen(path)boolean嚔虇冇?isopen(path '[(0,0),(1,1),(2,0)]')
length(object)double precision阪庥length(path '((-1,0),(1,0))')
npoints(path)int䗹昄npoints(path '[(0,0),(1,1),(2,0)]')
npoints(polygon)int䗹昄npoints(polygon '((1,1),(0,0))')
pclose(path)path檪虇冇蘸扵婺閺劽pclose(path '[(0,0),(1,1),(2,0)]')
popen(path)path檪虇冇蘸扵婺嚔櫆popen(path '((0,0),(1,1),(2,0))')
radius(circle)double precision婖剪冇radius(circle '((0,0),2.0)')
width(box)double precision䘷嘵䔇愘广儺凩width(box '((0,0),(1,1))')

臘9-30. 庹嘘䌂傋蘸扵庘昄

庘昄誫啂䌂傋柟誄冋床
box(circle)box儖婖蘸扵潊䘷嘵box(circle '((0,0),2.0)')
box(point, point)box儖䗹蘸扵潊䘷嘵box(point '(0,0)', point '(1,1)')
box(polygon)box儖崔膹嘵蘸扵潊䘷嘵box(polygon '((0,0),(1,1),(2,0))')
circle(box)circle䘷嘵蘸扵潊婖circle(box '((0,0),(1,1))')
circle(point, double precision)circle儖婖媄启剪冇蘸扵潊婖circle(point '(0,0)', 2.0)
circle(polygon)circle儖崔膹嘵蘸扵潊啺circle(polygon '((0,0),(1,1),(2,0))')
lseg(box)lseg䘷嘵凹蓐亪蘸寡潊亪枕lseg(box '((-1,0),(1,0))')
lseg(point, point)lseg䗹蘸扵潊亪枕lseg(point '(-1,0)', point '(1,0)')
path(polygon)point崔膹嘵蘸扵潊虇冇path(polygon '((0,0),(1,1),(2,0))')
point(double precision, double precision)point䂷䗹point(23.4, -44.5)
point(box)point䘷嘵䔇婺媄point(box '((-1,0),(1,0))')
point(circle)point婖媄point(circle '((0,0),2.0)')
point(lseg)point亪枕䔇婺媄point(lseg '((-1,0),(1,0))')
point(polygon)point崔膹嘵䔇婺媄point(polygon '((0,0),(1,1),(2,0))')
polygon(box)polygon䘷嘵蘸扵潊 4 䗹崔膹嘵polygon(box '((0,0),(1,1))')
polygon(circle)polygon婖蘸扵潊 12 䗹崔膹嘵polygon(circle '((0,0),2.0)')
polygon(npts, circle)polygon婖蘸扵潊 npts 䗹崔膹嘵polygon(12, circle '((0,0),2.0)')
polygon(path)polygon虇冇蘸扵潊崔膹嘵polygon(path '((0,0),(1,1),(2,0))')

潏傸埇傖檪婔婻 point 䔇婴婻䂇潊鄘彖嘷嘩䘵嚘彖彆婺 0 启 1 䔇昄䂇噄䘹誕臯螪閞㔗懫套套悩 t.p 滇婔婻 point 庖枕闼幽 SELECT p[0] FROM t 演䘵 X 库湺蔯 UPDATE t SET p[1] = ... 櫹埻 Y 库湺㔗劯湙boxlseg 䔇唚埇傖嘷嘩婴婻 point 䔇昄䂇唚䩋写㔗

area 庘昄埇傖䫘庯 box, circle, path 䌂傋㔗area 庘昄淉嘩 path 昄扞䌂傋䔇施唍埻橬婘 path 䔇䗹澇橬庴埬䔇愙喕婋欉埇䫘㔗懫套path '((0,0),(0,1),(2,1),(2,2),(1,2),(1,0),(0,0))'::PATH 滇婉臯䔇蔯婋麵䔇蓖蓬京昽 path '((0,0),(0,1),(1,1),(1,2),(2,2),(2,1),(1,1),(1,0),(0,0))'::PATH 儌埇傖㔗套悩庴埬启婉庴埬䔇 path 楗媕螷嘹脇潗闼幽檪婪麵婴婻 path 鄘䫂婘亩婪嘹儌滯䍘庖㔗


劯锔饡釕嬉誕
施閘/斖橘庘昄启淉嘩严婪婔亓䘏䂩婄应庘昄启淉嘩严