<html 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" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=US-ASCII">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<!--[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]-->
<title>ESRI Shapes from database</title>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
name="place"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
name="City"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
/* Font Definitions */
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman";}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{color:purple;
text-decoration:underline;}
p
{mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
font-size:12.0pt;
font-family:"Times New Roman";}
span.EmailStyle18
{mso-style-type:personal;
font-family:Arial;
color:navy;}
span.EmailStyle20
{mso-style-type:personal-reply;
font-family:Arial;
color:navy;}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
{page:Section1;}
-->
</style>
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<div style='border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt'>
<div>
<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>
<hr size=2 width="100%" align=center tabindex=-1>
</span></font></div>
<p class=MsoNormal><b><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma;font-weight:bold'>From:</span></font></b><font size=2
face=Tahoma><span style='font-size:10.0pt;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
11:16 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 size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=blue face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:blue'>Lee,</span></font><o:p></o:p></p>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> <o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=blue face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:blue'>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.</span></font><o:p></o:p></p>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> <o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=blue face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:blue'>For example these casts work okay</span></font><o:p></o:p></p>
<p class=MsoNormal><font size=2 color=blue face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:blue'>SELECT (encode(E'\\002The'::bytea,
'hex'))::float<br>
SELECT (encode(substring(E'\\002The'::bytea from 1 for 8), 'hex'))::float</span></font><o:p></o:p></p>
<p class=MsoNormal><font size=2 color=blue face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:blue'>SELECT
(encode(substring(E'\\002The'::bytea from 2 for 8), 'hex'))::float</span></font><o:p></o:p></p>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> <o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=blue face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:blue'>--Now if I try to go past the size of the
bytea observe - this casts to empty</span></font><o:p></o:p></p>
<p class=MsoNormal><font size=2 color=blue face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:blue'>SELECT
(encode(substring(E'\\002The'::bytea from 5 for 8), 'hex'))</span></font><o:p></o:p></p>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> <o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=blue face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:blue'>And if I then try to cast that empty to
float</span></font><o:p></o:p></p>
<p class=MsoNormal><font size=2 color=blue face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:blue'>SELECT
(encode(substring(E'\\002The'::bytea from 5 for 8), 'hex'))::float</span></font><o:p></o:p></p>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> <o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=blue face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:blue'>I get the error </span></font><o:p></o:p></p>
<div>
<p class=MsoNormal><font size=2 color=blue face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:blue'>ERROR: invalid input syntax for type
double precision: ""</span></font><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> <o:p></o:p></span></font></p>
</div>
<div>
<p class=MsoNormal><font size=2 color=blue face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:blue'>Hope that helps,</span></font><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><st1:City w:st="on"><st1:place w:st="on"><font size=2
color=blue face=Arial><span style='font-size:10.0pt;font-family:Arial;
color:blue'>Regina</span></font></st1:place></st1:City><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p> </o:p></span></font></p>
</div>
<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>
<hr size=2 width="100%" align=center tabIndex=-1>
</span></font></div>
<p class=MsoNormal><b><i><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy;font-weight:bold;
font-style:italic'>[Lee Keel] <o:p></o:p></span></font></i></b></p>
<p class=MsoNormal><st1:City w:st="on"><st1:place w:st="on"><font size=2
color=blue face=Arial><span style='font-size:10.0pt;font-family:Arial;
color:blue'>Regina</span></font></st1:place></st1:City><font size=2
color=blue face=Arial><span style='font-size:10.0pt;font-family:Arial;
color:blue'>,<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=blue face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:blue'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=blue face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:blue'>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. <o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=blue face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:blue'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=blue face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:blue'>I am getting a hex string back from by
bytea:<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=blue face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:blue'>SELECT (encode(substring(esri_shape from
cnt for 8), 'hex')) = 'E4A9F1517F0E2B41'<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=blue face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:blue'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=blue face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:blue'>So in theory this <b><span
style='font-weight:bold'>should</span></b> work:<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=blue face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:blue'>SELECT (encode(substring(esri_shape from
cnt for 8), 'hex'))::float<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=blue face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:blue'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=blue face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:blue'>But instead I get 'invalid syntax for a
double precision'. In my C# code, this hex value ('</span></font><font
size=1 color=blue face="Courier New"><span style='font-size:8.0pt;font-family:
"Courier New";color:blue'>E4A9F1517F0E2B41'</span></font><font size=2
color=blue face=Arial><span style='font-size:10.0pt;font-family:Arial;
color:blue'>) converts to 886591.660046872 using the microsoft bit
converter. The bit converter converts the given hex into the following
bit array:<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:30.75pt'><font size=1 color=blue
face="Courier New"><span style='font-size:8.0pt;font-family:"Courier New";
color:blue'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='margin-left:30.75pt'><font size=1 color=blue
face="Courier New"><span style='font-size:8.0pt;font-family:"Courier New";
color:blue'>[0]: 228<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 color=blue face="Courier New"><span
style='font-size:8.0pt;font-family:"Courier New";color:blue'>
[1]: 169<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 color=blue face="Courier New"><span
style='font-size:8.0pt;font-family:"Courier New";color:blue'>
[2]: 241<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 color=blue face="Courier New"><span
style='font-size:8.0pt;font-family:"Courier New";color:blue'>
[3]: 81<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 color=blue face="Courier New"><span
style='font-size:8.0pt;font-family:"Courier New";color:blue'>
[4]: 127<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 color=blue face="Courier New"><span
style='font-size:8.0pt;font-family:"Courier New";color:blue'>
[5]: 14<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 color=blue face="Courier New"><span
style='font-size:8.0pt;font-family:"Courier New";color:blue'>
[6]: 43<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=1 color=blue face="Courier New"><span
style='font-size:8.0pt;font-family:"Courier New";color:blue'>
[7]: 65<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=blue face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:blue'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=blue face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:blue'>I would appreciate any help you can
continue to provide on this.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=blue face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:blue'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=blue face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:blue'>Thanks again,<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=blue face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:blue'>Lee<o:p></o:p></span></font></p>
</div>
</div>
</body>
</html>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.