[postgis-users] ESRI Shapes from database

Lee Keel lee.keel at uai.com
Wed Oct 17 12:38:51 PDT 2007


  _____  

From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Obe,
Regina
Sent: Wednesday, October 17, 2007 11:16 AM
To: PostGIS Users Discussion
Subject: RE: [postgis-users] ESRI Shapes from database

 

Lee,

 

Well here is an example I grabbed from somewhere.  But if I exceed the size
of the bytearray - I get one of the errors you describe.  That was why I
thought maybe your offsets are wrong and part of your array has terminators
embedded in it.

 

For example these casts work okay

SELECT (encode(E'\\002The'::bytea, 'hex'))::float
SELECT (encode(substring(E'\\002The'::bytea from 1 for 8), 'hex'))::float

SELECT (encode(substring(E'\\002The'::bytea from 2 for 8), 'hex'))::float

 

--Now if I try to go past the size of the bytea observe - this casts to
empty

SELECT (encode(substring(E'\\002The'::bytea from 5 for 8), 'hex'))

 

And if I then try to cast that empty to float

SELECT (encode(substring(E'\\002The'::bytea from 5 for 8), 'hex'))::float

 

I get the error 

ERROR:  invalid input syntax for type double precision: ""

 

Hope that helps,

Regina

 

  _____  

[Lee Keel] 

Regina,

 

Let me start by saying THANK YOU for all of your help on this.  I have been
trying the sample like you have above and I see what it is doing, but I
can't seem to get it to work with a value that I have.  

 

I am getting a hex string back from by bytea:

SELECT (encode(substring(esri_shape from cnt for 8), 'hex')) =
'E4A9F1517F0E2B41'

 

So in theory this should work:

SELECT (encode(substring(esri_shape from cnt for 8), 'hex'))::float

 

But instead I get 'invalid syntax for a double precision'.  In my C# code,
this hex value ('E4A9F1517F0E2B41') converts to 886591.660046872 using the
microsoft bit converter.  The bit converter converts the given hex into the
following bit array:

 

[0]: 228

    [1]: 169

    [2]: 241

    [3]: 81

    [4]: 127

    [5]: 14

    [6]: 43

    [7]: 65

 

I would appreciate any help you can continue to provide on this.

 

Thanks again,

Lee

This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the sender. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20071017/619f2185/attachment.html>


More information about the postgis-users mailing list