Opened 8 years ago

Closed 8 years ago

#6128 closed defect (fixed)

WKB incorrectly guessed as 'Infinity'

Reported by: guido Owned by: warmerdam
Priority: normal Milestone: 2.0.2
Component: default Version: unspecified
Severity: normal Keywords: ogr2ogr, csv, csvdrv
Cc:

Description

Hi,

We've noticed that trying to import a csv such as the one attached (input.csv), ogr2ogr incorrectly interprets WKB as "double precision".

There is a script (bug.sh) attached which should reproduce the problem provided a postgres database with postgis installed is made available.

Attachments (2)

input.csv (130 bytes ) - added by guido 8 years ago.
bug.sh (764 bytes ) - added by guido 8 years ago.

Download all attachments as: .zip

Change History (4)

by guido, 8 years ago

Attachment: input.csv added

by guido, 8 years ago

Attachment: bug.sh added

comment:1 by Jukka Rahkonen, 8 years ago

I do not believe that the string you have is WKB, rather it seems like PostGIS geometry in a "canonical form" http://postgis.net/docs/manual-2.1/using_postgis_dbmanagement.html#EWKB_EWKT.

Am I right that this is your plan:

1) Acquire geometry in canonical form:

select st_geomfromtext('MULTIPOLYGON ((( -40 20, -40 60, 0 60, 0 20, -40 20 )))',4326);

result:

0106000020E6100000010000000103000000010000000500000000000000000044C0000000000000344000000000000044C00000000000004E4000000000000000000000000000004E400000000000000000000000000000344000000000000044C00000000000003440

2) Insert geometry from the canonical form:

insert into states(geom) values ('0106000020E6100000010000000103000000010000000500000000000000000044C0000000000000344000000000000044C00000000000004E4000000000000000000000000000004E400000000000000000000000000000344000000000000044C00000000000003440')

Am I right that you want that CSV driver could somehow automatically detect that a field contains a PostGIS geometry in a "canonical form" http://postgis.net/docs/manual-2.1/using_postgis_dbmanagement.html#EWKB_EWKT?

I am not sure if your plan to use csv as an interim format is reasonable. However, GDAL does not seem to interpret that the canonical geometry is "double", it sees is as a string, which is what it actually is:

ogrinfo input.csv input
INFO: Open of `input.csv'
      using driver `CSV' successful.

Layer name: input
Geometry: None
Feature Count: 2
Layer SRS WKT:
(unknown)
cartodb_id: String (0.0)
the_geom: String (0.0)
OGRFeature(input):1
  cartodb_id (String) = 2
  the_geom (String) = 0101000020E610000000000000000026400000000000002640



comment:2 by Even Rouault, 8 years ago

Milestone: 2.0.2
Resolution: fixed
Status: newclosed

trunk r30666, branches/2.0 r30667 "CPLGetValueType(): improve heuristics to avoid detecting some WKB strings as real numbers (#6128)"

In trunk, the -oo GEOM_POSSIBLE_NAMES=the_geom option can be used to decode WKB content as geometry. But this is unrelated to the issue of this ticket.

Note: See TracTickets for help on using tickets.