[gdal-dev] How to write WKB as string?

Roger André randre at gmail.com
Wed Oct 14 10:28:49 PDT 2015


Ahh, thanks!  It helps to frame the question correctly.  I see now that
what I am trying to do is create the hex-encoded form of WKB.

On Wed, Oct 14, 2015 at 10:24 AM, Even Rouault <even.rouault at spatialys.com>
wrote:

> Le mercredi 14 octobre 2015 19:18:20, Roger André a écrit :
> > <grin>  Yes Even, exportToWkb() was something I tried, but I thought
> there
> > might be an easy way to get the ASCII form of the WKB, rather than the
> > straight binary that I got when I wrote out to a text file.
>
> Ah I missed that part.
>
> The following should help:
>
> http://www.gdal.org/cpl__string_8h.html:
>
> char *  CPLBinaryToHex (int nBytes, const GByte *pabyData)
> CPL_WARN_UNUSED_RESULT
>         Binary to hexadecimal translation. More...
>
> GByte *         CPLHexToBinary (const char *pszHex, int *pnBytes)
> CPL_WARN_UNUSED_RESULT
>
> Even more compact with base64 encoding:
>
> char *  CPLBase64Encode (int nBytes, const GByte *pabyData)
> CPL_WARN_UNUSED_RESULT
>
> int     CPLBase64DecodeInPlace (GByte *pszBase64)
>
> >
> > Norman, thanks for the links. I'll go peruse them.
> >
> > On Wed, Oct 14, 2015 at 10:10 AM, Norman Vine <nhv at cape.com> wrote:
> > > On Oct 14, 2015, at 12:59 PM, Roger André <randre at gmail.com> wrote:
> > >
> > > Hi All,
> > >
> > > I have a tool which currently exports geometry using the ExportToWkt()
> > > function.  It works great, but I'd like to try reducing the size of my
> > > output files by using a format like the string representation of WKB
> that
> > > shp2pgsql produsces when creating SQL insert files.  Is there a export
> > > function available in GDAL that I could use for this?
> > >
> > > I'm looking at http://www.gdal.org/classOGRGeometry.html currently,
> but
> > > have not yet spotted what I'm looking for.
> > >
> > > Thanks,
> > >
> > >
> > > see
> > > http://www.gdal.org/ogr__api_8h.html#ad5c94ae76c09774dba8725c24daeefd6
> > > or
> > >
> http://www.gdal.org/classOGRGeometry.html#a9a3ad2f9b55285be500ca6ac5dc75d
> > > 1d
>
> --
> Spatialys - Geospatial professional services
> http://www.spatialys.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20151014/05f1cb27/attachment.html>


More information about the gdal-dev mailing list