[postgis-users] ESRI Shapes from database

Obe, Regina robe.dnd at cityofboston.gov
Wed Oct 17 09:15:36 PDT 2007


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

________________________________

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


________________________________


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 7:42 AM
To: PostGIS Users Discussion
Subject: RE: [postgis-users] ESRI Shapes from database

 

Lee,

 

Just wondering what your example bytea looks like that you are trying to
convert that is giving you problems.  Normally I would think what you
are doing below should work (and I have tried some simple examples and
they work - but I don't work with bytea so what do I know.)  

 

So perhaps whatever your bytea is returning is out of range of float and
is not actually what you think it is like you have a terminator byte in
there or something causing the problems.

 

Other thought is if you could get the string representation of your
xcoord without casting to float,  since in the next line your float is
going to be internally recast as a string to do this  sb := sb || '(' ||
xCoord || ' ' || yCoord; 

anyway.

 

Hope that helps,

Regina

 

 

________________________________

Regina,

 

The reason that I can't go from the string representation is that the
8bytes used from the bytea are an encoding that contain information
about where to place the decimal and the digits on both sides of the
decimal.  So I need to cast to a float, then back to a string to get the
complete point.  I am very curious as to the examples you got working.
Could you please post what you had so I can take a look at what I am
doing wrong.  Here is what I have, I am just not sure how to take a hex
string and convert it to float:

 

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

 

 Thanks,

 Lee

 

________________________________

The substance of this message, including any attachments, may be
confidential, legally privileged and/or exempt from disclosure pursuant
to Massachusetts law. It is intended solely for the addressee. If you
received this in error, please contact the sender and delete the
material from any computer. 

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.



-----------------------------------------
The substance of this message, including any attachments, may be
confidential, legally privileged and/or exempt from disclosure
pursuant to Massachusetts law. It is intended
solely for the addressee. If you received this in error, please
contact the sender and delete the material from any computer.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20071017/bd1afc59/attachment.html>


More information about the postgis-users mailing list