[GRASS5] [bug #4190] (grass) Could not import a NB Double Stereographic shapefile - used EPSG #2036

Hi,

I have tried to import the SHAPE file:
v.in.ogr nbaa_5000_ranb.shp out=nbaa loc=new_brunswick
Segmentation Fault.

Using 'ddd', I found:

0xb7791448 in strcmp () from /lib/tls/libc.so.6
(gdb) up
#1 0xb78c2515 in G_find_key_value (key=0x0, kv=0x80794e8) at key_value1.c:107
/home/neteler/soft/61grass_cvsexp/lib/gis/key_value1.c:107:2013:beg:0xb78c2515

It happens here:
char *G_find_key_value (char *key, struct Key_Value *kv)
{
    int n;
    
    for (n = 0; n < kv->nitems; n++)
        if (strcmp (key, kv->key[n]) == 0) <----------- ZAP!
            return kv->value[n][0] ? kv->value[n] : NULL;
    return NULL;
}

while n is 0.

It is called in lib/proj/convert.c:352

        sprintf(path,"%s/etc/projections",G_gisbase());
        if( G_lookup_key_value_from_file(path,pszProj,name,sizeof(name)) > 0 )

At this stage 'pszProj' is empty (huh).

This is called in v.in.ogr/main.c here in line 371:
        if ( GPJ_osr_to_grass( &cellhd, &proj_info,
                               &proj_units, Ogr_projection, 1) < 0 )

where Ogr_projection is empty (huh) because above

  Ogr_projection = OGR_L_GetSpatialRef(Ogr_layer);

but Ogr_layer is empty (huh!!).

Apparently
    /* Open OGR DSN */
    Ogr_ds = OGROpen( dsn_opt->answer, FALSE, NULL );
    if ( Ogr_ds == NULL ) G_fatal_error (_("Cannot open data source: %s"),
dsn_opt->answer);

fails.

According to
http://www.gdal.org/ogr/ogr__api_8h.html#82ff6956f7e39436cc7d6550247435d5
the OGROpen() function isn't used correctly.

I'll try and report back.

This sort of bug was also reported by others to me.

Markus

-------------------------------------------- Managed by Request Tracker