<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Aptos;
        panose-1:2 11 0 4 2 2 2 2 2 4;}
@font-face
        {font-family:Garamond;
        panose-1:2 2 4 4 3 3 1 1 8 3;}
@font-face
        {font-family:"Times New Roman \(Body CS\)";
        panose-1:2 11 6 4 2 2 2 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:12.0pt;
        font-family:"Aptos",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Garamond",serif;
        color:windowtext;
        font-weight:normal;
        font-style:normal;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;
        mso-ligatures:none;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="en-NL" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Garamond",serif;mso-fareast-language:EN-US">I cannot help you, let alone send pseudocode, as long as you do not understand the principle: you need to know
<b>which projection</b> you used in making (or was used by the software or the maker of) your PNG map. Only then you can calculate from lat-lon to x-y and from there to image pixel coordinates....<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Garamond",serif;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Garamond",serif;color:black">-- <o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Garamond",serif;color:black">Barend Köbben</span><span style="font-family:"Garamond",serif;mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Garamond",serif;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div id="mail-editor-reference-message-container">
<div>
<div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt">On 19/08/2025, 13:07, "Luca Bertoncello" <lucabert@lucabert.de> wrote:<o:p></o:p></p>
</div>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:11.0pt">Am 19.08.2025 10:29, schrieb Kobben, Barend (UT-ITC):<br>
> You can’t unless you know which X & Y you want/mean. It is NOT<br>
> correct to say that y is latitude and x is longitude!! XY means you<br>
> use a cartesian coordinate system (the map = flat rectangle) instead<br>
> of lat & lon which are angles from the center of a spheroid or<br>
> ellipsoid (the globe = a 3D object).<br>
> <br>
> We call the transformation from 3D globe to flat map a projection.<br>
> There are endless ways of projecting. Choose one of those projections<br>
> and do the math and then you go from lat-lons to y-es and x-es...<br>
<br>
Can you suggest me a way?<br>
<br>
> For a nice overview of all this see e.g.<br>
> <a href="https://kartoweb.itc.nl/geometrics">https://kartoweb.itc.nl/geometrics</a><br>
<br>
I think, I don't have the needed mathematical knowledge to understand <br>
that... :(<br>
<br>
I try to explain again what I need...<br>
I created an image, putting more tiles together. This is a PNG.<br>
Then I try to add some markers (airports) at known coordinates. And I <br>
need to convert this coordinates in X,Y related to my image.<br>
I searched many procedures in Internet, but they always position the <br>
markers at the wrong place.<br>
I tried now a very simple procedure that assumes Earth is flat, but it <br>
does not work correctly, too...<br>
<br>
This is my code (PHP):<br>
<br>
function latlngToScreenXY($lat, $lng, $minLat, $minLng, $maxLat, <br>
$maxLng, $mapWidth, $mapHeight)<br>
{<br>
   $lngDelta = $maxLng - $minLng;<br>
   $relLng = $lng - $minLng;<br>
   $percLng = $relLng / $lngDelta;<br>
   $x = $mapWidth * $percLng;<br>
<br>
   $latDelta = $maxLat - $minLat;<br>
   $relLat = $lat - $minLat;<br>
   $percLat = $relLat / $latDelta;<br>
   $y = $mapWidth * $percLat;<br>
<br>
   return array('X' => $x, 'Y' => $mapHeight - $y);<br>
}<br>
<br>
You can see the result as attachment.<br>
In the Map I drawed two circles: the first one at the south-west corner <br>
of the map. This is correct.<br>
The second one should be in the middle of the map ( ($maxLat - $minLat) <br>
/ 2 + $minLat, ($maxLng - $minLng) / 2 + $minLng ), and you see, this is <br>
NOT correct.<br>
Finally I tried to add the markers for the airports of Kamenz and <br>
Bautzen. And they are on the wrong position (both are souther than the <br>
correct position, Kamenz is wester and Bautzen is easter, too).<br>
<br>
Can you please send me at least a pseudocode to understand you to <br>
convert LatLng to Y,X of an image?<br>
<br>
Thanks<br>
Luca Bertoncello<br>
(lucabert@lucabert.de)<o:p></o:p></span></p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>