[postgis-users] WKB format

Paul Ramsey pramsey at refractions.net
Thu Jul 4 11:02:43 PDT 2002


OK, poking around a bit in JDBC definitions: the pgsql JDBC driver will
try and map unknown types (like wkb) into LONGVARCHAR. This is no good
for you, you want an 8bit representation. Add a custom mapping for the
wkb type which maps into LONGVARBINARY instead. Then getBytes should
work better. (http://lab.applinet.nl/postgresql-jdbc/)

(My query to Dave and Chris remains.)

Paul Ramsey wrote:
> 
> Poke around some more. My guess is that this problem adheres to the JDBC
> driver in some manner. We can retrieve WKB directly from binary cursors
> with no problem via libpq. It could be that pgsql is squashing the
> results of the WKB query into 7 bits because it is not a known 8bit
> type, and the cursor is not 8bit. Can you do clean getBytes against
> bytea types using text cursors?
> Perhaps Dave/Chris could answer: why are we using a special type (wkb)
> for the wkb results instead of just a bytea?
> 
> P.
> 
> David Garnier wrote:
> >
> > OK, I think I get it from reading the source. PostGIS actually parses the binary data into an hexadecimal string and returns it. If I try to read my data with a getString, it looks fine, just like in plsql.
> >
> > Now, there is a way to get the real bytes? A byte array that would match the specification of the WKB format? Or are we stuck with Strings till the end of times?
> >
> > Best Regards,
> > David Garnier
> >
> > On Thu, 4 Jul 2002 21:24:18 +0200
> > David Garnier <david.garnier at etudier-online.com> wrote:
> >
> > > Hello,
> > >
> > > I'm working on this WKBReader in java, and I have some problems getting the data out of postgres. I use the following query:
> > > select asbinary(the_geom,'NDR') as wkb , astext(the_geom) as wkt  from road_shapes limit 25
> > > Then I do a getBytes on wkb:
> > > From java I got this: 303130353030303030303031303030303030303130323030303030303033303030303030373532324331353433334641353943303130354130463546323630303434343034324231313533343244464235394330334132313734443032353030343434303734354643453643353746433539433032334639344132303235303034343430
> > >
> > > From plsql, I got this:
> > > 0105000000010000000102000000030000007522C15433FA59C0105A0F5F2600444042B115342DFB59C03A2174D025004440745FCE6C57FC59C023F94A2025004440
> > >
> > > I think that there is two problems: the fourth bit of the each byte is set null. That would explain why there is no values above 7.
> > >
> > > I'm thinking that this might be related to different encoding schemes between Java and postgres.
> > >
> > > I figured that I would just ask around before diving head first into the source code of postgis.
> > >
> > > Best Regards,
> > > David Garnier
> > >
> > > _______________________________________________
> > > 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
> 
> --
>       __
>      /
>      | Paul Ramsey
>      | Refractions Research
>      | Email: pramsey at refractions.net
>      | Phone: (250) 885-0632
>      \_
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users

-- 
      __
     /
     | Paul Ramsey
     | Refractions Research
     | Email: pramsey at refractions.net
     | Phone: (250) 885-0632
     \_




More information about the postgis-users mailing list