[GRASS-dev] Re: testing the new network modules

Moritz Lennert mlennert at club.worldonline.be
Wed Jan 13 07:26:05 EST 2010


On Tue, January 12, 2010 20:43, Daniel Bundala wrote:
> Thanks for the comments and testing of the modules. Just a quick
> reply. I did not have a look at the first two problems but the likely
> cause of the last problem is that you ran out of memory. I am not sure
> about the details, but the module needs about 4*N*N bytes of memory
> where N is the number of nodes.

Several comments:

- This is one of the examples of where there is possible confusion with
layers. In v.net.allpairs/main.c you have one option for defining a layer,
and you use it twice, once for defining the layer of nodes:

    layer = atoi(field_opt->answer);
    chcat =
        (neta_initialise_varray
         (&In, layer, GV_POINT, where_opt->answer, cat_opt->answer,
          &varray) == 1);

and once to build the graph (with the arcs):

    Vect_net_build_graph(&In, mask_type, atoi(field_opt->answer), 0,
                         afcol->answer, abcol->answer, NULL, geo, 0);

So, it is not possible to have nodes defined on a different layer from arcs.

- Further on in v.net.allpairs/main.c (lines 166ff), IIUC, you allocate
memory space for all nodes in the graph, and not only those that you want
to calculate distances for (i.e. those defined by the cats option). Why is
this necessary ? In the man page you say "the table is filled only for the
selected points. In other  words,  cat columns  contains  only  selected
points but the distances are computed and updated for all other nodes."
Again, why is it necessary to compute the distances between all nodes ?

- The '-a' flag does not seem to work as I would expect. Do I understand
correctly that if I have a network of arcs, but without points at nodes,
this flag should create the points and then calculate the distances
between them. Right now, with a map test with the following topology
(attached as GRASS ascii file to be imported into NC demo location with
v.in.ascii format=standard):

GRASS 6.4.0svn (nc_spm_06):~ > v.build test
Building topology for vector map <test>...
Registering primitives...
9 primitives registered
25 vertices registered
Building areas...
 100%
0 areas built
0 isles built
Attaching islands...
Attaching centroids...
 100%
Number of nodes: 9
Number of primitives: 9
Number of points: 0
Number of lines: 9
Number of boundaries: 0
Number of centroids: 0
Number of areas: 0
Number of isles: 0


v.net.allpairs -a in=test out=dist

gives me:

Building topology for vector map <dist>...
Registering primitives...
0 primitives registered
0 vertices registered
Building areas...
0 areas built
0 isles built
Attaching islands...
Attaching centroids...
Number of nodes: 0
Number of primitives: 0
Number of points: 0
Number of lines: 0
Number of boundaries: 0
Number of centroids: 0
Number of areas: 0
Number of isles: 0

i.e. an empty map with an empty table.

Could this be because in main.c you create the array output[] (defining
which points to include in the output, v.net.allpairs/main.c lines 187ff)
before you add the new points to nodes and so these points are not taken
into account ?

- Also, the following (v.net.allpairs/main.c, lines 205ff) seems a bit
inefficient, as it even if the -a flag is not set, it still loops through
the entire lot of nodes:

    for (i = 1; i <= nnodes; i++)
        if (newpoints_f->answer && cats[i] == -1) {
            Vect_reset_cats(Cats);
            Vect_cat_set(Cats, 1, max_cat);
            cats[i] = max_cat++;
            neta_add_point_on_node(&In, &Out, i, Cats);
        }

It would seem more efficient to only enter the loop if the flag is set.
But this should probably be rewritten anyhow in order to take into account
the previous point, unless my understanding of all this is completely off.

- Now using the above test map and adding nodes to it with v.net (to layer
1 !) and the v.net.allpairs:

v.net -c test operation=nodes out=test_nodes nlayer=1
v.net.allpairs in=test_nodes out=dist_nodes

I get distances for some pairs, but most distances are -0.001. What does
that mean ?

- Finally, I wanted to come back to the question of introducing min and
max thresholds in v.net.distance. I don't understand the code well enough
at this stage to be able to suggest anything, but I think these thresholds
would be very useful. In the code (netalib/path.c) you say that the
function neta_distance_from_points() "computes shortest paths to every
node from  nodes in "from". Array "dst" contains the length of the path".
So does this mean that dst contains an array of distances between each
from node to all other nodes ? If so, wouldn't it be possible to select
from this array the smallest distance within the threshold defined by min
& max ?
Just an uneducated guess here...

Once again, thanks for all these modules. Once they are polished / once I
really understand how to use them, they will be extremely helpful !

Moritz

>
> I hope I will have a time to look at it in more detail later this weak.
>
> Best,
> Daniel
>
> On Tue, Jan 12, 2010 at 3:17 PM, Moritz Lennert
> <mlennert at club.worldonline.be> wrote:
>> Dear Daniel,
>>
>> Here some more comments on the network modules:
>>
>> ** all modules:
>>
>> The 'layer' option is not always very clear in your modules. Do they
>> concern nodes or arcs ? And in modules where you need both, how to
>> specify
>> that nodes are on a different layer than arcs ? In the original v.net
>> modules, there generally is alayer for arcs and nlayer for nodes. Any
>> reason this cannot be implemented in your modules ?
>>
>> ** v.net.centrality:
>>
>> Steps in nc_spm_06 NC demo data:
>> - v.net -c in=streets_wake out=streets_nodes operation=nodes
>> - v.net.centrality in=streets_nodes out=streets_centrality degree=degree
>> => segmentation fault
>>
>> Here's the DEBUG=3 output:
>>
>> D1/3: Vect_open_old(): vector opened on level 2
>> D1/3: Vect_read_dblinks(): map = streets_nodes, mapset = user1
>> D3/3: Searching for FID column in OGR DB
>> D1/3: dbln file:
>> /home/mlennert/GRASSDATA/nc_spm_06/user1/vector/streets_nodes/dbln D1/3:
>> dbln: 1 streets_nodes cat $GISDBASE/$LOCATION_NAME/$MAPSET/dbf/ dbf
>> D3/3:
>> Field number <1>, name <(null)>
>> D3/3: Vect_check_dblink: field 1
>> D1/3: field = 1 name = (null), table = streets_nodes, key = cat,
>> database
>> = $GISDBASE/$LOCATION_NAME/$MAPSET/dbf/, driver = dbf
>> D1/3: Dblinks read
>> D1/3: Vect_Rewind(): name = streets_nodes
>> D2/3: Vect_open_new(): name = streets_centrality
>> D1/3: Vect_set_thresh(): thresh = 0.000000
>> D1/3: V1_open_new_nat(): name = streets_centrality
>> Erreur de segmentation
>>
>> I will have to recompile to provide gdb output, so please let me know if
>> this is necessary/useful for you.
>>
>> ** v.net.allpairs
>>
>> v.net.allpairs in=streets_nodes out=dist --overwrite
>>
>> leads to
>>
>> ERROR: G_calloc: unable to allocate 41814 * 4 bytes at main.c:174
>>
>> Any ideas on the latter two ?
>>
>> Best wishes,
>> Moritz
>>
>>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.ascii.zip
Type: application/zip
Size: 619 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/grass-dev/attachments/20100113/a06df66b/test.ascii.zip


More information about the grass-dev mailing list