April 4, 2002 --just fixed some bugs in geo_addfuncs.c
and added a few new calls, as return_buffer to make the buffer lines and
path_to_file for writing
postgres lines to format suitable for v.in.arc input. --alex
Here is an example of vector line buffer constructed from a GRASS line
map (rivers). It consists of polygons from another map (kuruma_id).
Both maps were exported to PostgreSQL with a new module v.to.pg
(see some other simple examples here).
----------------------------------------
For spatial buffer query, a simple C code was used to make a shared library with functions that can be loaded by Postgres backend by commands like: CREATE FUNCTION pt_in_path_buffer(path,point,float8) RETURNS boolean AS 'geo_addfuncs.so','path_buffer_contain_pt' LANGUAGE 'c'; (syntax is for 7.1.3 version - different in 7.2) Now we can query polygons (and sites) in different ways: a) center of polygon boundary box is within buffer (picture)
etc. To draw the selected (falling in 1000 m buffer) polygons on screen: d.vect.pg -f -s map=kuruma_id sql=test_buffer1000.sql
color=grey
test_buffer<i>.sql:
|
|
----------------------------------------------------
Make buffers in psql with command: select path_to_file(return_buffer(path_reduce(segment,2),100))
Each time it writes a single result buffer line (in picture in violet
- 100 m) in the
Functions 'path_to_file', 'return_buffer' and 'path_reduce' are from the same library, and are created by Postgres superuser using CREATE FUNCTION. Check the code for correct parameter definitions before you create these SQL functions in psql. Note: 'path_reduce' second parameter is number of times the input
line is generalized before buffering. This parameter is 1 if radius of
buffering is less or equal to segments lengths. However, when radius is
much greater than distances between vertices, the true UNION of circles
is intrapolated by 'thinning" the number of vertices. Thus we can produce,
e.g.,
|
Finally, draw in yellow rivers themselves:
d.vect.pg -s map=rivers sql=show_rivs.sql color=yellow show_rivs.sql:
|
Alex Shevlakov, Motivation Free Software consulting,
Moscow, Russia
sixote@yahoo.com