Hallo ihr PHP-Experten,
ich mache Grafiken mit PHP, die als IMGs in Webseiten erscheinen,
also ohne eigenes Fenster und da bekomme ich kein include/require
hin.
Hier ein Beispiel was funktioniert, aber wenn die Funktion
ausgelagert ist, dann nicht mehr:
<?PHP // Darstellung von Orten<br />//include("geogk-inc.php"); // jetzt auskommentiert
function GeoGk($z) {
define ('rho',180/pi());
$sy = 4; //GK-Streifen
$e2 = 0.0067192188;
$c = 6398786.849;
$j=strpos($z,'/')+1;
if ($j\<13) $j=strpos($z,',')+1;
$br=substr($z,0,7);
$la=substr($z,$j,7);
$bf = $br / rho;
$g = 111120.61962 \* $br
-15988.63853 \* sin(2\*$bf)
+16.72995 \* sin(4\*$bf)
-0.02178 \* sin(6\*$bf)
+0.00003 \* sin(8\*$bf);
$co = cos($bf);
$g2 = $e2 \* ($co \* $co);
$g1 = $c / sqrt(1+$g2);
$t = sin($bf) / $co; // =tan(t)
$dl = $la - $sy \* 3;
$fa = $co \* $dl / rho;
$y = $g + $fa \* $fa \* $t \* $g1 / 2
+ $fa \* $fa \* $fa \* $fa \* $t \* $g1 \*
(5 - $t \* $t + 9 \* $g2) / 24;
$rm = $fa \* $g1
+ $fa \* $fa \* $fa \* $g1 \* (1 - $t \* $t + $g2) / 6
+ pow($fa,5) \* $g1 \* (5 - 18 \* pow($t,6)) / 120;
$x = round($rm) + $sy \* 1000000 + 500000;
$y=round($y);
return $x.'/'.$y;
}
$image = imagecreate(500,300);
$gelb = imagecolorallocate($image,255,255,0);
$schwarz = imagecolorallocate($image,0,0,0);
$rot = imagecolorallocate($image,255,0,0);
$z = array('',
' 4407050 5608900 Suhl',
' 4430655 5648940 Erfurt',
'50.87150000,12.07410000 Gera');
for ($i = 1; $i <count></count>if (substr($z[$i],2,1)=='.') // goedät.Koord.
$zz=GeoGk($z[$i]);
else //Guass-Kr.-Koord.
$zz=substr($z[$i],8);
$px[$i] = substr($zz,0,7);
$py[$i] = substr($zz,8,7);
$xy[$i+$i-2] = 50+(($px[$i]-$px[1])\>\>8);
$xy[$i+$i-1] = 4900+(($px[1]-$py[$i])\>\>8);
imagestring($image,2,$xy[$i+$i-2],$xy[$i+$i-1],substr($z[$i],24),
$schwarz);
//imagestring($image,2,125,100+$i\*20,$px[$i].'/'.$py[$i].' '.$z[$i],
$rot);
}
imagepolygon($image,$xy,3,$rot);
header("Content-type: image/png");
imagepng($image);
imagedestroy($image);
?\>
Hoffe dass mir jemand den Trick verrät, wie ich meine Funktionen
nicht zig-mal ablegen muss.
Gruss von Jott053 aus Thüringen