Opened 2 years ago

Closed 2 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



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 ( 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 2 years ago. (764 bytes) - added by guido 2 years ago.

Download all attachments as: .zip

Change History (4)

Changed 2 years ago by guido

Attachment: input.csv added

Changed 2 years ago by guido

Attachment: added

comment:1 Changed 2 years ago by Jukka Rahkonen

I do not believe that the string you have is WKB, rather it seems like PostGIS geometry in a "canonical form"

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);



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"

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:
cartodb_id: String (0.0)
the_geom: String (0.0)
  cartodb_id (String) = 2
  the_geom (String) = 0101000020E610000000000000000026400000000000002640

comment:2 Changed 2 years ago by Even Rouault

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.