[GRASS5] v.in.ogr behaviour

Dear list,

[sorry for crossposting, but perhaps this is interesting for the
GDAL-folks as well]

I am working with GRASS6_CVS and Oracle 9i which is compiled into
GDAL/OGR 1.3.1. Everything works if the tables in Oracle are owned by
the given user.
v.in.ogr reports the available layers as follows:
v.in.ogr -l dsn="OCI:owneroftables/pw@OCI" layer=DATA1 out=data1
Data source contains 2 layers:
DATA1, DATA2

Removing the -l-switch imports the data nicly and creates dataset data1
inside GRASS.

When I create another oracle-user with only
SELECT-privileges on that table, the tables inside Oracle are shown like
this:

v.in.ogr -l dsn="OCI:readonlyuser/pw@OCI" layer=OWNEROFTABLES.DATA1
out=data1
Data source contains 2 layers:
OWNEROFTABLES.DATA1, OWNEROFTABLES.DATA2

Trying to import now, this results in a Segmentation fault.
v.in.ogr dsn="OCI:readonlyuser/pw@OCI" layer=OWNEROFTABLES.DATA1
out=data1

So I assume the dot between user and table produces this?! Perhaps
anybody can give me a hint where to look at.

Using ogr2ogr works with both users and exports e.g. a shapefile
correct.

Thanks in advance for any pointers.

  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@gdf-hannover.de
Phone : ++49-(0)511.39088507 - Fax: ++49-(0)511.39088508

Hello Lists,

[crosspost again]

On Mon, 13 Mar 2006 12:09:15 +0100 Stephan Holl <holl@gdf-hannover.de>
wrote:

Dear list,

[sorry for crossposting, but perhaps this is interesting for the
GDAL-folks as well]

I am working with GRASS6_CVS and Oracle 9i which is compiled into
GDAL/OGR 1.3.1. Everything works if the tables in Oracle are owned by
the given user.
v.in.ogr reports the available layers as follows:
v.in.ogr -l dsn="OCI:owneroftables/pw@OCI" layer=DATA1 out=data1
Data source contains 2 layers:
DATA1, DATA2

Removing the -l-switch imports the data nicly and creates dataset
data1 inside GRASS.

When I create another oracle-user with only
SELECT-privileges on that table, the tables inside Oracle are shown
like this:

v.in.ogr -l dsn="OCI:readonlyuser/pw@OCI" layer=OWNEROFTABLES.DATA1
out=data1
Data source contains 2 layers:
OWNEROFTABLES.DATA1, OWNEROFTABLES.DATA2

Trying to import now, this results in a Segmentation fault.
v.in.ogr dsn="OCI:readonlyuser/pw@OCI" layer=OWNEROFTABLES.DATA1
out=data1

So I assume the dot between user and table produces this?! Perhaps
anybody can give me a hint where to look at.

Using ogr2ogr works with both users and exports e.g. a shapefile
correct.

Thanks in advance for any pointers.

Apparently noone has stumbled over this I will provide as much
information for the developers.
I have created a full gdb backtrace[1] of the segfault. But again, I do
not know where to dig into the problem since I do know what is going on
there...

Thank you for having a look what might go wrong here.

Best regards

  Stephan

[1] http://www.gdf-hannover.de/holl/tmp/v.in.ogr_bt-full.txt

--
GDF Hannover - Solutions for spatial data analysis and remote sensing
Hannover Office - Mengendamm 16d - D-30177 Hannover
Internet: www.gdf-hannover.de - Email: holl@gdf-hannover.de
Phone : ++49-(0)511.39088507 - Fax: ++49-(0)511.39088508

Hello Stephan,

[replying to myself again]

On Wed, 15 Mar 2006 09:37:26 +0100 Stephan Holl <holl@gdf-hannover.de>
wrote:

Hello Lists,

[crosspost again]

On Mon, 13 Mar 2006 12:09:15 +0100 Stephan Holl <holl@gdf-hannover.de>
wrote:

> Dear list,
>
> [sorry for crossposting, but perhaps this is interesting for the
> GDAL-folks as well]
>
> I am working with GRASS6_CVS and Oracle 9i which is compiled into
> GDAL/OGR 1.3.1. Everything works if the tables in Oracle are owned
> by the given user.
> v.in.ogr reports the available layers as follows:
> v.in.ogr -l dsn="OCI:owneroftables/pw@OCI" layer=DATA1 out=data1
> Data source contains 2 layers:
> DATA1, DATA2
>
> Removing the -l-switch imports the data nicly and creates dataset
> data1 inside GRASS.
>
> When I create another oracle-user with only
> SELECT-privileges on that table, the tables inside Oracle are shown
> like this:
>
> v.in.ogr -l dsn="OCI:readonlyuser/pw@OCI" layer=OWNEROFTABLES.DATA1
> out=data1
> Data source contains 2 layers:
> OWNEROFTABLES.DATA1, OWNEROFTABLES.DATA2
>
> Trying to import now, this results in a Segmentation fault.
> v.in.ogr dsn="OCI:readonlyuser/pw@OCI" layer=OWNEROFTABLES.DATA1
> out=data1
>
> So I assume the dot between user and table produces this?! Perhaps
> anybody can give me a hint where to look at.
>
> Using ogr2ogr works with both users and exports e.g. a shapefile
> correct.
>
> Thanks in advance for any pointers.

Apparently noone has stumbled over this I will provide as much
information for the developers.
I have created a full gdb backtrace[1] of the segfault. But again, I
do not know where to dig into the problem since I do know what is
going on there...

Thank you for having a look what might go wrong here.

Learning to use DDD with Markus help got further information for me.
When I run v.in.ogr through ddd I have severel stacks which can be
investigated.

1.UP: key_value1.c:107
2.UP: key_value4.c:49
3.UP: convert.c:352
4.UP: /v.in.ogr/main.c:384

It currently segfaults in key_value1.c:107 (strcmp).
When I put the lines into comments, recompile and run v.in.ogr with
-o-flag, the dataset gets imported with warning, at least it gets
imported.

So now I know, that there must be something wrong with the
projection-stuff. It seems to me that Markus has investigated something
similar in the bugtracker[1] also dealing with projection-stuff.

I have tried to find some hints in the CVS changelogs for key_value1.c
but I am not sure if they are relevant.

2006-01-04 12:40 markus G_malloc(); alloc() -> G_alloc(); calloc() ->
    G_calloc();realloc() -> G_realloc()

and

2006-02-09 04:08 glynn Use <grass/gis.h> etc rather than <gis.h>

Probably this problem is also relevant with the following changes:

2006-02-12 22:41 cho v.in.ogr segmentation fault fixed
          argument type fixed: OGRSpatialReferenceH * =>
          OGRSpatialReferenceH OGRSpatialReferenceH is already a
          pointer to void.

2006-02-09 17:58 cho vector/v.in.ogr/main.c: bug fixed: wrong argument
type passed

Does anybody know if this changes require any CVS-versions of GDAL/OGR
or PROJ.4?

?!

Thanks for any comments on this.

  Stephan
  
[1] https://intevation.de/rt/webrt?display=History&serial_num=4190

--
GDF Hannover - Solutions for spatial data analysis and remote sensing
Hannover Office - Mengendamm 16d - D-30177 Hannover
Internet: www.gdf-hannover.de - Email: holl@gdf-hannover.de
Phone : ++49-(0)511.39088507 - Fax: ++49-(0)511.39088508

Hello Stephan,

On Wed, 22 Mar 2006 11:10:58 +0100 Stephan Holl <holl@gdf-hannover.de>
wrote:

Hello Stephan,

[replying to myself again]

On Wed, 15 Mar 2006 09:37:26 +0100 Stephan Holl <holl@gdf-hannover.de>
wrote:

> Hello Lists,
>
> [crosspost again]
>
> On Mon, 13 Mar 2006 12:09:15 +0100 Stephan Holl
> <holl@gdf-hannover.de> wrote:
>
> > Dear list,
> >
> > [sorry for crossposting, but perhaps this is interesting for the
> > GDAL-folks as well]
> >
> > I am working with GRASS6_CVS and Oracle 9i which is compiled into
> > GDAL/OGR 1.3.1. Everything works if the tables in Oracle are owned
> > by the given user.
> > v.in.ogr reports the available layers as follows:
> > v.in.ogr -l dsn="OCI:owneroftables/pw@OCI" layer=DATA1 out=data1
> > Data source contains 2 layers:
> > DATA1, DATA2
> >
> > Removing the -l-switch imports the data nicly and creates dataset
> > data1 inside GRASS.
> >
> > When I create another oracle-user with only
> > SELECT-privileges on that table, the tables inside Oracle are
> > shown like this:
> >
> > v.in.ogr -l dsn="OCI:readonlyuser/pw@OCI"
> > layer=OWNEROFTABLES.DATA1 out=data1
> > Data source contains 2 layers:
> > OWNEROFTABLES.DATA1, OWNEROFTABLES.DATA2
> >
> > Trying to import now, this results in a Segmentation fault.
> > v.in.ogr dsn="OCI:readonlyuser/pw@OCI" layer=OWNEROFTABLES.DATA1
> > out=data1
> >
> > So I assume the dot between user and table produces this?! Perhaps
> > anybody can give me a hint where to look at.
> >
> > Using ogr2ogr works with both users and exports e.g. a shapefile
> > correct.
> >
> > Thanks in advance for any pointers.
>
> Apparently noone has stumbled over this I will provide as much
> information for the developers.
> I have created a full gdb backtrace[1] of the segfault. But again, I
> do not know where to dig into the problem since I do know what is
> going on there...
>
> Thank you for having a look what might go wrong here.

Learning to use DDD with Markus help got further information for me.
When I run v.in.ogr through ddd I have severel stacks which can be
investigated.

1.UP: key_value1.c:107
2.UP: key_value4.c:49
3.UP: convert.c:352
4.UP: /v.in.ogr/main.c:384

It currently segfaults in key_value1.c:107 (strcmp).
When I put the lines into comments, recompile and run v.in.ogr with
-o-flag, the dataset gets imported with warning, at least it gets
imported.

So now I know, that there must be something wrong with the
projection-stuff. It seems to me that Markus has investigated
something similar in the bugtracker[1] also dealing with
projection-stuff.

I have tried to find some hints in the CVS changelogs for key_value1.c
but I am not sure if they are relevant.

2006-01-04 12:40 markus G_malloc(); alloc() -> G_alloc(); calloc() ->
    G_calloc();realloc() -> G_realloc()

and

2006-02-09 04:08 glynn Use <grass/gis.h> etc rather than <gis.h>

Probably this problem is also relevant with the following changes:

2006-02-12 22:41 cho v.in.ogr segmentation fault fixed
          argument type fixed: OGRSpatialReferenceH * =>
          OGRSpatialReferenceH OGRSpatialReferenceH is
already a pointer to void.

2006-02-09 17:58 cho vector/v.in.ogr/main.c: bug fixed: wrong
argument type passed

Does anybody know if this changes require any CVS-versions of GDAL/OGR
or PROJ.4?

?!

Thanks for any comments on this.

OK, further updates. I have started over with a fresh checkout of
GRASS today, and noticed, that the nasty segfault-bug in v.in.ogr is
still there.

What I am curious is, that a fix from Cho[1] from 2006-02-09 is not in
CVS. I can see the commit-mail, where it gets included[1], but when
I do cvs diff to look where it gets lost again, I cannot find the
revision...

When I add this manuall, recompile the module, v.in.ogr
does not segfault anymore, but does not determine the correct projection
information of the dataset in any case...

I have stripped down a spearfish-example where you can reproduce this.

1. Applying the patch from attachment (and recompile v.in.ogr)
2. start grass in spearfish-location
3. export soils dataset to shape
   v.out.ogr in=soils type=area dsn=/tmp/ olayer=soils
4. show projection of shape
   ogrinfo -ro -al -summary /tmp/soils.shp
Layer name: soils
Geometry: Polygon
Feature Count: 737
Extent: (589443.780000, 4913923.480000) - (609546.170000,
4928105.880000)
Layer SRS WKT:
PROJCS["UTM Zone 13, Northern Hemisphere",
    GEOGCS["clark66",
        DATUM["North_American_Datum_1927",
            SPHEROID["clark66",6378206.4,294.9786982]],
        PRIMEM["Greenwich",0],
        UNIT["degree",0.0174532925199433]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",0],
    PARAMETER["central_meridian",-105],
    PARAMETER["scale_factor",0.9996],
    PARAMETER["false_easting",500000],
    PARAMETER["false_northing",0],
    UNIT["meter",1]]
cat: Real (11.0)
label: String (80.0)

seems OK so far.

5. try to reimport from shape
   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.

Can anybody reproduce this?

if I do not apply this patch, the shapefile gets imported, but I can
import any projected data, every data gets accepted and it seems that
the -o switch is given.

I think, there is something is wrong inside the
projection/datum-recognition.

Thank you for looking into this.

cheers

  Stephan

[1] http://grass.itc.it/pipermail/grass-commit/2006-February/020656.html

--
GDF Hannover - Solutions for spatial data analysis and remote sensing
Hannover Office - Mengendamm 16d - D-30177 Hannover
Internet: www.gdf-hannover.de - Email: holl@gdf-hannover.de
Phone : ++49-(0)511.39088507 - Fax: ++49-(0)511.39088508

Hi,

I'm unable to reproduce your error using GRASS 61. cvs updated today,
nor a segfault. Does it help you? Trace follows:

GRASS 6.1.cvs (spearfish60):~ > 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):~ > v.in.ogr dsn=/tmp/soils.shp out=test1
A datum name nad27 (North_American_Datum_1927) was specified without
transformation parameters.
WARNING: Non-interactive mode: the GRASS default for nad27 is
         towgs84=-22.000,157.000,176.000.
Projection of input dataset and current location appear to match.
Proceeding with import...
Layer: soils
WARNING: Column name changed: 'cat' -> 'cat_'
Importing map 737 features...
-----------------------------------------------------
Building topology ...
778 primitives registered
Building areas: 100%
534 areas built
529 isles built
Attaching islands: 100%
Attaching centroids: 100%
Topology was built.
Number of nodes : 652
Number of primitives: 778
Number of points : 0
Number of lines : 0
Number of boundaries: 778
Number of centroids : 0
Number of areas : 534
Number of isles : 529
Number of incorrect boundaries : 247
Number of areas without centroid : 534
-----------------------------------------------------
WARNING: Cleaning polygons, result is not guaranteed!
Building topology ...
Topology was built.
Number of nodes : 652
Number of primitives: 778
Number of points : 0
Number of lines : 0
Number of boundaries: 778
Number of centroids : 0
Number of areas : -
Number of isles : -
-----------------------------------------------------
Break polygons:
Registering points ... 34778
All points (vertices): 71509
Registered points (unique coordinates): 34778
Points marked for break: 1418
Breaks: 4008
-----------------------------------------------------
Remove duplicates:
Duplicates: 1965
-----------------------------------------------------
Break boundaries:
Intersections: 0
-----------------------------------------------------
Remove duplicates:
Duplicates: 0
-----------------------------------------------------
Clean boundaries at nodes:
Modifications: 0
-----------------------------------------------------
Change dangles to lines:
Removed dangles: 0 removed lines: 0
-----------------------------------------------------
Remove bridges:
Removed bridges: 0 removed lines: 0
-----------------------------------------------------
Building topology ...
Building areas: 100%
737 areas built
42 isles built
Attaching islands: 100%
Topology was built.
Number of nodes : 1418
Number of primitives: 4786
Number of points : 0
Number of lines : 0
Number of boundaries: 4786
Number of centroids : 0
Number of areas : 737
Number of isles : 42
Number of areas without centroid : 737
Layer: soils
-----------------------------------------------------
-----------------------------------------------------
Building topology ...
2850 primitives registered
Building areas: 100%
737 areas built
42 isles built
Attaching islands: 100%
Attaching centroids: 100%
Topology was built.
Number of nodes : 2155
Number of primitives: 2850
Number of points : 0
Number of lines : 0
Number of boundaries: 2113
Number of centroids : 737
Number of areas : 737
Number of isles : 42
-----------------------------------------------------
737 input polygons
total area: 2.762475e+08 (737 areas)
overlapping area: 0.000000e+00 (0 areas)
area without category: 0.000000e+00 (0 areas)

M.

2006/3/23, Stephan Holl <holl@gdf-hannover.de>:

Hello Stephan,

On Wed, 22 Mar 2006 11:10:58 +0100 Stephan Holl <holl@gdf-hannover.de>
wrote:

> Hello Stephan,
>
> [replying to myself again]
>
> On Wed, 15 Mar 2006 09:37:26 +0100 Stephan Holl <holl@gdf-hannover.de>
> wrote:
>
> > Hello Lists,
> >
> > [crosspost again]
> >
> > On Mon, 13 Mar 2006 12:09:15 +0100 Stephan Holl
> > <holl@gdf-hannover.de> wrote:
> >
> > > Dear list,
> > >
> > > [sorry for crossposting, but perhaps this is interesting for the
> > > GDAL-folks as well]
> > >
> > > I am working with GRASS6_CVS and Oracle 9i which is compiled into
> > > GDAL/OGR 1.3.1. Everything works if the tables in Oracle are owned
> > > by the given user.
> > > v.in.ogr reports the available layers as follows:
> > > v.in.ogr -l dsn="OCI:owneroftables/pw@OCI" layer=DATA1 out=data1
> > > Data source contains 2 layers:
> > > DATA1, DATA2
> > >
> > > Removing the -l-switch imports the data nicly and creates dataset
> > > data1 inside GRASS.
> > >
> > > When I create another oracle-user with only
> > > SELECT-privileges on that table, the tables inside Oracle are
> > > shown like this:
> > >
> > > v.in.ogr -l dsn="OCI:readonlyuser/pw@OCI"
> > > layer=OWNEROFTABLES.DATA1 out=data1
> > > Data source contains 2 layers:
> > > OWNEROFTABLES.DATA1, OWNEROFTABLES.DATA2
> > >
> > > Trying to import now, this results in a Segmentation fault.
> > > v.in.ogr dsn="OCI:readonlyuser/pw@OCI" layer=OWNEROFTABLES.DATA1
> > > out=data1
> > >
> > > So I assume the dot between user and table produces this?! Perhaps
> > > anybody can give me a hint where to look at.
> > >
> > > Using ogr2ogr works with both users and exports e.g. a shapefile
> > > correct.
> > >
> > > Thanks in advance for any pointers.
> >
> > Apparently noone has stumbled over this I will provide as much
> > information for the developers.
> > I have created a full gdb backtrace[1] of the segfault. But again, I
> > do not know where to dig into the problem since I do know what is
> > going on there...
> >
> > Thank you for having a look what might go wrong here.
>
> Learning to use DDD with Markus help got further information for me.
> When I run v.in.ogr through ddd I have severel stacks which can be
> investigated.
>
> 1.UP: key_value1.c:107
> 2.UP: key_value4.c:49
> 3.UP: convert.c:352
> 4.UP: /v.in.ogr/main.c:384
>
> It currently segfaults in key_value1.c:107 (strcmp).
> When I put the lines into comments, recompile and run v.in.ogr with
> -o-flag, the dataset gets imported with warning, at least it gets
> imported.
>
> So now I know, that there must be something wrong with the
> projection-stuff. It seems to me that Markus has investigated
> something similar in the bugtracker[1] also dealing with
> projection-stuff.
>
> I have tried to find some hints in the CVS changelogs for key_value1.c
> but I am not sure if they are relevant.
>
> 2006-01-04 12:40 markus G_malloc(); alloc() -> G_alloc(); calloc() ->
> G_calloc();realloc() -> G_realloc()
>
> and
>
> 2006-02-09 04:08 glynn Use <grass/gis.h> etc rather than <gis.h>
>
>
> Probably this problem is also relevant with the following changes:
>
> 2006-02-12 22:41 cho v.in.ogr segmentation fault fixed
> argument type fixed: OGRSpatialReferenceH * =>
> OGRSpatialReferenceH OGRSpatialReferenceH is
> already a pointer to void.
>
> 2006-02-09 17:58 cho vector/v.in.ogr/main.c: bug fixed: wrong
> argument type passed
>
> Does anybody know if this changes require any CVS-versions of GDAL/OGR
> or PROJ.4?
>
> ?!
>
> Thanks for any comments on this.

OK, further updates. I have started over with a fresh checkout of
GRASS today, and noticed, that the nasty segfault-bug in v.in.ogr is
still there.

What I am curious is, that a fix from Cho[1] from 2006-02-09 is not in
CVS. I can see the commit-mail, where it gets included[1], but when
I do cvs diff to look where it gets lost again, I cannot find the
revision...

When I add this manuall, recompile the module, v.in.ogr
does not segfault anymore, but does not determine the correct projection
information of the dataset in any case...

I have stripped down a spearfish-example where you can reproduce this.

1. Applying the patch from attachment (and recompile v.in.ogr)
2. start grass in spearfish-location
3. export soils dataset to shape
   v.out.ogr in=soils type=area dsn=/tmp/ olayer=soils
4. show projection of shape
   ogrinfo -ro -al -summary /tmp/soils.shp
Layer name: soils
Geometry: Polygon
Feature Count: 737
Extent: (589443.780000, 4913923.480000) - (609546.170000,
4928105.880000)
Layer SRS WKT:
PROJCS["UTM Zone 13, Northern Hemisphere",
    GEOGCS["clark66",
        DATUM["North_American_Datum_1927",
            SPHEROID["clark66",6378206.4,294.9786982]],
        PRIMEM["Greenwich",0],
        UNIT["degree",0.0174532925199433]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",0],
    PARAMETER["central_meridian",-105],
    PARAMETER["scale_factor",0.9996],
    PARAMETER["false_easting",500000],
    PARAMETER["false_northing",0],
    UNIT["meter",1]]
cat: Real (11.0)
label: String (80.0)

seems OK so far.

5. try to reimport from shape
   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.

Can anybody reproduce this?

if I do not apply this patch, the shapefile gets imported, but I can
import any projected data, every data gets accepted and it seems that
the -o switch is given.

I think, there is something is wrong inside the
projection/datum-recognition.

Thank you for looking into this.

cheers

        Stephan

[1] http://grass.itc.it/pipermail/grass-commit/2006-February/020656.html

--
GDF Hannover - Solutions for spatial data analysis and remote sensing
Hannover Office - Mengendamm 16d - D-30177 Hannover
Internet: www.gdf-hannover.de - Email: holl@gdf-hannover.de
Phone : ++49-(0)511.39088507 - Fax: ++49-(0)511.39088508

_______________________________________________
grass5 mailing list
grass5@grass.itc.it
http://grass.itc.it/mailman/listinfo/grass5

--
-- marcos boullón magán
-- universidade de Santiago de Compostela

Hello marcos,

On Thu, 23 Mar 2006 12:31:43 +0100 "marcos boullón magán"
<marcosboullon@gmail.com> wrote:

Hi,

I'm unable to reproduce your error using GRASS 61. cvs updated today,
nor a segfault. Does it help you? Trace follows:

OK, thanks for your report.
I just realized that I have forgotten to attach the small patch.

Could you try with the patch again (which should be in CVS already when
I look at the changelogs).

Thanks for testing.

  Stephan

GRASS 6.1.cvs (spearfish60):~ > 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):~ > v.in.ogr dsn=/tmp/soils.shp out=test1
A datum name nad27 (North_American_Datum_1927) was specified without
transformation parameters.
WARNING: Non-interactive mode: the GRASS default for nad27 is
         towgs84=-22.000,157.000,176.000.
Projection of input dataset and current location appear to match.
Proceeding with import...
Layer: soils
WARNING: Column name changed: 'cat' -> 'cat_'
Importing map 737 features...
-----------------------------------------------------
Building topology ...
778 primitives registered
Building areas: 100%
534 areas built
529 isles built
Attaching islands: 100%
Attaching centroids: 100%
Topology was built.
Number of nodes : 652
Number of primitives: 778
Number of points : 0
Number of lines : 0
Number of boundaries: 778
Number of centroids : 0
Number of areas : 534
Number of isles : 529
Number of incorrect boundaries : 247
Number of areas without centroid : 534
-----------------------------------------------------
WARNING: Cleaning polygons, result is not guaranteed!
Building topology ...
Topology was built.
Number of nodes : 652
Number of primitives: 778
Number of points : 0
Number of lines : 0
Number of boundaries: 778
Number of centroids : 0
Number of areas : -
Number of isles : -
-----------------------------------------------------
Break polygons:
Registering points ... 34778
All points (vertices): 71509
Registered points (unique coordinates): 34778
Points marked for break: 1418
Breaks: 4008
-----------------------------------------------------
Remove duplicates:
Duplicates: 1965
-----------------------------------------------------
Break boundaries:
Intersections: 0
-----------------------------------------------------
Remove duplicates:
Duplicates: 0
-----------------------------------------------------
Clean boundaries at nodes:
Modifications: 0
-----------------------------------------------------
Change dangles to lines:
Removed dangles: 0 removed lines: 0
-----------------------------------------------------
Remove bridges:
Removed bridges: 0 removed lines: 0
-----------------------------------------------------
Building topology ...
Building areas: 100%
737 areas built
42 isles built
Attaching islands: 100%
Topology was built.
Number of nodes : 1418
Number of primitives: 4786
Number of points : 0
Number of lines : 0
Number of boundaries: 4786
Number of centroids : 0
Number of areas : 737
Number of isles : 42
Number of areas without centroid : 737
Layer: soils
-----------------------------------------------------
-----------------------------------------------------
Building topology ...
2850 primitives registered
Building areas: 100%
737 areas built
42 isles built
Attaching islands: 100%
Attaching centroids: 100%
Topology was built.
Number of nodes : 2155
Number of primitives: 2850
Number of points : 0
Number of lines : 0
Number of boundaries: 2113
Number of centroids : 737
Number of areas : 737
Number of isles : 42
-----------------------------------------------------
737 input polygons
total area: 2.762475e+08 (737 areas)
overlapping area: 0.000000e+00 (0 areas)
area without category: 0.000000e+00 (0 areas)

M.

2006/3/23, Stephan Holl <holl@gdf-hannover.de>:
> Hello Stephan,
>
> On Wed, 22 Mar 2006 11:10:58 +0100 Stephan Holl
> <holl@gdf-hannover.de> wrote:
>
> > Hello Stephan,
> >
> > [replying to myself again]
> >
> > On Wed, 15 Mar 2006 09:37:26 +0100 Stephan Holl
> > <holl@gdf-hannover.de> wrote:
> >
> > > Hello Lists,
> > >
> > > [crosspost again]
> > >
> > > On Mon, 13 Mar 2006 12:09:15 +0100 Stephan Holl
> > > <holl@gdf-hannover.de> wrote:
> > >
> > > > Dear list,
> > > >
> > > > [sorry for crossposting, but perhaps this is interesting for
> > > > the GDAL-folks as well]
> > > >
> > > > I am working with GRASS6_CVS and Oracle 9i which is compiled
> > > > into GDAL/OGR 1.3.1. Everything works if the tables in Oracle
> > > > are owned by the given user.
> > > > v.in.ogr reports the available layers as follows:
> > > > v.in.ogr -l dsn="OCI:owneroftables/pw@OCI" layer=DATA1
> > > > out=data1 Data source contains 2 layers:
> > > > DATA1, DATA2
> > > >
> > > > Removing the -l-switch imports the data nicly and creates
> > > > dataset data1 inside GRASS.
> > > >
> > > > When I create another oracle-user with only
> > > > SELECT-privileges on that table, the tables inside Oracle are
> > > > shown like this:
> > > >
> > > > v.in.ogr -l dsn="OCI:readonlyuser/pw@OCI"
> > > > layer=OWNEROFTABLES.DATA1 out=data1
> > > > Data source contains 2 layers:
> > > > OWNEROFTABLES.DATA1, OWNEROFTABLES.DATA2
> > > >
> > > > Trying to import now, this results in a Segmentation fault.
> > > > v.in.ogr dsn="OCI:readonlyuser/pw@OCI"
> > > > layer=OWNEROFTABLES.DATA1 out=data1
> > > >
> > > > So I assume the dot between user and table produces this?!
> > > > Perhaps anybody can give me a hint where to look at.
> > > >
> > > > Using ogr2ogr works with both users and exports e.g. a
> > > > shapefile correct.
> > > >
> > > > Thanks in advance for any pointers.
> > >
> > > Apparently noone has stumbled over this I will provide as much
> > > information for the developers.
> > > I have created a full gdb backtrace[1] of the segfault. But
> > > again, I do not know where to dig into the problem since I do
> > > know what is going on there...
> > >
> > > Thank you for having a look what might go wrong here.
> >
> > Learning to use DDD with Markus help got further information for
> > me. When I run v.in.ogr through ddd I have severel stacks which
> > can be investigated.
> >
> > 1.UP: key_value1.c:107
> > 2.UP: key_value4.c:49
> > 3.UP: convert.c:352
> > 4.UP: /v.in.ogr/main.c:384
> >
> > It currently segfaults in key_value1.c:107 (strcmp).
> > When I put the lines into comments, recompile and run v.in.ogr
> > with -o-flag, the dataset gets imported with warning, at least it
> > gets imported.
> >
> > So now I know, that there must be something wrong with the
> > projection-stuff. It seems to me that Markus has investigated
> > something similar in the bugtracker[1] also dealing with
> > projection-stuff.
> >
> > I have tried to find some hints in the CVS changelogs for
> > key_value1.c but I am not sure if they are relevant.
> >
> > 2006-01-04 12:40 markus G_malloc(); alloc() -> G_alloc();
> > calloc() -> G_calloc();realloc() -> G_realloc()
> >
> > and
> >
> > 2006-02-09 04:08 glynn Use <grass/gis.h> etc rather than <gis.h>
> >
> >
> > Probably this problem is also relevant with the following changes:
> >
> > 2006-02-12 22:41 cho v.in.ogr segmentation fault fixed
> > argument type fixed: OGRSpatialReferenceH * =>
> > OGRSpatialReferenceH OGRSpatialReferenceH is
> > already a pointer to void.
> >
> > 2006-02-09 17:58 cho vector/v.in.ogr/main.c: bug fixed: wrong
> > argument type passed
> >
> > Does anybody know if this changes require any CVS-versions of
> > GDAL/OGR or PROJ.4?
> >
> > ?!
> >
> > Thanks for any comments on this.
>
> OK, further updates. I have started over with a fresh checkout of
> GRASS today, and noticed, that the nasty segfault-bug in v.in.ogr is
> still there.
>
> What I am curious is, that a fix from Cho[1] from 2006-02-09 is
> not in CVS. I can see the commit-mail, where it gets included[1],
> but when I do cvs diff to look where it gets lost again, I cannot
> find the revision...
>
> When I add this manuall, recompile the module, v.in.ogr
> does not segfault anymore, but does not determine the correct
> projection information of the dataset in any case...
>
> I have stripped down a spearfish-example where you can reproduce
> this.
>
> 1. Applying the patch from attachment (and recompile v.in.ogr)
> 2. start grass in spearfish-location
> 3. export soils dataset to shape
> v.out.ogr in=soils type=area dsn=/tmp/ olayer=soils
> 4. show projection of shape
> ogrinfo -ro -al -summary /tmp/soils.shp
> Layer name: soils
> Geometry: Polygon
> Feature Count: 737
> Extent: (589443.780000, 4913923.480000) - (609546.170000,
> 4928105.880000)
> Layer SRS WKT:
> PROJCS["UTM Zone 13, Northern Hemisphere",
> GEOGCS["clark66",
> DATUM["North_American_Datum_1927",
> SPHEROID["clark66",6378206.4,294.9786982]],
> PRIMEM["Greenwich",0],
> UNIT["degree",0.0174532925199433]],
> PROJECTION["Transverse_Mercator"],
> PARAMETER["latitude_of_origin",0],
> PARAMETER["central_meridian",-105],
> PARAMETER["scale_factor",0.9996],
> PARAMETER["false_easting",500000],
> PARAMETER["false_northing",0],
> UNIT["meter",1]]
> cat: Real (11.0)
> label: String (80.0)
>
> seems OK so far.
>
> 5. try to reimport from shape
> 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.
>
> Can anybody reproduce this?
>
> if I do not apply this patch, the shapefile gets imported, but I can
> import any projected data, every data gets accepted and it seems
> that the -o switch is given.
>
>
> I think, there is something is wrong inside the
> projection/datum-recognition.
>
> Thank you for looking into this.
>
> cheers
>
> Stephan
>
>
> [1]
> http://grass.itc.it/pipermail/grass-commit/2006-February/020656.html
>
>
> --
> GDF Hannover - Solutions for spatial data analysis and remote
> sensing Hannover Office - Mengendamm 16d -
> D-30177 Hannover Internet: www.gdf-hannover.de - Email:
> holl@gdf-hannover.de Phone : ++49-(0)511.39088507 -
> Fax: ++49-(0)511.39088508
>
> _______________________________________________
> grass5 mailing list
> grass5@grass.itc.it
> http://grass.itc.it/mailman/listinfo/grass5
>

--
-- marcos boullón magán
-- universidade de Santiago de Compostela

--
GDF Hannover - Solutions for spatial data analysis and remote sensing
Hannover Office - Mengendamm 16d - D-30177 Hannover
Internet: www.gdf-hannover.de - Email: holl@gdf-hannover.de
Phone : ++49-(0)511.39088507 - Fax: ++49-(0)511.39088508

(attachments)

cho.patch (1.05 KB)

Hello Stephan,

After applying the patch, the output is:

marcos@venux:~/cvsgrass$ cd grass6/vector/v.in.ogr/
marcos@venux:~/cvsgrass/grass6/vector/v.in.ogr$ patch < ~/cho.patch
marcos@venux:~/cvsgrass/grass6/vector/v.in.ogr$ make
marcos@venux:~/cvsgrass/grass6/vector/v.in.ogr$ cd ../..
marcos@venux:~/cvsgrass/grass6/vector/v.in.ogr$ su
venux:/home/marcos/cvsgrass/grass6/vector/v.in.ogr# make install
marcos@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.

M.

2006/3/23, Stephan Holl <holl@gdf-hannover.de>:

Hello marcos,

On Thu, 23 Mar 2006 12:31:43 +0100 "marcos boullón magán"
<marcosboullon@gmail.com> wrote:

> Hi,
>
> I'm unable to reproduce your error using GRASS 61. cvs updated today,
> nor a segfault. Does it help you? Trace follows:

OK, thanks for your report.
I just realized that I have forgotten to attach the small patch.

Could you try with the patch again (which should be in CVS already when
I look at the changelogs).

Thanks for testing.

        Stephan

>
> GRASS 6.1.cvs (spearfish60):~ > 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):~ > v.in.ogr dsn=/tmp/soils.shp out=test1
> A datum name nad27 (North_American_Datum_1927) was specified without
> transformation parameters.
> WARNING: Non-interactive mode: the GRASS default for nad27 is
> towgs84=-22.000,157.000,176.000.
> Projection of input dataset and current location appear to match.
> Proceeding with import...
> Layer: soils
> WARNING: Column name changed: 'cat' -> 'cat_'
> Importing map 737 features...
> -----------------------------------------------------
> Building topology ...
> 778 primitives registered
> Building areas: 100%
> 534 areas built
> 529 isles built
> Attaching islands: 100%
> Attaching centroids: 100%
> Topology was built.
> Number of nodes : 652
> Number of primitives: 778
> Number of points : 0
> Number of lines : 0
> Number of boundaries: 778
> Number of centroids : 0
> Number of areas : 534
> Number of isles : 529
> Number of incorrect boundaries : 247
> Number of areas without centroid : 534
> -----------------------------------------------------
> WARNING: Cleaning polygons, result is not guaranteed!
> Building topology ...
> Topology was built.
> Number of nodes : 652
> Number of primitives: 778
> Number of points : 0
> Number of lines : 0
> Number of boundaries: 778
> Number of centroids : 0
> Number of areas : -
> Number of isles : -
> -----------------------------------------------------
> Break polygons:
> Registering points ... 34778
> All points (vertices): 71509
> Registered points (unique coordinates): 34778
> Points marked for break: 1418
> Breaks: 4008
> -----------------------------------------------------
> Remove duplicates:
> Duplicates: 1965
> -----------------------------------------------------
> Break boundaries:
> Intersections: 0
> -----------------------------------------------------
> Remove duplicates:
> Duplicates: 0
> -----------------------------------------------------
> Clean boundaries at nodes:
> Modifications: 0
> -----------------------------------------------------
> Change dangles to lines:
> Removed dangles: 0 removed lines: 0
> -----------------------------------------------------
> Remove bridges:
> Removed bridges: 0 removed lines: 0
> -----------------------------------------------------
> Building topology ...
> Building areas: 100%
> 737 areas built
> 42 isles built
> Attaching islands: 100%
> Topology was built.
> Number of nodes : 1418
> Number of primitives: 4786
> Number of points : 0
> Number of lines : 0
> Number of boundaries: 4786
> Number of centroids : 0
> Number of areas : 737
> Number of isles : 42
> Number of areas without centroid : 737
> Layer: soils
> -----------------------------------------------------
> -----------------------------------------------------
> Building topology ...
> 2850 primitives registered
> Building areas: 100%
> 737 areas built
> 42 isles built
> Attaching islands: 100%
> Attaching centroids: 100%
> Topology was built.
> Number of nodes : 2155
> Number of primitives: 2850
> Number of points : 0
> Number of lines : 0
> Number of boundaries: 2113
> Number of centroids : 737
> Number of areas : 737
> Number of isles : 42
> -----------------------------------------------------
> 737 input polygons
> total area: 2.762475e+08 (737 areas)
> overlapping area: 0.000000e+00 (0 areas)
> area without category: 0.000000e+00 (0 areas)
>
> M.
>
> 2006/3/23, Stephan Holl <holl@gdf-hannover.de>:
> > Hello Stephan,
> >
> > On Wed, 22 Mar 2006 11:10:58 +0100 Stephan Holl
> > <holl@gdf-hannover.de> wrote:
> >
> > > Hello Stephan,
> > >
> > > [replying to myself again]
> > >
> > > On Wed, 15 Mar 2006 09:37:26 +0100 Stephan Holl
> > > <holl@gdf-hannover.de> wrote:
> > >
> > > > Hello Lists,
> > > >
> > > > [crosspost again]
> > > >
> > > > On Mon, 13 Mar 2006 12:09:15 +0100 Stephan Holl
> > > > <holl@gdf-hannover.de> wrote:
> > > >
> > > > > Dear list,
> > > > >
> > > > > [sorry for crossposting, but perhaps this is interesting for
> > > > > the GDAL-folks as well]
> > > > >
> > > > > I am working with GRASS6_CVS and Oracle 9i which is compiled
> > > > > into GDAL/OGR 1.3.1. Everything works if the tables in Oracle
> > > > > are owned by the given user.
> > > > > v.in.ogr reports the available layers as follows:
> > > > > v.in.ogr -l dsn="OCI:owneroftables/pw@OCI" layer=DATA1
> > > > > out=data1 Data source contains 2 layers:
> > > > > DATA1, DATA2
> > > > >
> > > > > Removing the -l-switch imports the data nicly and creates
> > > > > dataset data1 inside GRASS.
> > > > >
> > > > > When I create another oracle-user with only
> > > > > SELECT-privileges on that table, the tables inside Oracle are
> > > > > shown like this:
> > > > >
> > > > > v.in.ogr -l dsn="OCI:readonlyuser/pw@OCI"
> > > > > layer=OWNEROFTABLES.DATA1 out=data1
> > > > > Data source contains 2 layers:
> > > > > OWNEROFTABLES.DATA1, OWNEROFTABLES.DATA2
> > > > >
> > > > > Trying to import now, this results in a Segmentation fault.
> > > > > v.in.ogr dsn="OCI:readonlyuser/pw@OCI"
> > > > > layer=OWNEROFTABLES.DATA1 out=data1
> > > > >
> > > > > So I assume the dot between user and table produces this?!
> > > > > Perhaps anybody can give me a hint where to look at.
> > > > >
> > > > > Using ogr2ogr works with both users and exports e.g. a
> > > > > shapefile correct.
> > > > >
> > > > > Thanks in advance for any pointers.
> > > >
> > > > Apparently noone has stumbled over this I will provide as much
> > > > information for the developers.
> > > > I have created a full gdb backtrace[1] of the segfault. But
> > > > again, I do not know where to dig into the problem since I do
> > > > know what is going on there...
> > > >
> > > > Thank you for having a look what might go wrong here.
> > >
> > > Learning to use DDD with Markus help got further information for
> > > me. When I run v.in.ogr through ddd I have severel stacks which
> > > can be investigated.
> > >
> > > 1.UP: key_value1.c:107
> > > 2.UP: key_value4.c:49
> > > 3.UP: convert.c:352
> > > 4.UP: /v.in.ogr/main.c:384
> > >
> > > It currently segfaults in key_value1.c:107 (strcmp).
> > > When I put the lines into comments, recompile and run v.in.ogr
> > > with -o-flag, the dataset gets imported with warning, at least it
> > > gets imported.
> > >
> > > So now I know, that there must be something wrong with the
> > > projection-stuff. It seems to me that Markus has investigated
> > > something similar in the bugtracker[1] also dealing with
> > > projection-stuff.
> > >
> > > I have tried to find some hints in the CVS changelogs for
> > > key_value1.c but I am not sure if they are relevant.
> > >
> > > 2006-01-04 12:40 markus G_malloc(); alloc() -> G_alloc();
> > > calloc() -> G_calloc();realloc() -> G_realloc()
> > >
> > > and
> > >
> > > 2006-02-09 04:08 glynn Use <grass/gis.h> etc rather than <gis.h>
> > >
> > >
> > > Probably this problem is also relevant with the following changes:
> > >
> > > 2006-02-12 22:41 cho v.in.ogr segmentation fault fixed
> > > argument type fixed: OGRSpatialReferenceH * =>
> > > OGRSpatialReferenceH OGRSpatialReferenceH is
> > > already a pointer to void.
> > >
> > > 2006-02-09 17:58 cho vector/v.in.ogr/main.c: bug fixed: wrong
> > > argument type passed
> > >
> > > Does anybody know if this changes require any CVS-versions of
> > > GDAL/OGR or PROJ.4?
> > >
> > > ?!
> > >
> > > Thanks for any comments on this.
> >
> > OK, further updates. I have started over with a fresh checkout of
> > GRASS today, and noticed, that the nasty segfault-bug in v.in.ogr is
> > still there.
> >
> > What I am curious is, that a fix from Cho[1] from 2006-02-09 is
> > not in CVS. I can see the commit-mail, where it gets included[1],
> > but when I do cvs diff to look where it gets lost again, I cannot
> > find the revision...
> >
> > When I add this manuall, recompile the module, v.in.ogr
> > does not segfault anymore, but does not determine the correct
> > projection information of the dataset in any case...
> >
> > I have stripped down a spearfish-example where you can reproduce
> > this.
> >
> > 1. Applying the patch from attachment (and recompile v.in.ogr)
> > 2. start grass in spearfish-location
> > 3. export soils dataset to shape
> > v.out.ogr in=soils type=area dsn=/tmp/ olayer=soils
> > 4. show projection of shape
> > ogrinfo -ro -al -summary /tmp/soils.shp
> > Layer name: soils
> > Geometry: Polygon
> > Feature Count: 737
> > Extent: (589443.780000, 4913923.480000) - (609546.170000,
> > 4928105.880000)
> > Layer SRS WKT:
> > PROJCS["UTM Zone 13, Northern Hemisphere",
> > GEOGCS["clark66",
> > DATUM["North_American_Datum_1927",
> > SPHEROID["clark66",6378206.4,294.9786982]],
> > PRIMEM["Greenwich",0],
> > UNIT["degree",0.0174532925199433]],
> > PROJECTION["Transverse_Mercator"],
> > PARAMETER["latitude_of_origin",0],
> > PARAMETER["central_meridian",-105],
> > PARAMETER["scale_factor",0.9996],
> > PARAMETER["false_easting",500000],
> > PARAMETER["false_northing",0],
> > UNIT["meter",1]]
> > cat: Real (11.0)
> > label: String (80.0)
> >
> > seems OK so far.
> >
> > 5. try to reimport from shape
> > 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.
> >
> > Can anybody reproduce this?
> >
> > if I do not apply this patch, the shapefile gets imported, but I can
> > import any projected data, every data gets accepted and it seems
> > that the -o switch is given.
> >
> >
> > I think, there is something is wrong inside the
> > projection/datum-recognition.
> >
> > Thank you for looking into this.
> >
> > cheers
> >
> > Stephan
> >
> >
> > [1]
> > http://grass.itc.it/pipermail/grass-commit/2006-February/020656.html
> >
> >
> > --
> > GDF Hannover - Solutions for spatial data analysis and remote
> > sensing Hannover Office - Mengendamm 16d -
> > D-30177 Hannover Internet: www.gdf-hannover.de - Email:
> > holl@gdf-hannover.de Phone : ++49-(0)511.39088507 -
> > Fax: ++49-(0)511.39088508
> >
> > _______________________________________________
> > grass5 mailing list
> > grass5@grass.itc.it
> > http://grass.itc.it/mailman/listinfo/grass5
> >
>
>
> --
> -- marcos boullón magán
> -- universidade de Santiago de Compostela

--
GDF Hannover - Solutions for spatial data analysis and remote sensing
Hannover Office - Mengendamm 16d - D-30177 Hannover
Internet: www.gdf-hannover.de - Email: holl@gdf-hannover.de
Phone : ++49-(0)511.39088507 - Fax: ++49-(0)511.39088508

--
-- marcos boullón magán

Hi,

marcos@venux:~/cvsgrass$ cd grass6/vector/v.in.ogr/
marcos@venux:~/cvsgrass/grass6/vector/v.in.ogr$ patch < ~/cho.patch
marcos@venux:~/cvsgrass/grass6/vector/v.in.ogr$ make
marcos@venux:~/cvsgrass/grass6/vector/v.in.ogr$ cd ../..
marcos@venux:~/cvsgrass/grass6/vector/v.in.ogr$ su
venux:/home/marcos/cvsgrass/grass6/vector/v.in.ogr# make install
marcos@venux:~/cvsgrass/grass6/vector/v.in.ogr$ grass61

Oops. Transcription error! Steps were...

marcos@venux:~/cvsgrass$ cd grass6/vector/v.in.ogr/
marcos@venux:~/cvsgrass/grass6/vector/v.in.ogr$ patch < ~/cho.patch
marcos@venux:~/cvsgrass/grass6/vector/v.in.ogr$ make
marcos@venux:~/cvsgrass/grass6/vector/v.in.ogr$ cd ../..
marcos@venux:~/cvsgrass/grass6$ su
venux:/home/marcos/cvsgrass/grass6# make install
marcos@venux:~/cvsgrass/grass6$ grass61

So, don't worry: patch was applied, command recompiled and
successfully installed.

M.

--
-- marcos boullón magán

Hello marcos,

On Thu, 23 Mar 2006 13:01:54 +0100 "marcos boullón magán"
<marcosboullon@gmail.com> wrote:

Hello Stephan,

After applying the patch, the output is:

marcos@venux:~/cvsgrass$ cd grass6/vector/v.in.ogr/
marcos@venux:~/cvsgrass/grass6/vector/v.in.ogr$ patch < ~/cho.patch
marcos@venux:~/cvsgrass/grass6/vector/v.in.ogr$ make
marcos@venux:~/cvsgrass/grass6/vector/v.in.ogr$ cd ../..
marcos@venux:~/cvsgrass/grass6/vector/v.in.ogr$ su
venux:/home/marcos/cvsgrass/grass6/vector/v.in.ogr# make install
marcos@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@gdf-hannover.de
Phone : ++49-(0)511.39088507 - Fax: ++49-(0)511.39088508

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@gdf-hannover.de>:

Hello marcos,

On Thu, 23 Mar 2006 13:01:54 +0100 "marcos boullón magán"
<marcosboullon@gmail.com> wrote:

> Hello Stephan,
>
> After applying the patch, the output is:
>
> marcos@venux:~/cvsgrass$ cd grass6/vector/v.in.ogr/
> marcos@venux:~/cvsgrass/grass6/vector/v.in.ogr$ patch < ~/cho.patch
> marcos@venux:~/cvsgrass/grass6/vector/v.in.ogr$ make
> marcos@venux:~/cvsgrass/grass6/vector/v.in.ogr$ cd ../..
> marcos@venux:~/cvsgrass/grass6/vector/v.in.ogr$ su
> venux:/home/marcos/cvsgrass/grass6/vector/v.in.ogr# make install
> marcos@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@gdf-hannover.de
Phone : ++49-(0)511.39088507 - Fax: ++49-(0)511.39088508

--
-- marcos boullón magán

Hello again,

If you are still receiving a segfault with GRASS 6.1 cvs version in
file lib/gis/key_value1.c, line 107, as said in a previous email, you
can try the following patch (attached) to gather more information on
the error conditions (but don't apply the Chos's patch!).

The patch containts code to show the comparing strings process while
running in G_find_key_value() function. Patch and compile as
necessary, then in GRASS try v.out.ogr/v.in.ogr and compare your
results with the attached ones:

$ cd grass6/lib/gis
$ patch < key_vect1.patch
...
GRASS 6.1.cvs (spearfish60):~/cvsgrass/grass6 > v.out.ogr in=soils
type=area dsn=/tmp/ olayer=soils 2> v.out.ogr.stderr.txt
GRASS 6.1.cvs (spearfish60):~/cvsgrass/grass6 > md5sum /tmp/soils.shp
24a6c8a36089cfd661b417807546f8ba /tmp/soils.shp
GRASS 6.1.cvs (spearfish60):~/cvsgrass/grass6 > v.in.ogr
dsn=/tmp/soils.shp out=test1 2> v.in.ogr.stderr.txt

If not succesfully finished, v.in.ogr.stderr.txt containts the
"trace". Compare with mine and report.

Good luck,

M.

2006/3/23, marcos boullón magán <marcosboullon@gmail.com>:

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@gdf-hannover.de>:
> Hello marcos,
>
> On Thu, 23 Mar 2006 13:01:54 +0100 "marcos boullón magán"
> <marcosboullon@gmail.com> wrote:
>
> > Hello Stephan,
> >
> > After applying the patch, the output is:
> >
> > marcos@venux:~/cvsgrass$ cd grass6/vector/v.in.ogr/
> > marcos@venux:~/cvsgrass/grass6/vector/v.in.ogr$ patch < ~/cho.patch
> > marcos@venux:~/cvsgrass/grass6/vector/v.in.ogr$ make
> > marcos@venux:~/cvsgrass/grass6/vector/v.in.ogr$ cd ../..
> > marcos@venux:~/cvsgrass/grass6/vector/v.in.ogr$ su
> > venux:/home/marcos/cvsgrass/grass6/vector/v.in.ogr# make install
> > marcos@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@gdf-hannover.de
> Phone : ++49-(0)511.39088507 - Fax: ++49-(0)511.39088508
>

--
-- marcos boullón magán

--
-- marcos boullón magán

(attachments)

key_value1.zip (8.15 KB)

Hello marcos boullón magán,

On Thu, 23 Mar 2006 17:10:45 +0100 "marcos boullón magán"
<marcosboullon@gmail.com> wrote:

Hello again,

If you are still receiving a segfault with GRASS 6.1 cvs version in
file lib/gis/key_value1.c, line 107, as said in a previous email, you
can try the following patch (attached) to gather more information on
the error conditions (but don't apply the Chos's patch!).

Thank you very much for your clear and very helpful explanation of what
was going in chos patch.
As I am now C-expert, it is now possible to understand the differences
between the two decalarations.

The patch containts code to show the comparing strings process while
running in G_find_key_value() function. Patch and compile as
necessary, then in GRASS try v.out.ogr/v.in.ogr and compare your
results with the attached ones:

$ cd grass6/lib/gis
$ patch < key_vect1.patch
...
GRASS 6.1.cvs (spearfish60):~/cvsgrass/grass6 > v.out.ogr in=soils
type=area dsn=/tmp/ olayer=soils 2> v.out.ogr.stderr.txt
GRASS 6.1.cvs (spearfish60):~/cvsgrass/grass6 > md5sum /tmp/soils.shp
24a6c8a36089cfd661b417807546f8ba /tmp/soils.shp
GRASS 6.1.cvs (spearfish60):~/cvsgrass/grass6 > v.in.ogr
dsn=/tmp/soils.shp out=test1 2> v.in.ogr.stderr.txt

I have applied your patch and have the same behviour as yours with the
shapefile. The import works well.

BUT:
Using other datasources are getting more difficult.
I have a PostGIS-Point-dataset (EPSG:4326 -> latlon)

ogrinfo -al -summary "PG:dbname=postgis user=gdf" grass_users
INFO: Open of `PG:dbname=postgis user=gdf'
using driver `PostgreSQL' successful.

Layer name: grass_users
Geometry: Point
Feature Count: 32
Extent: (-155.605011, -77.280006) - (128.640015, 75.840004)
Layer SRS WKT:
GEOGCS["WGS 84",
    DATUM["WGS_1984",
        SPHEROID["WGS 84",6378137,298.257223563,
            AUTHORITY["EPSG","7030"]],
        AUTHORITY["EPSG","6326"]],
    PRIMEM["Greenwich",0,
        AUTHORITY["EPSG","8901"]],
    UNIT["degree",0.01745329251994328,
        AUTHORITY["EPSG","9122"]],
    AUTHORITY["EPSG","4326"]]
gid: Integer (0.0)
x: Integer (0.0)
y: Integer (0.0)
name: String (0.0)
company: String (0.0)

which imports just fine into spearfish60 ?! This is aparently wrong.
Please see the debugging output attached (v.in.ogr_pgis.dmp).
So apparently GRASS identifies the dataset as utm (which is not true
as shown above from ogrinfo).

I have found another strange behaviour when trying to access
oracle-spatial through v.in.ogr. ogrinfo reports the correct
projection-information, but v.in.ogr segfaults while trying to compare
(null) -> segfault. (see v.in.ogr_oracle.dmp)

ogrinfo -al -summary -ro "OCI:user/pw@oracle.galileo"
DATA.SPEAR_SOILS
using driver `OCI' successful.

Layer name: DATA.SPEAR_SOILS
Geometry: Unknown (any)
Feature Count: 737
Extent: (589443.780000, 4913923.480000) - (609546.170000,
4928105.880000) Layer SRS WKT:
PROJCS["UTM Zone 13, Northern Hemisphere",
    GEOGCS["clark66",
        DATUM["North_American_Datum_1927",
            SPHEROID["clark66",6378206.4,294.9786982]],
        PRIMEM["Greenwich",0],
        UNIT["Decimal Degree",0.0174532925199433]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",0],
    PARAMETER["central_meridian",-105],
    PARAMETER["scale_factor",0.9996],
    PARAMETER["false_easting",500000],
    PARAMETER["false_northing",0],
    UNIT["Meter",1]]
cat: Integer (11.0)
label: String (80.0)

At least for other datasources than shapefiles some
projection-quirks are there.

Your help is greatly appreciated.

Thank you very much.

  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@gdf-hannover.de
Phone : ++49-(0)511.39088507 - Fax: ++49-(0)511.39088508

(attachments)

v.in.ogr_oracle.dmp (98 Bytes)
v.in.ogr.pgis.dmp (2.64 KB)

2006/3/24, Stephan Holl <holl@gdf-hannover.de>:

Using other datasources are getting more difficult.
I have a PostGIS-Point-dataset (EPSG:4326 -> latlon)

ogrinfo -al -summary "PG:dbname=postgis user=gdf" grass_users
INFO: Open of `PG:dbname=postgis user=gdf'
using driver `PostgreSQL' successful.
[...]
which imports just fine into spearfish60 ?! This is aparently wrong.
Please see the debugging output attached (v.in.ogr_pgis.dmp).
So apparently GRASS identifies the dataset as utm (which is not true
as shown above from ogrinfo).

Sorry, but my skills in geoprocessing are rather low. I'm a recent
arrival to this field and get lost easily with projection, datum,
coord system... vocabulary. Maybe with an equivalent sample database I
could reproduce and trace back this error to the origin, maybe not.
Which SQL commands create point geometry datasets in EPSG:4326 latlon?

Anyway, as seen in dump, the importing driver finds the token "utm" in
the string returned by OSRExportToProj4() function call (file
lib/proj/convert.c, line 277), commented as "Get the coordinate system
definition in PROJ.4 format". Reference system appears as utm before
the conversion code. Did you double check you were importing the right
table? Sorry, no more ideas without all data.

I have found another strange behaviour when trying to access
oracle-spatial through v.in.ogr. ogrinfo reports the correct
projection-information, but v.in.ogr segfaults while trying to compare
(null) -> segfault. (see v.in.ogr_oracle.dmp)

Again, not enough data to say what's wrong with the import process:
apparently the key value in struct Key_Value is incorrect because null
value (file key_value1.c, line 107); going back to its last
assignement (incarnated as pszProj in file lib/proj/convert.c, line
675 I guess), it was... NULL: string pszProj is only different to NULL
when token "proj=something" is present in OSRExportToProj4() return
string.

Please add the following code to show what OSRExportToProj4() does (no
diff file because a single change). In file grass6/lib/convert.c, line
277 and 278, change

    if( OSRExportToProj4( hSRS, &pszProj4 ) != OGRERR_NONE )
        goto default_to_xy;

to

    if( OSRExportToProj4( hSRS, &pszProj4 ) != OGRERR_NONE )
        goto default_to_xy;
    fprintf(stderr, "OSRExportToProj4() returned \"%s\"\n", pszProj4);
    fflush(stderr);

and recompile. Maybe useful info arises.

Regards,

M.

--
-- marcos boullón magán

What I am curious is, that a fix from Cho[1] from 2006-02-09 is not in
CVS. I can see the commit-mail, where it gets included[1], but when
I do cvs diff to look where it gets lost again, I cannot find the
revision...

see rev 1.57, 1.58. Applied then reverted.

http://freegis.org/cgi-bin/viewcvs.cgi/grass6/vector/v.in.ogr/main.c

Hamish

Hello marcos,

On Fri, 24 Mar 2006 15:32:14 +0100 "marcos boullón magán"
<marcosboullon@gmail.com> wrote:

2006/3/24, Stephan Holl <holl@gdf-hannover.de>:
> Using other datasources are getting more difficult.
> I have a PostGIS-Point-dataset (EPSG:4326 -> latlon)
>
> ogrinfo -al -summary "PG:dbname=postgis user=gdf" grass_users
> INFO: Open of `PG:dbname=postgis user=gdf'
> using driver `PostgreSQL' successful.
> [...]
> which imports just fine into spearfish60 ?! This is aparently wrong.
> Please see the debugging output attached (v.in.ogr_pgis.dmp).
> So apparently GRASS identifies the dataset as utm (which is not true
> as shown above from ogrinfo).

Sorry, but my skills in geoprocessing are rather low. I'm a recent
arrival to this field and get lost easily with projection, datum,
coord system... vocabulary. Maybe with an equivalent sample database I
could reproduce and trace back this error to the origin, maybe not.

OK, I could provide another dataset for you as SQL-Dump, which is in
EPSG:4326 for postGIS.
I put it on my website for you to download[1] (4 MB), a world-dataset
grabbed from here[2]. You could import the data using
psql -U <youuser> -h <yourhost> postgisdatabase < cntr98.sql (You need
a postgis-enabled database of course).

Which SQL commands create point geometry datasets in EPSG:4326 latlon?

Anyway, as seen in dump, the importing driver finds the token "utm" in
the string returned by OSRExportToProj4() function call (file
lib/proj/convert.c, line 277), commented as "Get the coordinate system
definition in PROJ.4 format". Reference system appears as utm before
the conversion code. Did you double check you were importing the right
table? Sorry, no more ideas without all data.

Yes, strange. After your patch was applied I got this output:
v.in.ogr dsn="PG:dbname=postgis user=gdf" layer=cntry98 out=test14
comparing "meters"
to "unit"
to "units"
to "meters"
OSRExportToProj4() returned "+proj=utm +zone=13 +ellps=clrk66
+datum=NAD27 +units=m +no_defs "

According to the ogrinfo-output the projection should at least be
EPSG 4326 which is latlon

ogrinfo -al -summary "PG:dbname=postgis user=gdf" cntry98
Layer name: cntry98
Geometry: Multi Polygon
Feature Count: 251
Extent: (-180.000000, -90.000000) - (180.000000, 83.623596)
Layer SRS WKT:
GEOGCS["WGS 84",
    DATUM["WGS_1984",
        SPHEROID["WGS 84",6378137,298.257223563,
            AUTHORITY["EPSG","7030"]],
        AUTHORITY["EPSG","6326"]],
    PRIMEM["Greenwich",0,
        AUTHORITY["EPSG","8901"]],
    UNIT["degree",0.01745329251994328,
        AUTHORITY["EPSG","9122"]],
    AUTHORITY["EPSG","4326"]]
gid: Integer (0.0)
fips_cntry: String (0.0)
gmi_cntry: String (0.0)
iso_2digit: String (0.0)
iso_3digit: String (0.0)
cntry_name: String (0.0)
sovereign: String (0.0)
pop_cntry: Integer (0.0)
sqkm_cntry: Real (0.0)
sqmi_cntry: Real (0.0)
curr_type: String (0.0)
curr_code: String (0.0)
landlocked: String (0.0)
color_map: String (0.0)

Which is definetly the projection of the current location I am in, and
not the data-projection.
g.region -p
projection: 1 (UTM)
zone: 13
datum: nad27
ellipsoid: clark66
north: 5345694.68966235
south: 5324945.25464811
west: 4452539.52677299
east: 4479502.31502616
nsres: 29.89832135
ewres: 29.92540317
rows: 694
cols: 901

I do not understand what is going on in there, so I need to leave this
to you and others to find out. *?!*

> I have found another strange behaviour when trying to access
> oracle-spatial through v.in.ogr. ogrinfo reports the correct
> projection-information, but v.in.ogr segfaults while trying to
> compare (null) -> segfault. (see v.in.ogr_oracle.dmp)

Again, not enough data to say what's wrong with the import process:
apparently the key value in struct Key_Value is incorrect because null
value (file key_value1.c, line 107); going back to its last
assignement (incarnated as pszProj in file lib/proj/convert.c, line
675 I guess), it was... NULL: string pszProj is only different to NULL
when token "proj=something" is present in OSRExportToProj4() return
string.

I see, so my Oracle_dataset does not provide the correct proj-string
apparently, which is quite strange, because ogr2ogr shows everything is
correct... See my last mail for ogrinfo-output.

The segfault somes from here:

comparing "meters"
to "unit"
to "units"
to "meters"
OSRExportToProj4() returned "+ellps=bessel +units=m +no_defs "
comparing "(null)"
to "ll"
Segmentation fault

So comparing (null) to something results in a segfault...

Please add the following code to show what OSRExportToProj4() does (no
diff file because a single change). In file grass6/lib/convert.c, line
277 and 278, change

    if( OSRExportToProj4( hSRS, &pszProj4 ) != OGRERR_NONE )
        goto default_to_xy;

to

    if( OSRExportToProj4( hSRS, &pszProj4 ) != OGRERR_NONE )
        goto default_to_xy;
    fprintf(stderr, "OSRExportToProj4() returned \"%s\"\n", pszProj4);
    fflush(stderr);

and recompile. Maybe useful info arises.

Yes, definetly. Thank you.

Best
  Stephan

[1] http://www.gdf-hannover.de/holl/tmp/cntry98.sql.gz
[2] http://www.mappinghacks.com/data/cntry98.zip

--
GDF Hannover - Solutions for spatial data analysis and remote sensing
Hannover Office - Mengendamm 16d - D-30177 Hannover
Internet: www.gdf-hannover.de - Email: holl@gdf-hannover.de
Phone : ++49-(0)511.39088507 - Fax: ++49-(0)511.39088508

Hello Hamish,

On Sat, 25 Mar 2006 02:33:18 +1200 Hamish <hamish_nospam@yahoo.com>
wrote:

> What I am curious is, that a fix from Cho[1] from 2006-02-09 is
> not in CVS. I can see the commit-mail, where it gets included[1],
> but when I do cvs diff to look where it gets lost again, I cannot
> find the revision...

see rev 1.57, 1.58. Applied then reverted.

http://freegis.org/cgi-bin/viewcvs.cgi/grass6/vector/v.in.ogr/main.c

thanks

  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@gdf-hannover.de
Phone : ++49-(0)511.39088507 - Fax: ++49-(0)511.39088508

Hello Stephan,

Our outputs differ again!

Yes, strange. After your patch was applied I got this output:
v.in.ogr dsn="PG:dbname=postgis user=gdf" layer=cntry98 out=test14
comparing "meters"
to "unit"
to "units"
to "meters"
OSRExportToProj4() returned "+proj=utm +zone=13 +ellps=clrk66
+datum=NAD27 +units=m +no_defs "

According to the ogrinfo-output the projection should at least be
EPSG 4326 which is latlon

Very strange, because program flow shouldn't arrive to OSRExportToProj4()!!

I downloaded the db you provided, EPSG 4326 latlon, successfully
imported to postgis database, run v.in.ogr and the command
consistently warned about a different projection:

In postgresql+postgis server (see the 4326 SRID?):

geoprueba=# select * from geometry_columns where f_table_name='cntry98';
f_table_catalog | f_table_schema | f_table_name | f_geometry_column |
coord_dimension | srid | type | attrelid | varattnum | stats
-----------------+----------------+--------------+-------------------+-----------------+------+--------------+----------+-----------+-------
                 | public | cntry98 | the_geom |
              2 | 4326 | MULTIPOLYGON | | |

In local machine, grass 6.1:

GRASS 6.1.cvs (spearfish60):~/cvsgrass/grass6 > v.in.ogr
dsn="PG:host=escaton dbname=geoprueba user=postgres" layer=cntry98
output=test1 type=point
comparing "meters"
to "unit"
to "units"
to "meters"
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.

Outputs from g.region and ogrinfo is the same as yours. Investigating
command flow in the source code, I can see in file
grass6/vector/v.in.ogr/main.c, lines 244+ ..

/* Open OGR DSN */
Ogr_ds = OGROpen( dsn_opt->answer, FALSE, NULL );
...
for ( i = 0; i < navailable_layers; i++ ) {
  Ogr_layer = OGR_DS_GetLayer( Ogr_ds, i );
  Ogr_featuredefn = OGR_L_GetLayerDefn( Ogr_layer );
  available_layer_names[i] = G_store ( (char *)OGR_FD_GetName(
Ogr_featuredefn ) );
}
...
Ogr_projection = OGR_L_GetSpatialRef(Ogr_layer);
...
if ( GPJ_osr_to_grass( &cellhd, &proj_info,
  &proj_units, Ogr_projection, 1) < 0 )
...

where Ogr_projection becomes a NULL pointer before calling
GPJ_osr_to_grass(). It seems to be the correct behaviour. Then, in
file grass6/lib/proj/convert.c, lines 227+ ...

int GPJ_osr_to_grass(struct Cell_head *cellhd, struct Key_Value **projinfo,
                     struct Key_Value **projunits, OGRSpatialReferenceH hSRS,
                     int interactive)
{
    struct Key_Value *temp_projinfo;
    char *pszProj4 = NULL, *pszRemaining;
    char *pszProj = NULL;

    if( hSRS == NULL )
        goto default_to_xy;
  ...
  default_to_xy:
    if( cellhd != NULL )
    {
        cellhd->proj = PROJECTION_XY;
        cellhd->zone = 0;
    }
  ...
    return 1;
}

So, when receiving a NULL hSRS (the Ogr_projection value), the
function GPJ_osr_to_grass() automatically assume LatLon and exit, and
the string message about OSRExportToProj4() shouldn't appear at all as
the hSRS==NULL is the very first thing checked.

What's happening here? No idea, but it seems to be an issue in your
GRASS install, not in code in CVS. Sorry.

The segfault somes from here:

comparing "meters"
to "unit"
to "units"
to "meters"
OSRExportToProj4() returned "+ellps=bessel +units=m +no_defs "
comparing "(null)"
to "ll"
Segmentation fault

So comparing (null) to something results in a segfault...

Yes, standard behaviour when using a NULL value in strcmp() function
(file key_value1.c, line 107). The question is, why do we get a null
for "key" value? The "key" parameter is always assigned to a static
string, except in the following files:
general/g.setproj/get_stp.c, lib/g3d/g3dkeys.c and lib/gis/get_projname.c.

It can't be in the first one: calling G_find_key_value(answer, ...) is
preceded by a strcmp(answer, ...) without producing segfault. The same
happens for the third one: strcmp(answer, ...) doesn't segfault, then
answer is not null. And no use of g3d code, so second file is also
descarted.

Again, I'm afraid the error is attached to your install. I can't
reproduce your results from my fresh GRASS 6.1 cvs install (from
yesterday) using your own data.

Sorry, but I quit. Regards,

M.

--
-- marcos boullón magán

Hello marcos,

On Fri, 24 Mar 2006 19:56:37 +0100 "marcos boullón magán"
<marcosboullon@gmail.com> wrote:

Hello Stephan,

Our outputs differ again!

> Yes, strange. After your patch was applied I got this output:
> v.in.ogr dsn="PG:dbname=postgis user=gdf" layer=cntry98 out=test14
> comparing "meters"
> to "unit"
> to "units"
> to "meters"
> OSRExportToProj4() returned "+proj=utm +zone=13 +ellps=clrk66
> +datum=NAD27 +units=m +no_defs "
>
> According to the ogrinfo-output the projection should at least be
> EPSG 4326 which is latlon
>

Very strange, because program flow shouldn't arrive to
OSRExportToProj4()!!

?! but why do I have this in my output?

I downloaded the db you provided, EPSG 4326 latlon, successfully
imported to postgis database, run v.in.ogr and the command
consistently warned about a different projection:

In postgresql+postgis server (see the 4326 SRID?):

geoprueba=# select * from geometry_columns where
f_table_name='cntry98'; f_table_catalog | f_table_schema |
f_table_name | f_geometry_column | coord_dimension | srid |
type | attrelid | varattnum | stats
-----------------+----------------+--------------+-------------------+-----------------+------+--------------+----------+-----------+-------
| public | cntry98 | the_geom | 2 | 4326 |
MULTIPOLYGON | | |

Exactly. This is what it should state.

In local machine, grass 6.1:

GRASS 6.1.cvs (spearfish60):~/cvsgrass/grass6 > v.in.ogr
dsn="PG:host=escaton dbname=geoprueba user=postgres" layer=cntry98
output=test1 type=point
comparing "meters"
to "unit"
to "units"
to "meters"
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.

only one odditiy here. AFAIK GRASS was known to figure out the correct
data.projection. In your case this is obviosly not the case since it
states unreferenced/unknown instead of LatLon which should be correct.

e.g.
name: Lat/lon
proj: ll
...
for the used dataset.

Outputs from g.region and ogrinfo is the same as yours. Investigating
command flow in the source code, I can see in file
grass6/vector/v.in.ogr/main.c, lines 244+ ..

/* Open OGR DSN */
Ogr_ds = OGROpen( dsn_opt->answer, FALSE, NULL );
...
for ( i = 0; i < navailable_layers; i++ ) {
  Ogr_layer = OGR_DS_GetLayer( Ogr_ds, i );
  Ogr_featuredefn = OGR_L_GetLayerDefn( Ogr_layer );
  available_layer_names[i] = G_store ( (char *)OGR_FD_GetName(
Ogr_featuredefn ) );
}
...
Ogr_projection = OGR_L_GetSpatialRef(Ogr_layer);
...
if ( GPJ_osr_to_grass( &cellhd, &proj_info,
  &proj_units, Ogr_projection, 1) < 0 )
...

where Ogr_projection becomes a NULL pointer before calling
GPJ_osr_to_grass(). It seems to be the correct behaviour. Then, in
file grass6/lib/proj/convert.c, lines 227+ ...

int GPJ_osr_to_grass(struct Cell_head *cellhd, struct Key_Value
**projinfo, struct Key_Value **projunits, OGRSpatialReferenceH hSRS,
                     int interactive)
{
    struct Key_Value *temp_projinfo;
    char *pszProj4 = NULL, *pszRemaining;
    char *pszProj = NULL;

    if( hSRS == NULL )
        goto default_to_xy;
  ...
  default_to_xy:
    if( cellhd != NULL )
    {
        cellhd->proj = PROJECTION_XY;
        cellhd->zone = 0;
    }
  ...
    return 1;
}

So, when receiving a NULL hSRS (the Ogr_projection value), the
function GPJ_osr_to_grass() automatically assume LatLon and exit, and
the string message about OSRExportToProj4() shouldn't appear at all as
the hSRS==NULL is the very first thing checked.

What's happening here? No idea, but it seems to be an issue in your
GRASS install, not in code in CVS. Sorry.

> The segfault somes from here:
>
> comparing "meters"
> to "unit"
> to "units"
> to "meters"
> OSRExportToProj4() returned "+ellps=bessel +units=m +no_defs "
> comparing "(null)"
> to "ll"
> Segmentation fault
>
> So comparing (null) to something results in a segfault...

Yes, standard behaviour when using a NULL value in strcmp() function
(file key_value1.c, line 107). The question is, why do we get a null
for "key" value? The "key" parameter is always assigned to a static
string, except in the following files:
general/g.setproj/get_stp.c, lib/g3d/g3dkeys.c and
lib/gis/get_projname.c.

It can't be in the first one: calling G_find_key_value(answer, ...) is
preceded by a strcmp(answer, ...) without producing segfault. The same
happens for the third one: strcmp(answer, ...) doesn't segfault, then
answer is not null. And no use of g3d code, so second file is also
descarted.

Again, I'm afraid the error is attached to your install. I can't
reproduce your results from my fresh GRASS 6.1 cvs install (from
yesterday) using your own data.

Sorry, but I quit. Regards,

no problem at all. I have learned a lot in this thread, but acctually
it did not solve my problem.

I am going to investigate the whole software chain starting from proj,
geos, gdal, pg, oci, grass

Thanks for your help marcos.

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@gdf-hannover.de
Phone : ++49-(0)511.39088507 - Fax: ++49-(0)511.39088508