Radim Blazek wrote:
> > > Ideally, someone would produce a Tcl/Tk replacement for v.digit, then
> > > the R_get_location_* stuff can be discarded altogether (no other
> > > module is important enough to stand in the way of that change).
> > >
> > > Unfortunately, I don't think anyone other than Radim understands the
> > > vector API well enough to perform the necessary enhancements to
> > > v.{in,out}.ascii (topology support).
> >
> > All you need to modify a vector is Vect_write_line(),
> > Vect_rewrite_line() and Vect_delete_line().
>
>
> Is "v.build option=dump" a good starting point for a format to use
> to describe any vector's topology?
What do you want to do exactly? option=dump is only for debugging.
You dont need to care about topology, you just write/delete lines
the topology is create automaticaly.
What I want to do exactly is extract vector maps from GRASS to a
textual format which can be read by e.g. Tcl/Tk programs, modify the
data, write it out in a textual format and import it back into GRASS,
all without loss of information.
v.out.ascii doesn't include the topology information, so if you want
to draw filled polygons, you have to build the topology yourself.
An example might help. I've attached a Tcl/Tk script which displays a
vector map in a Tk canvas. Sample usage (in spearfish):
wish vect.tcl fields
It uses v.out.pov, because that was the only obvious way to extract a
vector map in a textual format with topology information. However,
v.out.pov doesn't export everything which makes up the map, only
enough to draw it. For a more general export tool, the textual format
needs to contain everything, so that the export/import cycle doesn't
lose anything.
v.out.ascii has all of the information, but not the topology (for a
while, I thought that it was omitting data, until I realised that the
boundary segments didn't define complete polygons).
Whilst I could probably figure out how to modify v.out.pov to behave a
bit more like v.out.ascii (i.e. dump out "raw" data), the main problem
is that, in order to avoid trashing users' data (which I'd really like
to avoid), you need to be sure to include /everything/ in the exported
data. Which essentially requires that you understand what you are
doing, rather than just dumping out whatever data you can find and
hoping that you haven't missed anything.
--
Glynn Clements <glynn@gclements.plus.com>
(attachments)
vect.tcl (3.06 KB)