<div>Hi </div>
<div>&nbsp;</div>
<div>I am doing this ....</div>
<div>&nbsp;</div>
<div>I have lat/lon of Top Left Corner of the Map and&nbsp; Bottom Right Corner of The Map</div>
<div>iam converting&nbsp;them to projected X,Y using this projection defintion </div>
<div>&nbsp;</div>
<div>World Mercator &lt;54004&gt; +proj=merc +latts=0 +lon0=0 +k=1.000000 +x0=0<br>+y0=0 +ellps=WGS84 +datum=WGS84 +units=m no_defs &lt;&gt;<br>&nbsp;</div>
<div>For example: </div>
<div>&nbsp;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;tl_lat = 42.8483;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tl_lon = -74.2935;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; br_lat = 42.3813;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; br_lon = -73.6509;<br>&nbsp;</div>
<div>&nbsp;</div>
<div>using pj_transform of proj4.. iam converting them to X,Y.</div>
<div>&nbsp;</div>
<div>
<p>top left xy </p>
<p>-8270314.5893 , 5259843.0071</p>
<p>btm right xy </p>
<p>-8198780.6845 , 5189458.4882<br></p>
<p>I calculate the Centre cX,cY using the top left X,Y and Btm right X,Y...</p>
<p>The Size of the Image I have generated from the Map is (1031,801)...</p>
<p>width = absolute value of (btm right X - top left X)</p>
<p>height&nbsp;= absolute value of (btm right&nbsp;Y - top left Y)</p>
<p>Now I am trying to&nbsp;get the pixel x,y from&nbsp;the projected X,Y&nbsp;using this formula</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;px = 515.5 +&nbsp; (1031/width)*(X-cX);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; py = 400.5&nbsp; -&nbsp; (801/height)*(Y-cY);<br></p>
<p>This gives correct pixels if i give top left or bottom right or the centre X,Y...</p>
<p>But for some point inside the Image ... </p>
<p>the calcualted pixel X&nbsp;is some 2/3 pixels away from actual pixel X&nbsp;</p>
<p>the calcualted pixel&nbsp;Y&nbsp;is some 8/10 pixels away from actual pixel Y</p>
<p>where am I going wrong ... is the projection iam using correct for such calculations ..???</p>
<p>&nbsp;</p>
<p>Thanks in advance.</p>
<p>sandeep</p>
<p>&nbsp;</p>
<p>&nbsp;</p></div>
<div><br>&nbsp;</div>
<div><span class="gmail_quote">On 10/6/06, <b class="gmail_sendername">Alessandro Pasotti</b> &lt;<a href="mailto:ale.pas@tiscali.it">ale.pas@tiscali.it</a>&gt; wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Il 16:04, venerd́ 6 ottobre 2006, Sandeep Kumar Jakkaraju ha scritto:<br>&gt; Hi<br>&gt;<br>&gt; a similar problem ...
<br>&gt;<br>&gt; I want to know the img_x and img_y&nbsp;&nbsp;for a corresponding MAPLON, MAPLAT....<br><br>I believe the only way is to do some math on the server or on the client (with<br>javascript code).<br><br>You already know the map extent and jpeg size, don't you?
<br><br>You can find a lot of examples on the net, just look at the js code of one of<br>the many webgis clients (p.mapper, openlayers or ka-map to cite a few).<br><br>Regards.<br>--<br>Alessandro Pasotti<br>itOpen - &quot;Open Solutions for the Net Age&quot;
<br>w3:&nbsp;&nbsp;<a href="http://www.itopen.it">www.itopen.it</a><br>Linux User# 167502<br></blockquote></div><br><br clear="all"><br>-- <br>Sandeep Kumar Jakkaraju <br>WeBlog:<br><a href="http://jakkarajus.blogspot.com">http://jakkarajus.blogspot.com
</a>