<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns="http://www.w3.org/TR/REC-html40" xmlns:v = 
"urn:schemas-microsoft-com:vml" xmlns:o = 
"urn:schemas-microsoft-com:office:office" xmlns:w = 
"urn:schemas-microsoft-com:office:word" xmlns:st1 = 
"urn:schemas-microsoft-com:office:smarttags"><HEAD><TITLE>ESRI Shapes from database</TITLE>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.6000.16481" name=GENERATOR><!--[if !mso]>
<STYLE>v\:* {
        BEHAVIOR: url(#default#VML)
}
o\:* {
        BEHAVIOR: url(#default#VML)
}
w\:* {
        BEHAVIOR: url(#default#VML)
}
..shape {
        BEHAVIOR: url(#default#VML)
}
</STYLE>
<![endif]--><o:SmartTagType name="place" 
namespaceuri="urn:schemas-microsoft-com:office:smarttags"></o:SmartTagType><o:SmartTagType 
name="City" 
namespaceuri="urn:schemas-microsoft-com:office:smarttags"></o:SmartTagType><!--[if !mso]>
<STYLE>st1\:* {
        BEHAVIOR: url(#default#ieooui)
}
</STYLE>
<![endif]-->
<STYLE>@font-face {
        font-family: Tahoma;
}
@page Section1 {size: 8.5in 11.0in; margin: 1.0in 1.25in 1.0in 1.25in; }
P.MsoNormal {
        FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman"
}
LI.MsoNormal {
        FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman"
}
DIV.MsoNormal {
        FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman"
}
A:link {
        COLOR: blue; TEXT-DECORATION: underline
}
SPAN.MsoHyperlink {
        COLOR: blue; TEXT-DECORATION: underline
}
A:visited {
        COLOR: purple; TEXT-DECORATION: underline
}
SPAN.MsoHyperlinkFollowed {
        COLOR: purple; TEXT-DECORATION: underline
}
P {
        FONT-SIZE: 12pt; MARGIN-LEFT: 0in; MARGIN-RIGHT: 0in; FONT-FAMILY: "Times New Roman"; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto
}
SPAN.EmailStyle18 {
        COLOR: navy; FONT-FAMILY: Arial; mso-style-type: personal-reply
}
DIV.Section1 {
        page: Section1
}
</STYLE>
</HEAD>
<BODY lang=EN-US vLink=purple link=blue>
<DIV dir=ltr align=left><SPAN class=411300115-17102007><FONT face=Arial 
color=#0000ff size=2>Lee,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=411300115-17102007><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=411300115-17102007><FONT face=Arial 
color=#0000ff size=2>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.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=411300115-17102007><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=411300115-17102007><FONT face=Arial 
color=#0000ff size=2>For example these casts work okay</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=411300115-17102007><FONT face=Arial 
color=#0000ff size=2>SELECT (encode(E'\\002The'::bytea, 'hex'))::float<BR>SELECT 
(encode(substring(E'\\002The'::bytea from 1 for 8), 
'hex'))::float</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=411300115-17102007><FONT face=Arial 
color=#0000ff size=2>SELECT (encode(substring(E'\\002The'::bytea from 2 for 
8), 'hex'))::float</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=411300115-17102007><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=411300115-17102007><FONT face=Arial 
color=#0000ff size=2>--Now if I try to go past the size of the bytea observe - 
this casts to empty</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=411300115-17102007><FONT face=Arial 
color=#0000ff size=2>SELECT (encode(substring(E'\\002The'::bytea from 5 for 8), 
'hex'))</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=411300115-17102007><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=411300115-17102007><FONT face=Arial 
color=#0000ff size=2>And if I then try to cast that empty to 
float</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=411300115-17102007><FONT face=Arial 
color=#0000ff size=2>SELECT (encode(substring(E'\\002The'::bytea from 5 for 8), 
'hex'))::float</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=411300115-17102007><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=411300115-17102007><FONT face=Arial 
color=#0000ff size=2>I get the error </FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT><FONT face=Arial color=#0000ff 
size=2>ERROR:  invalid input syntax for type double precision: 
""</FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><SPAN class=411300115-17102007><FONT face=Arial color=#0000ff size=2>Hope 
that helps,</FONT></SPAN></DIV>
<DIV><SPAN class=411300115-17102007><FONT face=Arial color=#0000ff 
size=2>Regina</FONT></SPAN></DIV>
<DIV><BR></DIV>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> 
postgis-users-bounces@postgis.refractions.net 
[mailto:postgis-users-bounces@postgis.refractions.net] <B>On Behalf Of </B>Lee 
Keel<BR><B>Sent:</B> Wednesday, October 17, 2007 10:28 AM<BR><B>To:</B> PostGIS 
Users Discussion<BR><B>Subject:</B> RE: [postgis-users] ESRI Shapes from 
database<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV class=Section1>
<DIV 
style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: blue 1.5pt solid; PADDING-TOP: 0in; BORDER-BOTTOM: medium none">
<DIV>
<DIV class=MsoNormal style="TEXT-ALIGN: center" align=center><FONT 
face="Times New Roman" size=3><SPAN style="FONT-SIZE: 12pt">
<HR tabIndex=-1 align=center width="100%" SIZE=2>
</SPAN></FONT></DIV>
<P class=MsoNormal><B><FONT face=Tahoma size=2><SPAN 
style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; FONT-FAMILY: Tahoma">From:</SPAN></FONT></B><FONT 
face=Tahoma size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma"> 
postgis-users-bounces@postgis.refractions.net 
[mailto:postgis-users-bounces@postgis.refractions.net] <B><SPAN 
style="FONT-WEIGHT: bold">On Behalf Of </SPAN></B>Obe, Regina<BR><B><SPAN 
style="FONT-WEIGHT: bold">Sent:</SPAN></B> Wednesday, October 17, 2007 7:42 
AM<BR><B><SPAN style="FONT-WEIGHT: bold">To:</SPAN></B> PostGIS Users 
Discussion<BR><B><SPAN style="FONT-WEIGHT: bold">Subject:</SPAN></B> RE: 
[postgis-users] ESRI Shapes from database</SPAN></FONT><o:p></o:p></P></DIV>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN 
style="FONT-SIZE: 12pt"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=blue size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">Lee,</SPAN></FONT><o:p></o:p></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN 
style="FONT-SIZE: 12pt"> <o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=blue size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">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.)  </SPAN></FONT><o:p></o:p></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN 
style="FONT-SIZE: 12pt"> <o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=blue size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">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.</SPAN></FONT><o:p></o:p></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN 
style="FONT-SIZE: 12pt"> <o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=blue size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">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 </SPAN></FONT><FONT color=black><SPAN 
style="COLOR: black"> </SPAN></FONT><FONT face=Arial color=black size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial">sb := sb || '(' || 
xCoord || ' ' || yCoord; </SPAN></FONT><o:p></o:p></P>
<P class=MsoNormal><FONT face=Arial color=black size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial">anyway.</SPAN></FONT><o:p></o:p></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN 
style="FONT-SIZE: 12pt"> <o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=black size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial">Hope that 
helps,</SPAN></FONT><o:p></o:p></P>
<P class=MsoNormal><st1:City w:st="on"><st1:place w:st="on"><FONT face=Arial 
color=black size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial">Regina</SPAN></FONT></st1:place></st1:City><o:p></o:p></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN 
style="FONT-SIZE: 12pt"> <o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN 
style="FONT-SIZE: 12pt"><o:p> </o:p></SPAN></FONT></P>
<DIV class=MsoNormal style="TEXT-ALIGN: center" align=center><FONT 
face="Times New Roman" size=3><SPAN style="FONT-SIZE: 12pt">
<HR tabIndex=-1 align=center width="100%" SIZE=2>
</SPAN></FONT></DIV>
<P class=MsoNormal><st1:City w:st="on"><st1:place w:st="on"><FONT face=Arial 
color=navy size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">Regina</SPAN></FONT></st1:place></st1:City><FONT 
face=Arial color=navy size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">,<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">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:<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">(encode(substring(esri_shape 
from cnt for 8), 'hex'))<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"> Thanks,<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"> Lee<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></P></DIV></DIV>
<P>
<HR SIZE=1>

<P></P>
<P><STRONG>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. 
</STRONG></P>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.</BODY></HTML>