[GRASS5] v.in.ogr behaviour

marcos boullón magán marcosboullon at gmail.com
Thu Mar 23 09:46:52 EST 2006


Hi Stephan,

Sorry, but it seems that Cho's patch is not correct.

In file lib/proj/convert.c, line 227, the definition of
GPJ_osr_to_grass() states that fourth parameter is type
"OGRSpatialReferenceH", not "OGRSpatialReferenceH *" (a value, not a
pointer to the value):

int GPJ_osr_to_grass(struct Cell_head *cellhd, struct Key_Value **projinfo,
                     struct Key_Value **projunits, OGRSpatialReferenceH hSRS,
                     int interactive)

In file vector/v.in.ogr/main.c, line 384, the cvs code does a correct
use of this function:

        if ( GPJ_osr_to_grass( &cellhd, &proj_info,
                               &proj_units, Ogr_projection, 0) < 0 )

The patch incorrectly sends a pointer to the Ogr_projection variable
(of type OGRSpatialReferenceH) insted of the actual value as fourth
parameter:

        if ( GPJ_osr_to_grass( &cellhd, &proj_info,
                               &proj_units, &Ogr_projection, 0) < 0 )

When the patch is applied --wrong datatype is used--
GPJ_osr_to_grass() fails to identify the reference system: file
lib/proj/convert.c, line 248 (no Geographic coord system, nor
Projected, then it assumes coord system is Projected XY) and you get
the error message "ERROR: Projection of dataset does not appear to
match current location. [...] cellhd.proj = 0 (unreferenced/unknown)".

In conclussion, patch is incorrect.

If you still get segfaults with GRASS cvs version, I'm afraid the
problem is not related to this. (Try an interative debugging to find
in which function it fails, then check which parameter produces the
crash and follow back its assignements).

Hope you can solve it. Regards,

M.

2006/3/23, Stephan Holl <holl at gdf-hannover.de>:
> Hello marcos,
>
> On Thu, 23 Mar 2006 13:01:54 +0100 "marcos boullón magán"
> <marcosboullon at gmail.com> wrote:
>
> > Hello Stephan,
> >
> > After applying the patch, the output is:
> >
> > marcos at venux:~/cvsgrass$ cd grass6/vector/v.in.ogr/
> > marcos at venux:~/cvsgrass/grass6/vector/v.in.ogr$ patch < ~/cho.patch
> > marcos at venux:~/cvsgrass/grass6/vector/v.in.ogr$ make
> > marcos at venux:~/cvsgrass/grass6/vector/v.in.ogr$ cd ../..
> > marcos at venux:~/cvsgrass/grass6/vector/v.in.ogr$ su
> > venux:/home/marcos/cvsgrass/grass6/vector/v.in.ogr# make install
> > marcos at venux:~/cvsgrass/grass6/vector/v.in.ogr$ grass61
> >
> > GRASS 6.1.cvs (spearfish60):~/cvsgrass/grass6/vector/v.in.ogr >
> > v.out.ogr in=soils type=area dsn=/tmp/ olayer=soils
> > Exporting 737 areas (may take some time) ...
> >  100%
> > 737 features written
> > WARNING: 1 features without attributes written
> >
> > GRASS 6.1.cvs (spearfish60):~/cvsgrass/grass6/vector/v.in.ogr >
> > v.in.ogr dsn=/tmp/soils.shp out=test1
> > ERROR: Projection of dataset does not appear to match current
> > location.
> >
> >        LOCATION PROJ_INFO is:
> >        name: UTM
> >        datum: nad27
> >        nadgrids: conus
> >        proj: utm
> >        ellps: clark66
> >        a: 6378206.4000000004
> >        es: 0.0067686580
> >        f: 294.9786982000
> >        zone: 13
> >
> >        cellhd.proj = 0 (unreferenced/unknown)
> >
> >        You can use the -o flag to v.in.ogr to override this check.
> >        Consider to generate a new location with 'location' parameter
> > from input data set.
>
> [...]
>
> This is what I recognize as well. So where to look for the error now?
>
> Perhaps someone with more knowledge about the projection/datum-stuff
> could investigate the code?
>
> Thank you
>
>         Stephan
>
> --
> GDF Hannover - Solutions for spatial data analysis and remote sensing
> Hannover Office      -     Mengendamm 16d      -     D-30177 Hannover
> Internet: www.gdf-hannover.de      -      Email: holl at gdf-hannover.de
> Phone : ++49-(0)511.39088507       -        Fax: ++49-(0)511.39088508
>

--
-- marcos boullón magán




More information about the grass-dev mailing list