[Featureserver] type=OGR & encoding problem

Yves Moisan yves.moisan at boreal-is.com
Mon Aug 10 14:50:00 EDT 2009


> I was just about to write the list asking the same thing (Is there a way to 
> configure FeatureServer to use encodings other than UTF-8 or US ASCII?). 

If you use trunk, you can do this for postGIS layers :

[YOURLAYER]
type=PostGIS
dsn=
...
encoding=iso-8859-1
attribute_cols=
...

Check in an earlier email on this list about modifications in
PostGIS.py.  You could certainly do the same for in OGR.py for an
arbitrary OGR-accessible data source.

Cheers,

Yves

> But 
> you have answered it before I could even ask it. I was running into the same 
> problem with shapefiles containing Swedish accented characters.
> Thanks
> Matt Priour
> 
> --------------------------------------------------
> From: "Christopher Schmidt" <crschmidt at metacarta.com>
> Sent: Wednesday, August 05, 2009 1:17 PM
> To: "Alexandre Dube" <adube at mapgears.com>
> Cc: "FeatureServer mailing list" <featureserver at openlayers.org>
> Subject: Re: [Featureserver] type=OGR & encoding problem
> 
> > On Wed, Aug 05, 2009 at 02:02:56PM -0400, Alexandre Dube wrote:
> >> Hi,
> >>
> >>   I have some .tab files I'd like serve with featureserver.  Their
> >> encoding is iso-8859-1 and they do contain special characters such as
> >> French accents.  If I use type=OGR in the .cfg file to serve the data, I
> >> get the following error :
> >>
> >>   An error occurred: 'utf8' codec can't decode byte 0xb0 in position 2:
> >> unexpected code byte
> >>
> >>   I looked in the code source and it doesn't seem to support other
> >> character encodings than utf8.  Is this right ?  Or is this a known bug
> >> ?  Any workaround ?
> >
> > Not a bug, just a lack of functionality.
> >
> >     if isinstance(value, str): value = unicode(value, "utf-8")
> >
> > Change that line to iso-8859-1, and ou should be good. If youd like to 
> > make
> > it configurable and send a patch, all the better.
> >
> >>   If I import this file in PostGIS (with ogr2ogr + shp2pgsql (while
> >> specifying iso-8859-1 as character encoding)) and use type=PostGIS
> >> instead to link to this new imported data, I get no error, but I get
> >> weird characters (lots of '\' and numbers instead of my special
> >> character in the geojson string returned).  BUT, in the end, the special
> >> characters get displayed correctly in the application (OpenLayers) so
> >> it's ok.  This could be a good workaround, but I'd like to avoid the
> >> transfer of each file I have in PostGIS if possible...
> >>
> >>   Any hint ?
> >>
> >>   Many thanks,
> >>
> >> -- 
> >> Alexandre Dubé
> >> Mapgears
> >> www.mapgears.com
> >>
> >> _______________________________________________
> >> Featureserver mailing list
> >> Featureserver at openlayers.org
> >> http://featureserver.org/mailman/listinfo/featureserver
> >
> > -- 
> > Christopher Schmidt
> > MetaCarta
> >
> > 
> 
> _______________________________________________
> Featureserver mailing list
> Featureserver at openlayers.org
> http://featureserver.org/mailman/listinfo/featureserver




More information about the Featureserver mailing list