Opened 17 years ago

Closed 17 years ago

#1389 closed defect (fixed)

problem w/ date fields using ogr2ogr to load shapefile into postgis

Reported by: john.c.cartwright@… Owned by: Mateusz Łoskot
Priority: normal Milestone: 1.4.1
Component: OGR_SF Version: 1.3.2
Severity: normal Keywords:
Cc: warmerdam, Markus Neteler

Description (last modified by warmerdam)

the SQL generated by ogr2ogr seems to be truncating the date field. The record has the correct date using "ogrinfo -al". Problem reproduced on linux (RHEL WS 4) and Mac (10.4). Sample shapefile available at http://mapdevel.ngdc.noaa.gov/sample.tar

e.g. 
lynx:/usr/local/shapefiles jcc$ ogr2ogr -f postgresql -a_srs EPSG:4326
PG:dbname=jcc -overwrite osmc.shp
ERROR 1: INSERT command for new feature failed.
ERROR:  invalid input syntax for type date: "2006/12/"

Command: INSERT INTO "osmc" (wkb_geometry , "platform_i", "max_observ",
"observatio", "platform_t", "num_observ", "objectid") VALUES
(GeomFromEWKT('SRID=4326;POINT (-29.30999999999991
-41.889999999999972)'::TEXT) , '33627', '2006/12/', '2006/12/',
'DRIFTING BUOY', 133, 7469241)
ERROR 1: Terminating translation prematurely after failed
translation of layer osmc

Attachments (1)

sample.tar (10.0 KB ) - added by john.c.cartwright@… 17 years ago.
shape file containing 2 point features with date column

Download all attachments as: .zip

Change History (6)

by john.c.cartwright@…, 17 years ago

Attachment: sample.tar added

shape file containing 2 point features with date column

comment:2 by warmerdam, 17 years ago

Component: defaultOGR_SF
Description: modified (diff)
Milestone: 1.4.1
Owner: changed from warmerdam to Mateusz Łoskot
Priority: highestnormal
Severity: blockernormal

Mateusz,

Please check if this is working properly now. I see the original bug report was against 1.3.2. If a fix is needed, and not too complex, I'd like to see it in 1.4.1.

comment:3 by warmerdam, 17 years ago

Cc: warmerdam added

comment:4 by Markus Neteler, 17 years ago

Cc: Markus Neteler added

comment:5 by Mateusz Łoskot, 17 years ago

Status: newassigned

I checked current SVN version and it works for me correctly. I imported attached sample.shp file to PostgreSQL 8.2 database with ogr2ogr

ogr2ogr -update -f PostgreSQL PG:"host=localhost dbname=test" sample.shp

and queries imported data with ogrinfo, with following results:

ogrinfo PG:"host=localhost dbname=test" sample
INFO: Open of `PG:host=localhost dbname=test user=mloskot password=pantera'
      using driver `PostgreSQL' successful.

Layer name: sample
Geometry: Point
Feature Count: 2
Extent: (-143.549011, -6.237000) - (-143.548996, -6.237000)
Layer SRS WKT:
GEOGCS["Longitude / Latitude (WGS 84)",
    DATUM["WGS 84",
        SPHEROID["WGS 84",6378137.0,298.257223563]],
    PRIMEM["Greenwich",0.0],
    UNIT["Decimal Degree",0.0174532925199433]]
FID Column = ogc_fid
Geometry Column = wkb_geometry
depth: Integer (10.0)
ob_date: Date (0.0)
objectid: Integer (10.0)
parameter: String (10.0)
plat_id: String (9.0)
plat_type: String (20.0)
udunits: String (30.0)
value: Real (0.0)
OGRFeature(sample):1
  depth (Integer) = 1170
  ob_date (Date) = 2006/12/06
  objectid (Integer) = 6680551
  parameter (String) = zsal
  plat_id (String) = 5901026
  plat_type (String) = ARGO FLOAT
  udunits (String) = PSU
  value (Real) = 35
  POINT (-143.54900000000001 -6.23699999999995)

OGRFeature(sample):2
  depth (Integer) = 1143
  ob_date (Date) = 2006/12/06
  objectid (Integer) = 6680552
  parameter (String) = zsal
  plat_id (String) = 5901026
  plat_type (String) = ARGO FLOAT
  udunits (String) = PSU
  value (Real) = 35
  POINT (-143.54900000000001 -6.23699999999995)

Can I assume the problem has been fixed and close this ticked?

comment:6 by Mateusz Łoskot, 17 years ago

Resolution: fixed
Status: assignedclosed

I decided to close.

John, if the problem still occurs for you, please reopen this ticket.

Note: See TracTickets for help on using tickets.