Ticket #1389 (closed defect: fixed)

Opened 7 years ago

Last modified 6 years ago

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

Reported by: john.c.cartwright@… Owned by: mloskot
Priority: normal Milestone: 1.4.1
Component: OGR_SF Version: 1.3.2
Severity: normal Keywords:
Cc: warmerdam, neteler

Description (last modified by warmerdam) (diff)

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

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

Change History

Changed 7 years ago by john.c.cartwright@…

shape file containing 2 point features with date column

Changed 6 years ago by warmerdam

  • description modified (diff)
  • component changed from default to OGR_SF
  • priority changed from highest to normal
  • milestone set to 1.4.1
  • owner changed from warmerdam to mloskot
  • severity changed from blocker to normal

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.

Changed 6 years ago by warmerdam

  • cc warmerdam added

Changed 6 years ago by neteler

  • cc neteler added

Changed 6 years ago by mloskot

  • status changed from new to assigned

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?

Changed 6 years ago by mloskot

  • status changed from assigned to closed
  • resolution set to fixed

I decided to close.

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

Note: See TracTickets for help on using tickets.