[GRASS5] Q. How do you find the islands for a given area?
David D Gray
ddgray at armadce.demon.co.uk
Sat Feb 24 20:12:57 EST 2001
"Eric G. Miller" wrote:
> I've been looking into the d.area island drawing problem. Anyway, I'm
> trying to figure out how you find out:
I'm not familiar with this particular code, but a few remarks on the
> For a given area A:
> How many interior boundary islands does it have?
> How do I get line_pnts struct(s) for just these interior islands?
Instead of using the top level n_isles field, identify the index of the
area you are examining. This is available in struct Map_info as Area, an
area of pointers to P_AREA structures, each of which describes the
topology of just one area. The array starts at index 1, unusually. This
gives the number of bounding lines (for the outer hull), and a list
which is just an array of pointers to integers that represent the
indices of the lines in the top level Line array. Similarly, the n_isles
field and isles field give the number of islands and their identity
resp. The isles field is an array of pointer to int which are the
indices of the islands in top_level Isle which are islands of this area,
so that will get you the islands.
Each of these indices can be used in Vect_get_isle_points() to pull out
the points into a struct line_pnts.
> I've discovered I can get the total number of islands in the map with
> And, I can get an island using:
> Vect_get_isle_points (&Map, isle_num, &pnts)
> Problem is, I want to know just the islands for the current area. Even
> with V2_get_area (&Map, area_num, &area_ptr), the area_ptr->n_isles
> gives me nothing (even though I'm using a little test vector that has
> two areas each with one interior island).
This should work, but the area, island elements and so on are
topological structures, they will be empty or invalid till you build the
map. If that is so you should get a result from this. Maybe there is a
bug in V2_get_area(). Writing v.out.shape, I extracted this info
manually, bit by bit as I described above. Perhaps that would work,
certainly it is OK in v.out.shape.
> My idea for a solution to the filled area drawing routines would
> basically connect all the islands to their outer area where the
> island is closest to the area boundary. (Make any sense). I don't know
> how else these holes could be handled.
> | _ |<= Area
> | / \ |
> | \_/ |
> | Isle^ |
> | | | (Area "line points" now loops down and around island,
> | / \ | then back up to where it dropped down to the island
> | \_/ | to continue the rest of the area boundary)
> | |
> What am I missing?
Yes this is more a problem in 2d vector rendering, rather than a map
problem. Vector drawing is not my forte, but I understand this is
commonly how it is done.
I have recently been thinking that we should maintain a cache that
stores the polygons in this form for drawing purposes. Cached data could
be read for rapid display if the timestamp on the cache is more recent
than the persistent data in Map_info. Pulling topological data out of
dig_plus to generate geometry is quite fast anyway, but would be faster
still if the information was cached.
If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo at geog.uni-hannover.de with
subject 'unsubscribe grass5'
More information about the grass-dev