Hallo nochmal,
Ich habe da vom Eagle Dynamics Entwickler Team diese Formel in C++ um Längen und Breiten Grade in brauchbare lineare XZ Koordinaten umzuwandeln... Für mein Radar Lotsen
Projekt (Einfach nur auf connect drücken, mit der "R" Taste geht das Lineal an...)
PHP-Code:
const float zeroX = 5000000.f; // Real coordinates beginning
const float zeroZ = 6600000.f;
const float centerX = 11465000.f - zeroX; // Circle center
const float centerZ = 6500000.f - zeroZ;
const float pn40x24_X = 4468608.57f - zeroX; // point 40dgN : 24dgE
const float pn40x24_Z = 5730893.72f - zeroZ;
const float pn48x24_X = 5357858.31f - zeroX; // point 48dgN : 24dgE
const float pn48x24_Z = 5828649.53f - zeroZ;
const float pn40x42_X = 4468608.57f - zeroX; // point 40dgN : 42dgE
const float pn40x42_Z = 7269106.20f - zeroZ;
const float pn48x42_X = 5357858.31f - zeroX; // ????? 48dgN : 42dgE
const float pn48x42_Z = 7171350.00f - zeroZ;
// distances from the circle center to 48dgN and 40dgN
const double lenNorth = sqrt((pn48x24_X-centerX)*(pn48x24_X-centerX) + (pn48x24_Z-centerZ)*(pn48x24_Z-centerZ));
const double lenSouth = sqrt((pn40x24_X-centerX)*(pn40x24_X-centerX) + (pn40x24_Z-centerZ)*(pn40x24_Z-centerZ));
const double lenN_S = lenSouth - lenNorth;
const double RealAngleMaxLongitude = atan (((double)pn40x24_Z - centerZ)/(pn40x24_X - centerX)) * 180.f / PI;
// Map bounds. Degrees!
const float EndWest = 24.f;
const float EndEast = 42.f;
const float EndNorth = 48.f;
const float EndSouth = 40.f;
const float MiddleLongitude = (EndWest + EndEast) / 2;
const float ToLengthN_S = (float)((EndNorth - EndSouth) / lenN_S);
const double ToAngleW_E = (MiddleLongitude - EndWest) / RealAngleMaxLongitude;
const double ToDegree = 180. / PI;
void GetCoords(double inLatitudeGrad, double inLongitudeGrad, float &outX, float &outZ)
{
double realAng = (inLongitudeGrad - MiddleLongitude) / ToAngleW_E / ToDegree;
double realLen = lenSouth - (inLatitudeGrad - EndSouth) / ToLengthN_S;
outX = centerX - realLen * cos (realAng);
outZ = centerZ + realLen * sin (realAng);
}
Jetzt hab ich versucht die Formel in Actionscript umzubauen...
PHP-Code:
function latlong2xz (inLongitudeGrad,inLatitudeGrad) {
ToDegree = 180/Math.PI;
zeroX = 5000000;
zeroZ = 6600000;
centerX = 11465000-zeroX;
centerZ = 6500000-zeroZ;
pn40x24_X = 4468608.57-zeroX; // point 40dgN : 24dgE
pn40x24_Z = 5730893.72-zeroZ;
pn48x24_X = 5357858.31-zeroX; // point 48dgN : 24dgE
pn48x24_Z = 5828649.53-zeroZ;
pn40x42_X = 4468608.57-zeroX; // point 40dgN : 42dgE
pn40x42_Z = 7269106.20-zeroZ;
pn48x42_X = 5357858.31-zeroX; // point 48dgN : 42dgE
pn48x42_Z = 7171350.00-zeroZ;
// distances from the circle center to 48dgN and 40dgN
lenNorth = Math.sqrt((pn48x24_X-centerX)*(pn48x24_X-centerX)+(pn48x24_Z-centerZ)*(pn48x24_Z-centerZ));
lenSouth = Math.sqrt((pn40x24_X-centerX)*(pn40x24_X-centerX)+(pn40x24_Z-centerZ)*(pn40x24_Z-centerZ));
lenN_S = lenSouth-lenNorth;
RealAngleMaxLongitude = Math.atan((pn40x24_Z-centerZ)/(pn40x24_X-centerX))*ToDegree;
// Map bounds. Degrees!
EndWest = 24;
EndEast = 42;
EndNorth = 48;
EndSouth = 40;
MiddleLongitude = (EndWest+EndEast)/2;
ToLengthN_S = (EndNorth-EndSouth)/lenN_S;
ToAngleW_E = (MiddleLongitude-EndWest)/RealAngleMaxLongitude;
realAng = (inLongitudeGrad-MiddleLongitude)/ToAngleW_E/ToDegree;
realLen = lenSouth-(inLatitudeGrad-EndSouth)/ToLengthN_S;
outX = centerX-realLen*Math.cos(realAng);
outZ = centerZ+realLen*Math.sin(realAng);
return outX+" : "+outZ
}
klappt nur leider nicht richtig. D.h. Sie rechnet zwar, nur leider falsch. In C++ (davon kaum Ahnung) habe ich sie kompiliert gekriegt und siehe da, sie rechnet und auch noch richtig...
Wenn mir einer helfen mag wäre ich sehr dankbar...
Mit dieser
.exe... kann man dann überprüfen ob sie funktioniert... Die .exe in der Eingabeaufforderung ausführen und ganz wichtig,
. (Punkt) als Trennzeichen verwenden....
Danke vielmals im vorraus...
Zillion