<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" 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)">
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:Verdana;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"Lucida Console";
        panose-1:2 11 6 9 4 5 4 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:Verdana;}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:Verdana;
        color:navy;
        font-weight:normal;
        font-style:normal;
        text-decoration:none none;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size:
10.0pt;color:navy'>PROJ folks,<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size:
10.0pt;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size:
10.0pt;color:navy'>I am trying to invoke proj as a child process using the
–b option, pass binary 64-bit floats to stdin, and receive binary 64-bit
floats from stdout:<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size:
10.0pt;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>proj –b</span></font><font
color=navy><span style='color:navy'> </span></font><font color=navy
face="Courier New"><span style='font-family:"Courier New";color:navy'>+proj=merc
+ellps=WGS84</span></font><font color=navy><span style='color:navy'><o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size:
10.0pt;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size:
10.0pt;color:navy'>I have discovered that I can successfully project the point 37.782
0.0 but not the point 37.783 0.0. When I write the first point to stdin (in
radians, of course), proj responds by writing 16 bytes to stdout. This is the
projected point. But when I write the second point, proj does not write
anything to stdout. I have reproduced the problem on a Windows XP machine with
a Pentium M and a Windows Vista machine with a Core 2 T74000. I am using <a
href="ftp://ftp.remotesensing.org/proj/proj446_win32_bin.zip">ftp://ftp.remotesensing.org/proj/proj446_win32_bin.zip</a>.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size:
10.0pt;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size:
10.0pt;color:navy'>Can anyone explain why I can project one point but not the
other? If this is a bug in proj, can you fix it? Thanks very much for any help
anyone can provide. If it is a bug and no fix is possible, I would suggest that
the –b or –i options not be used by anyone unless someone can
explain the circumstances in which they may be safely used.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size:
10.0pt;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size:
10.0pt;color:navy'>Here is a detailed demonstration of the problem. First, I
can successfully project both points if I invoke proj in normal mode (not using
–b):<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size:
10.0pt;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>C:\temp2>proj
+proj=merc +ellps=WGS84<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>37.782 0.0<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>4205873.00
0.00<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>37.783 0.0<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>4205984.32
0.00<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size:
10.0pt;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size:
10.0pt;color:navy'>In order to use the –b option, it is necessary to pass
in radians. I wrote a C++ program, compiled with Visual Studio 2005 as a Win32
console application, to convert to radians and display the hex values of the
64-bit float representations:<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size:
10.0pt;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=blue
face="Lucida Console"><span style='font-size:10.0pt;font-family:"Lucida Console";
color:blue'>#include</span></font><font face="Lucida Console"><span
style='font-family:"Lucida Console"'> <font color="#a31515"><span
style='color:#A31515'><stdio.h><o:p></o:p></span></font></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color="#a31515"
face="Lucida Console"><span style='font-size:10.0pt;font-family:"Lucida Console";
color:#A31515'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=blue
face="Lucida Console"><span style='font-size:10.0pt;font-family:"Lucida Console";
color:blue'>void</span></font><font face="Lucida Console"><span
style='font-family:"Lucida Console"'> main()<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2
face="Lucida Console"><span style='font-size:10.0pt;font-family:"Lucida Console"'>{<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2
face="Lucida Console"><span style='font-size:10.0pt;font-family:"Lucida Console"'>
<font color=blue><span style='color:blue'>double</span></font> value =
3.14159265358979323846 / 180.0 * 37.782;<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2
face="Lucida Console"><span style='font-size:10.0pt;font-family:"Lucida Console"'>
<font color=blue><span style='color:blue'>unsigned</span></font> <font
color=blue><span style='color:blue'>char</span></font> *p = (<font color=blue><span
style='color:blue'>unsigned</span></font> <font color=blue><span
style='color:blue'>char</span></font> *)&value;<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2
face="Lucida Console"><span style='font-size:10.0pt;font-family:"Lucida Console"'>
printf(<font color="#a31515"><span style='color:#A31515'>"value = %.17f
(%02X %02X %02X %02X %02X %02X %02X %02X)\n"</span></font>, value, p[0],
p[1], p[2], p[3], p[4], p[5], p[6], p[7]);<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2
face="Lucida Console"><span style='font-size:10.0pt;font-family:"Lucida Console"'>
value = 3.14159265358979323846 / 180.0 * 37.783;<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2
face="Lucida Console"><span style='font-size:10.0pt;font-family:"Lucida Console"'>
printf(<font color="#a31515"><span style='color:#A31515'>"value = %.17f
(%02X %02X %02X %02X %02X %02X %02X %02X)\n"</span></font>, value, p[0],
p[1], p[2], p[3], p[4], p[5], p[6], p[7]);<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2
face="Lucida Console"><span style='font-size:10.0pt;font-family:"Lucida Console"'>}<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size:
10.0pt;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size:
10.0pt;color:navy'>This produced the output:<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size:
10.0pt;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>value =
0.65942029798849755 (C6 BB C5 98 F8 19 E5 3F)<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>value =
0.65943775128101756 (F9 FD EF 32 1D 1A E5 3F)<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size:
10.0pt;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size:
10.0pt;color:navy'>As an aside, because I ultimately want to invoke proj from
Python, I did the same thing in Python 2.5, to verify that Python and C++
produced the same representations:<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size:
10.0pt;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>>>>
import array, math<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>>>> '
'.join(map(hex, map(ord, array.array('d',
[math.radians(37.782)]).tostring()))).replace('0x', '').upper()<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>'C6 BB C5 98 F8
19 E5 3F'<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>>>> '
'.join(map(hex, map(ord, array.array('d',
[math.radians(37.783)]).tostring()))).replace('0x', '').upper()<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>'F9 FD EF 32 1D
1A E5 3F'<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size:
10.0pt;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size:
10.0pt;color:navy'>Using a hex editor, I wrote the binary values for the two
points to two 16-byte files, 37.782.bin and 37.783.bin. Note that the 64-bit
float representation of 0.0 is 0x0000000000000000.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size:
10.0pt;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>C:\temp2>hexdump
37.782.bin<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>HEXDUMP of Mon,
13 Jun 2005, copyright (c) 2005 by Rich Pasco<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face="Courier New"><span lang=DE
style='font-size:10.0pt;font-family:"Courier New";color:navy'>C:\temp2\37.782.bin
16 bytes 9/26/2007 9:22:50<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face="Courier New"><span lang=DE
style='font-size:10.0pt;font-family:"Courier New";color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face="Courier New"><span lang=DE
style='font-size:10.0pt;font-family:"Courier New";color:navy'>
-0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -A -B -C -D -E -F<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face="Courier New"><span lang=DE
style='font-size:10.0pt;font-family:"Courier New";color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face="Courier New"><span lang=DE
style='font-size:10.0pt;font-family:"Courier New";color:navy'>00000000- C6 BB
C5 98 F8 19 E5 3F 00 00 00 00 00 00 00 00 [.......?........]<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Verdana><span lang=DE
style='font-size:10.0pt;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face="Courier New"><span lang=DE
style='font-size:10.0pt;font-family:"Courier New";color:navy'>C:\temp2>hexdump
37.783.bin<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>HEXDUMP of Mon,
13 Jun 2005, copyright (c) 2005 by Rich Pasco<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face="Courier New"><span lang=DE
style='font-size:10.0pt;font-family:"Courier New";color:navy'>C:\temp2\37.783.bin
16 bytes 9/26/2007 9:22:56<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face="Courier New"><span lang=DE
style='font-size:10.0pt;font-family:"Courier New";color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face="Courier New"><span lang=DE
style='font-size:10.0pt;font-family:"Courier New";color:navy'>
-0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -A -B -C -D -E -F<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face="Courier New"><span lang=DE
style='font-size:10.0pt;font-family:"Courier New";color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>00000000- F9 FD
EF 32 1D 1A E5 3F 00 00 00 00 00 00 00 00 [...2...?........]<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size:
10.0pt;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size:
10.0pt;color:navy'>I verified that I could use the –i option with O/S redirection
to pass in 37.782.bin and get the expected result:<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size:
10.0pt;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>C:\temp2>proj
-i +proj=merc +ellps=WGS84 < 37.782.bin<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>4205873.00
0.00<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size:
10.0pt;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size:
10.0pt;color:navy'>But now, when I pass in 37.783.bin, proj does not write
anything to stdout:<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size:
10.0pt;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:navy'>C:\temp2>proj
-i +proj=merc +ellps=WGS84 < 37.783.bin<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size:
10.0pt;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size:
10.0pt;color:navy'>When I invoke it from a Python program using the –b
option, the same situations result (except the output for the first point is 16
bytes and the second point is nothing). For brevity, I’m not including
that program here.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size:
10.0pt;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size:
10.0pt;color:navy'>Again, thanks for your help,<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size:
10.0pt;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size:
10.0pt;color:navy'>Jason<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Verdana><span style='font-size:
10.0pt;color:navy'><o:p> </o:p></span></font></p>
</div>
</body>
</html>