Opened 19 years ago

Last modified 19 years ago

#681 closed defect (fixed)

loading s57 data into postgis: ERROR: malformed array literal: "{"

Reported by: halset@… Owned by: warmerdam
Priority: high Milestone:
Component: GDAL_Raster Version: unspecified
Severity: blocker Keywords:
Cc:

Description

I am trying to load a NOAA S57 cell into postgis using ogr2ogr. 

My setup:
postgresql-8.0.0b4
postgis-0.9.0
gdal-1.2.4

The command and the returned error message:
% /usr/local/bin/ogr2ogr -f "PostgreSQL" -update -lco OVERWRITE=YES   PG:'host=localhost 
port=5432 dbname=toretest user=toretest password=toretest' US1BS01M.000 BCNSPP
Warning 6: Can't create field lnam_refs with type StringList on PostgreSQL layers.  Creating as 
VARCHAR.
ERROR 1: INSERT command for new feature failed.
ERROR:  malformed array literal: "{"

The query and error from PostgreSQL log:
LOG:  statement: INSERT INTO "bcnspp" (wkb_geometry , "rcid", "prim", "grup", "objl", "rver", "agen", 
"fidn", "fids", "lnam", "lnam_refs", "ffpt_rind", "bcnshp", "catspm", "colour", "objnam", "status", "inform", 
"scamin", "sordat", "sorind") VALUES (GeometryFromText('POINT (-165.98983200 54.22163030)'::
TEXT,1) , 3, 1, 2, 9, 1, 550, 344289455, 2233, '0226148570AF08B9', '(2:02261485702E0', '{', 1, '27', '', 
'North Head Light', '1', 'On small house', 80000000, '20030000', 'US,US,graph,Chart 513')
ERROR:  malformed array literal: "{"

Change History (3)

comment:1 by halset@…, 19 years ago

The file can be downloaded from NOAA or
http://www.pvv.ntnu.no/~halset/tmp/US1BS01M.000.gz

comment:2 by halset@…, 19 years ago

This error also happens for 
postgresql-8.0.1
postgis-1.0.0-rc2
gdal-1.2.5

The problem seem to be a check for field length. I guess the field length for a postgresql int[] does not 
match the length of the string argument ala '{3,3,3,3}'. I worked around this problem with the following 
patch.

*** ogrpgtablelayer.cpp 2005/02/10 14:04:41     1.1
--- ogrpgtablelayer.cpp 2005/02/11 09:26:47
***************
*** 809,815 ****
              
              for( iChar = 0; pszStrValue[iChar] != '\0'; iChar++ )
              {
!                 if( poFeatureDefn->GetFieldDefn(i)->GetWidth() > 0
                      && iChar == poFeatureDefn->GetFieldDefn(i)->GetWidth() )
                  {
                      CPLDebug( "PG", 
--- 809,817 ----
              
              for( iChar = 0; pszStrValue[iChar] != '\0'; iChar++ )
              {
!                 if( poFeatureDefn->GetFieldDefn(i)->GetType() != OFTIntegerList
!                     && poFeatureDefn->GetFieldDefn(i)->GetType() != OFTRealList
!                     && poFeatureDefn->GetFieldDefn(i)->GetWidth() > 0
                      && iChar == poFeatureDefn->GetFieldDefn(i)->GetWidth() )
                  {
                      CPLDebug( "PG", 

comment:3 by warmerdam, 19 years ago

Problem verified. 

Patch applied. 

Fix verified. 

Thanks!

Note: See TracTickets for help on using tickets.