[GRASSLIST:6152] Re: v.mkgrid problems again...

Radim Blazek blazek at itc.it
Mon Mar 14 03:50:00 EST 2005


The horizontal lines are divided by 3:
/*
* For latlon, must draw in shorter sections
* to make sure that each section of the grid
* line is less than half way around the globe
*/

and horizontal lines are written in loop:
x_len = length/3.;
for () {
     next_x = x + x_len;
}

and to get exactly the same value for verticals
for () {
     x += x_len;
     x += x_len;
     x += x_len;
}

I guess that compiler can optimize the verticals to
x += 3*x_len; and the result will be different.

I have changed that for horizontals in HEAD branch to
x = startx;
for (j = 0; j < 3; j++)
{
    if ( j < 2 )
       next_x = x + x_len;
    else
       next_x = startx + length;
}
and verticals
for () {
     x += length;
}

which should always give that same value for grid nodes.


Radim


Dylan Beaudette wrote:
> Hi everyone,
> 
> last month I was having some trouble with v.mkgrid producing boundaries, 
> centroids, but no areas... after upgrading to GRASS6-beta1 the problem 
> was solved. Now with the latest GRASS 6.0.0 source v.mkgrid is not 
> producing areas. As a comparison, the GRASS6 package for MacOS X 
> produces the correct output.
> 
> Here is a comparison of the output:
> 
> MacOS X Package version of GRASS6:
> ---------------------
> GRASS 6.0.0 (pinn):~ > v.mkgrid map=g grid=3,3 ; d.vect g
> Creating vector grid ...
> Writing out vector rows ...
> Writing out vector columns ...
> Creating centroids ...
> Building topology ...
> 57 primitives registered
> Building areas:  100%
> 0 areas built
> 0 isles built
> Attaching islands:
> Attaching centroids:  100%
> Topology was built.
> Number of nodes     :   61
> Number of primitives:   57
> Number of points    :   0
> Number of lines     :   0
> Number of boundaries:   48
> Number of centroids :   9
> Number of areas     :   0
> Number of isles     :   0
> Number of incorrect boundaries   :   48
> Number of centroids outside area :   9
> ---------------------
> 
> GRASS 6.0.0 on linux from source code:
> ---------------------
> GRASS 6.0.cvs:~ - spearfish57 > v.mkgrid map=g grid=3,3
> Creating vector grid ...
> Writing out vector rows ...
> Writing out vector columns ...
> Creating centroids ...
> Building topology ...
> 57 primitives registered
> Building areas:  100%
> 9 areas built
> 1 isles built
> Attaching islands:  100%
> Attaching centroids:  100%
> Topology was built.
> Number of nodes     :   49
> Number of primitives:   57
> Number of points    :   0
> Number of lines     :   0
> Number of boundaries:   48
> Number of centroids :   9
> Number of areas     :   9
> Number of isles     :   1
> ---------------------
> 
> 
> Any ideas on why this is happening?
> 
> Thanks in advance!
> 
> Dylan




More information about the grass-user mailing list