[postgis-users] Read file encoding from from shape file

Peter Hopfgartner peter.hopfgartner at r3-gis.com
Thu Mar 25 10:18:20 PDT 2010


Well, I've started to compare the version in PostGIS with that from 
shapelib, dated 2003-07-08 (that should be approx the date of the fork). 
I've run indent on those files, so that diff produces less noise caused 
by changing white spaces.

In the PostGIS version are:

 1) a lot of added casts to unsigned int
 2) some bug fixes, which I would be cautious to port, since the same 
bugs may have been fixed in the main shapelib
 3) 2 new functions: DBFReadDeleted and DBFReadSetup. Here I'm not sure 
what really happens here.
 4) support for date. This seems to be easy and I've posted the diffs to 
the shapelib mailing list.

The diff between current PostGIS version and those of Shapefile dated 
2003-07-08 are attached.

Regards,

Peter

Paul Ramsey wrote:
> Yes, there's patches to our shapelib that don't exist in the mainline.
> The process needs to identify our changes to feed back to mainline,
> update mainline, then bring that in.
>
> P.
>
> On Sat, Mar 20, 2010 at 3:41 PM, Peter Hopfgartner
> <peter.hopfgartner at r3-gis.com> wrote:
>   
>> Paul Ramsey wrote:
>>     
>>> I was never certain that ESRI software actually respected the DBF code
>>> page flags, but your reference indicates they do, so this seems
>>> reasonable. Some investigation of the current state of shapelib WRT
>>> encoding would be wise, as I think we should update our shapelib to
>>> the current version when we release 2.0.
>>>
>>> P.
>>>
>>>
>>>       
>> I had a look if it was quick deal to upgrade to current shapelib. I copied
>> dbfopen.c, shpopen.c and shapefil.h from a currrent the shapelib checkout.
>> Unfortunatly, it seems to me that date handling has disappeared from
>> shapelib. At least FTDate is not defined anymore and in DBFOpen no 'D' is
>> assigned as field type.
>>
>> Am I missing something obvious here?
>>
>> Regards,
>>
>> Peter
>>     
>>> On Fri, Feb 26, 2010 at 5:55 AM, Peter Hopfgartner
>>> <peter.hopfgartner at r3-gis.com> wrote:
>>>
>>>       
>>>> Hi
>>>>
>>>> Looking into the sources of shp2pgsql, [0], it seems that the loader
>>>> assumes
>>>> that the encoding of the dbf file is  "WINDOWS-1252", if not specified
>>>> differently by the -W command line option.
>>>>
>>>> From [1], shape files carry some information about their encoding, either
>>>> in
>>>> the dbf file header at byte position 29, [2], or in a separate file with
>>>> extension CPG.
>>>>
>>>> Would it make sense to change the default behaviour of shp2pgsql into:
>>>>
>>>> 1) try to get file encoding from dbf file or cpg file
>>>> 2) if 1) fails, take WINDOWS-1252 as default
>>>> 3) if -W is given, take this option
>>>>
>>>> And then, is the information about the encoding set by pgsql2shp? It
>>>> would
>>>> be smooth, if shapes generated by pgsql2shp could be imported by
>>>> shp2pgsql
>>>> without specifying any encoding during import ("just works").
>>>>
>>>> Regards,
>>>>
>>>> Peter
>>>>
>>>> [0] http://trac.osgeo.org/postgis/browser/trunk/loader/
>>>> [1]
>>>>
>>>> http://support.esri.com/index.cfm?fa=knowledgebase.techArticles.articleShow&d=21106
>>>> [2] http://www.dbase.com/knowledgebase/int/db7_file_fmt.htm
>>>>
>>>> --
>>>>
>>>> Dott. Peter Hopfgartner
>>>>
>>>> R3 GIS Srl - GmbH
>>>> Via Johann Kravogl-Str. 2
>>>> I-39012 Meran/Merano (BZ)
>>>> Email: peter.hopfgartner at r3-gis.com
>>>> Tel. : +39 0473 494949
>>>> Fax  : +39 0473 069902
>>>> www  : http://www.r3-gis.com
>>>>
>>>> XING : http://www.xing.com/go/invita/8917535
>>>> _______________________________________________
>>>> postgis-users mailing list
>>>> postgis-users at postgis.refractions.net
>>>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>>>>
>>>>
>>>>         
>>> _______________________________________________
>>> postgis-users mailing list
>>> postgis-users at postgis.refractions.net
>>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>>>
>>>
>>>       
>> --
>>
>> Dott. Peter Hopfgartner
>>
>> R3 GIS Srl - GmbH
>> Via Johann Kravogl-Str. 2
>> I-39012 Meran/Merano (BZ)
>> Email: peter.hopfgartner at r3-gis.com
>> Tel. : +39 0473 494949
>> Fax  : +39 0473 069902
>> www  : http://www.r3-gis.com
>>
>> XING : http://www.xing.com/go/invita/8917535
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at postgis.refractions.net
>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>>
>>     
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
>   


-- 
 
Dott. Peter Hopfgartner
 
R3 GIS Srl - GmbH
Via Johann Kravogl-Str. 2
I-39012 Meran/Merano (BZ)
Email: peter.hopfgartner at r3-gis.com
Tel. : +39 0473 494949
Fax  : +39 0473 069902
www  : http://www.r3-gis.com

XING : http://www.xing.com/go/invita/8917535 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: dbfopen.c.diff
Type: text/x-patch
Size: 41870 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20100325/69b19944/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: shapefil.h.diff
Type: text/x-patch
Size: 17368 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20100325/69b19944/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: shpopen.c.diff
Type: text/x-patch
Size: 61278 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20100325/69b19944/attachment-0002.bin>


More information about the postgis-users mailing list