[postgis-devel] [WKT Raster] Plan to add ST_AsBinary
Mateusz Loskot
mateusz at loskot.net
Tue Aug 4 04:31:23 PDT 2009
Mark Cave-Ayland wrote:
> Mateusz Loskot wrote:
>>
>> What I'm looking for is what's the difference between ST_AsBinary
>> and ST_bytea, in PostGIS. Both functions are based on
>> WKBFromLWGEOM, so I assume they return object of exactly the same
>> type. AFAIU, the difference is that ST_AsBinary enables users to
>> choose endianness of output binary. Am I right? Is that all or
>> something is missing?
>
> IIRC the original PostGIS binary send/receive functions used HEXEWKB
> rather than bytea which is probably why the ST_bytea function is
> there (in fact, I didn't really notice it was there until you
> mentioned it!). So in short, ST_bytea is deprecated and really
> shouldn't be used - just stick with the ST_AsBinary()-type API and I
> don't think you can go far wrong.
I understand ST_bytea is deprecated, but it doesn't change the fact
that, AFAI can read the code, it returns WKB in the same form (bytea
object) as ST_AsBinary does.
Internally, both functions use WKBFromLWGEOM() and this function
forwards the job to serialized_lwgeom_to_ewkb().
The only (significant) difference I can see is that using ST_AsBinary
I can control endianness of output, but ST_bytea always returns
it as big-endian (network byte order) which is native for PostgreSQL
in binary games.
To summary,:
* existence of ST_bytea does not hurt
* semantic of ST_AsBinary is the same with extra options
Am I correct? If I am, I'd like to follow the same pattern making
ST_AsBinary for WKT Raster.
Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net
More information about the postgis-devel
mailing list