sql - How do I change the radius of a circle in PostgreSQL? -



sql - How do I change the radius of a circle in PostgreSQL? -

(using postgresql 9.1, without gis stuff installed)

assuming i've got box (which should square):

> select box '((0, 0), (1,1))' "(1,1),(0,0)"

i can circle fits within square:

> select circle (box '((0, 0), (1,1))') "<(0.5,0.5),0.707106781186548>"

and bit of messing around can bigger circle:

> select circle(center(circle(box '((0, 0), (1,1))')), radius(circle(box '((0, 0), (1,1))')) * 2) "<(0.5,0.5),1.4142135623731>"

but doing prepared statement means passing square twice:

"select circle(center(circle(?)), radius(circle(?)) * 2)

which isn't deal breaker, sense there should 'better' way of doing it.

is there easier/better way of resizing circle? specifically, want circle center @ center of box, , radius equal half diagonal length of box.

(if helps, i'm using "contained in or on" ('<@') operator set of points within area)

thanks.

i build statement using sql 'with' command. want of form:

with bxx (select center(bx) cb, length(diagonal(bx)) lb (select box('((0,0),(1,1))') bx) bun) select circle(cb, lb) bxx;

the clause generates table used in next sql (select in case) statement.

what here build table containing column box center , 1 length of diagonal. subquery in 'with' clause establishes box column (bx).

sql requires subquery named, hence 'as bun' -- unused.

this construction makes easier fiddle center , length parameters variations of problem.

i should point out in problem statement, first circle create outside box (center in center, radius half diagonal -- meaning box inscribed in circle). circle within box, want utilize radius length of half length of sides of square, not diagonal.

sql postgresql geometry

Comments

Popular posts from this blog

c - Compilation of a code: unkown type name string -

java - Bypassing "final local variable defined in an enclosing type" -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -