[GRASS-dev] Addons: r.horizon single point mode segfault

Hi,

I tried to use r.horizon in single point mode but it segfaults:

GRASS 6.4.svn (spearfish60):~/grass64 > gdb r.horizon
GNU gdb 6.6-3mdv2008.0 (Mandriva Linux release 2008.0)
...
This GDB was configured as "x86_64-mandriva-linux-gnu"...
Using host libthread_db library "/lib64/libthread_db.so.1".
(gdb) r elevation.dem step=30 direction=15 bufferzone=200
coord=-103.75026822,44.43602767
...
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 47370162098592 (LWP 6037)]
0x0000000000404e1f in calculate (xcoord=-103.75026822,
ycoord=44.436027670000001, buffer_e=6, buffer_w=6, buffer_s=6,
buffer_n=6)
    at main.c:1101
1101 z_orig = zp = z[yindex][xindex];
(gdb) bt
#0 0x0000000000404e1f in calculate (xcoord=-103.75026822,
ycoord=44.436027670000001, buffer_e=6, buffer_w=6, buffer_s=6,
buffer_n=6)
    at main.c:1101
#1 0x00000000004036fa in main (argc=6, argv=0x7fff78d62728) at main.c:510

(gdb) bt full
#0 0x0000000000404e8f in calculate (xcoord=-103.75026822,
ycoord=44.436027670000001, buffer_e=6, buffer_w=6, buffer_s=6,
buffer_n=6)
    at main.c:1102
        i = 11098
        j = -1268384144
        l = 32767
        k = 0
        numDigits = 6
        xindex = -19662
        yindex = -163781
        shadow_angle = 1.6975966453708918e-313
        coslat = 6.9532931413279238e-310
        latitude = 6.9532931413255523e-310
        longitude = 3.1434037398486797e-317
        xp = 1840
        yp = -9999
        inputAngle = 1840
        delt_lat = 4.9406564584124654e-324
        delt_lon = 1840
        delt_east = 6.9532931413318763e-310
        delt_nor = 2.0797925572540819e-317
        delt_dist = 3.1234217488682763e-317
        formatString = "��e��\177\000\000\233�"
        hor_row_start = 6
        hor_row_end = 484
        hor_col_start = 6
        hor_col_end = 641
        hor_numrows = 478
        hor_numcols = 635
        arrayNumInt = 490
        dfr_rad = 1.3729312770741917e-311
#1 0x000000000040374a in main (argc=6, argv=0x7fffb4660028) at main.c:510
        xcoord = -103.75026822
        ycoord = 44.436027670000001
        module = (struct GModule *) 0x2b5af6ad2660
        parm = {elevin = 0x2b5af6ad25c0, dist = 0x60db40, coord =
0x60da80, direction = 0x60d400, horizon = 0x60d9c0,
  step = 0x60d4a0, bufferzone = 0x60d540, e_buff = 0x60d5e0, w_buff =
0x60d680, n_buff = 0x60d720, s_buff = 0x60d7e0,
  maxdistance = 0x60d900}
        flag = {degreeOutput = 0x2b5af6ad2580}
        in_proj_info = (struct Key_Value *) 0x60b400
        in_unit_info = (struct Key_Value *) 0x611470

What could be the problem here?

thanks
Markus

Markus Neteler wrote:

I tried to use r.horizon in single point mode but it segfaults:

(gdb) r elevation.dem step=30 direction=15 bufferzone=200

Spearfish?

coord=-103.75026822,44.43602767

Hmm.

1101 z_orig = zp = z[yindex][xindex];

        xindex = -19662
        yindex = -163781

What could be the problem here?

        xcoord = -103.75026822
        ycoord = 44.436027670000001

This:

194 stepx = cellhd.ew_res;
195 stepy = cellhd.ns_res;

215 xmin = cellhd.west;
216 ymin = cellhd.south;

461 xmin = new_cellhd.west;
462 ymin = new_cellhd.south;

1073 xindex = (int)((xcoord - xmin) / stepx);
1074 yindex = (int)((ycoord - ymin) / stepy);

suggests that coord= is supposed to be cartographic coordinates, but
coord=-103,44 is way outside of the Spearfish region (~600000,4920000).

--
Glynn Clements <glynn@gclements.plus.com>

On Fri, Sep 26, 2008 at 3:50 AM, Glynn Clements
<glynn@gclements.plus.com> wrote:

Markus Neteler wrote:

I tried to use r.horizon in single point mode but it segfaults:

(gdb) r elevation.dem step=30 direction=15 bufferzone=200

Spearfish?

Yes.

coord=-103.75026822,44.43602767

Hmm.

1101 z_orig = zp = z[yindex][xindex];

        xindex = -19662
        yindex = -163781

What could be the problem here?

        xcoord = -103.75026822
        ycoord = 44.436027670000001

This:

194 stepx = cellhd.ew_res;
195 stepy = cellhd.ns_res;

215 xmin = cellhd.west;
216 ymin = cellhd.south;

461 xmin = new_cellhd.west;
462 ymin = new_cellhd.south;

1073 xindex = (int)((xcoord - xmin) / stepx);
1074 yindex = (int)((ycoord - ymin) / stepy);

suggests that coord= is supposed to be cartographic coordinates, but
coord=-103,44 is way outside of the Spearfish region (~600000,4920000).

Good point. I gave LL coords to the module.

This works:
GRASS 6.4.svn (spearfish60):~ > g.region -c
center easting: 599505.000000
center northing: 4921010.000000
GRASS 6.4.svn (spearfish60):~ > r.horizon elevation.dem step=30
direction=15 bufferzone=200 coord=599505.0,4921010.0

15.000000, 0.408906
45.000000, 0.140486
75.000000, 0.000000
105.000000, 0.000000
135.000000, 0.158644
165.000000, 0.260598
195.000000, 0.303381
225.000000, 0.318726
255.000000, 0.237845
285.000000, 0.276001
315.000000, 0.368949
345.000000, 0.408906

So everything fine here.

thanks
Markus

Hi Markus,

On Fri, Sep 26, 2008 at 3:50 AM, Glynn Clements
<glynn@gclements.plus.com> wrote:

Markus Neteler wrote:

I tried to use r.horizon in single point mode but it segfaults:

(gdb) r elevation.dem step=30 direction=15 bufferzone=200

[snip]

you surely already know that; but I specify for others reading that topic.
Note that:

1. if your projection is based on distance (easting and northing), the coordinates values must be in meters.
2. the elevation and maximum distance must be measured in meters, even if you use geographical coordinates (longitude/latitude)
3. the buffer parameters must be in the same units as the raster coordinates.

Cheers,

Marco