Example #1
0
function draw($lat, $lon, $color = NULL)
{
    global $im;
    global $offset;
    global $dot;
    if ($color == NULL) {
        $color = $dot;
    }
    $pt = getlocationcoords($lat, $long, imagesx($im), imagesy($im));
    ImageRectangle($im, $pt["x"] - $offset, $pt["y"], $pt["x"] + 1 - $offset, $pt["y"] + 1, $dot);
}
Example #2
0
function map()
{
    global $objUtil;
    $long = $objUtil->checkGetKey('long', 0);
    $lat = $objUtil->checkGetKey('lat', 0);
    // First we load the background/base map.
    // We assume it's located in ../../styles/images/earth.jpg.
    // This can be any format but we are using JPG in this example. We will also allocate the color for the marker
    $im = imagecreatefromjpeg("../../styles/images/earth.jpg");
    $red = imagecolorallocate($im, 255, 0, 0);
    // Next need to find the base image size. We need these variables to be able scale the long/lat coordinates.
    $scale_x = imagesx($im);
    $scale_y = imagesy($im);
    $pt = getlocationcoords($lat, $long, $scale_x, $scale_y);
    // Now mark the point on the map using a red 4 pixel rectangle
    imagefilledrectangle($im, $pt["x"] - 2, $pt["y"] - 2, $pt["x"] + 2, $pt["y"] + 2, $red);
    // imagestring($im,2,1,$scale_y-20,"Courtesy of www.staycanada.ca",$red);
    // Return the map image. We are using a PNG format as it gives better final image quality than a JPG
    header("Content-Type: image/png");
    imagepng($im);
    imagedestroy($im);
}
 $Blue = imagecolorallocate($im_earthmap, 0, 0, 255);
 $Yellow = imagecolorallocate($im_earthmap, 255, 255, 0);
 #ImageColorTransparent($im_map_user, $Black);
 #ImageFill($im_map_user, 0, 0, $Black);
 #Imageinterlace($im_map_user, 1);
 #ImageAlphaBlending($im_map_user, true);
 #$im_earthmap_user = ImageCreateTrueColor($im_size_x,$im_size_y);
 #ImageAlphaBlending($im_earthmap_user, true);
 //ip auslesen, koordinaten ermitteln und in x,y umsetzen, punkt markieren
 $geoip = geoip_record_by_addr($gi, getIP());
 #$pt = getlocationcoords($geoip->latitude, $geoip->longitude, $im_size_x, $im_size_y);
 //https://sourceforge.net/tracker/index.php?func=detail&aid=3114589&group_id=190396&atid=933192
 //bug fixed, id: 3114589
 //thx to tms-schmidt
 if (!is_null($geoip)) {
     $pt = getlocationcoords($geoip->latitude, $geoip->longitude, $im_size_x, $im_size_y);
 }
 /*****************************************************************/
 //Map Forms
 /*****************************************************************/
 if ($create_map == "subscriptions") {
     $map_earth_filename_sub = "map_earth_user_subscriptions.jpg";
     $map_filename_sub = "map_user_subscriptions.png";
     //punkte markieren
     #$FORMULAR->makeMap($im_map_user,$gi,0,$im_size_x,$im_size_y);
     $FORMULAR->makeMap($im_earthmap, $gi, 0, $im_size_x, $im_size_y);
     $map_text = ___("Geographische Verteilung der Anmeldungen") . " " . TM_TODAY;
 }
 /*****************************************************************/
 //Map NL History
 /*****************************************************************/
Example #4
0
        fwrite($stderr, "{$count} ");
    }
    $x1 = $row["sx"];
    $y1 = $row["sy"];
    $x2 = $row["dx"];
    $y2 = $row["dy"];
    $distance = gcPointDistance(array("x" => $x1, "y" => $y1), array("x" => $x2, "y" => $y2));
    if ($distance > $GC_MIN) {
        // Plot great circle curve
        $points = gcPath(array("x" => $x1, "y" => $y1), array("x" => $x2, "y" => $y2), $distance, false);
    } else {
        // Draw straight lines
        $points = straightPath(array("x" => $x1, "y" => $y1), array("x" => $x2, "y" => $y2));
    }
    $oldpt = null;
    foreach ($points as $loc) {
        if ($loc == null) {
            $oldpt = null;
            continue;
        }
        $newpt = getlocationcoords($loc["y"], $loc["x"], $scale_x, $scale_y);
        if ($oldpt) {
            imageline($im, $oldpt["x"], $oldpt["y"], $newpt["x"], $newpt["y"], $yellow);
        }
        $oldpt = $newpt;
    }
}
// Return the map image. We are using a PNG format as it gives better final image quality than a JPG
header("Content-type: image/png");
imagepng($im);
imagedestroy($im);
Example #5
0
    $earthimage = isvalidimage($imagething, $earthimages, $defaultimage);
} else {
    $earthimage = $earthimages[$defaultimage];
}
if (strstr($earthimage, ":")) {
    list($earthimage, , , ) = split(":", $earthimage);
}
// check if we need to run it in css mode
if (!shouldrun($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) {
    list($width, $height) = getimagecoords($earthimages, $earthimage);
    // make sure some coords were found
    if ($values["lat"] == "" || $values["lon"] == "") {
        $display = " ";
        $extracss = "";
    } else {
        list($x, $y) = getlocationcoords($values["lat"], $values["lon"], $width, $height);
        if (isset($HTTP_COOKIE_VARS["atlasprefs"])) {
            list(, , , , $dotname) = split(":", $HTTP_COOKIE_VARS["atlasprefs"]);
            $dotname = clean_param($dotname, PARAM_FILE);
            list($thedot, $dotwidth, $dotheight) = finddot($dotname, $cssdots, $defaultdot);
        } else {
            $dotname = $cssdots[$defaultdot];
            list($dotname, , , ) = split(":", $dotname);
            $dotname = clean_param($dotname, PARAM_FILE);
            list($thedot, $dotwidth, $dotheight) = finddot($dotname, $cssdots, $defaultdot);
        }
        // magical formula for placing the css dot
        $x = $x - floor($dotwidth / 2);
        $y = $y - floor($dotheight / 2);
        $extracss = "<style>\n#dotDiv { padding-left:{$x}; padding-top:{$y}; }\n</style>";
        $display = "<div id=\"dotDiv\"><img width=\"{$dotwidth}\" height=\"{$dotheight}\" src=\"{$thedot}\">";
Example #6
0
 function makeMapWeight(&$img, &$gi, $q_id, $width, $height)
 {
     $Query = "SELECT ip FROM " . TM_TABLE_NL_H . "\n\t\t\t\t\tWHERE siteid='" . TM_SITEID . "'";
     $Query .= " AND ip!='0.0.0.0' AND ip!=''";
     if (check_dbid($q_id)) {
         $Query .= " AND q_id=" . checkset_int($q_id);
     }
     #$Query .=" Limit 10000";
     if ($this->DB->Query($Query)) {
         $max = 0;
         $sum = 0;
         $K[0][0] = 0;
         while ($this->DB->next_Record()) {
             $geoip = geoip_record_by_addr($gi, $this->DB->Record['ip']);
             if (isset($geoip->latitude, $geoip->longitude)) {
                 $pt = getlocationcoords($geoip->latitude, $geoip->longitude, $width, $height);
                 if (isset($K[$pt['x']][$pt['y']])) {
                     $K[$pt['x']][$pt['y']]++;
                     if ($K[$pt['x']][$pt['y']] > $max) {
                         $max = $K[$pt['x']][$pt['y']];
                     }
                 } else {
                     $K[$pt['x']][$pt['y']] = 1;
                 }
                 $sum++;
             }
         }
         //while
         $one_pc = $sum / 100;
         $Color1 = imagecolorallocatealpha($img, 255, 0, 0, 0);
         foreach ($K as $x => $ya) {
             foreach ($ya as $y => $c) {
                 $d = round($c / $one_pc);
                 $r = $d * 5;
                 imagearc($img, $x, $y, $r, $r, 0, 360, $Color1);
             }
         }
     }
     //if query
 }
 function makeMap(&$img, &$gi, $frm_id, $width, $height)
 {
     $Query = "SELECT ip FROM " . TM_TABLE_FRM_S . "\n\t\t\t\t\tWHERE siteid='" . TM_SITEID . "'";
     $Query .= " AND ip!='0.0.0.0' AND ip!=''";
     if (check_dbid($frm_id)) {
         $Query .= " AND frm_id=" . checkset_int($frm_id);
     }
     if ($this->DB->Query($Query)) {
         $Color1 = imagecolorallocate($img, 255, 255, 0);
         $Color2 = imagecolorallocate($img, 255, 0, 0);
         while ($this->DB->next_Record()) {
             $geoip = geoip_record_by_addr($gi, $this->DB->Record['ip']);
             if (isset($geoip->latitude, $geoip->longitude)) {
                 $pt = getlocationcoords($geoip->latitude, $geoip->longitude, $width, $height);
                 imagefilledrectangle($img, $pt["x"] - 1, $pt["y"] - 1, $pt["x"] + 1, $pt["y"] + 1, $Color1);
                 imagerectangle($img, $pt["x"] - 4, $pt["y"] - 4, $pt["x"] + 4, $pt["y"] + 4, $Color2);
             }
         }
         //while
     }
     //if query
 }
    $r = "0";
    $g = "225";
    $b = "0";
} elseif ($setcolor == "violet") {
    $r = "191";
    $g = "0";
    $b = "255";
} else {
    $r = "255";
    $g = "0";
    $b = "0";
}
$loc_color = ImageColorAllocate($im, $r, $g, $b);
if ($lat == "" && $lon == "") {
} else {
    list($x, $y) = getlocationcoords($lat, $lon, $width, $height);
    if ($setshape == "Diamond") {
        ImageLine($im, $x - $setsize, $y, $x, $y + $setsize, $loc_color);
        ImageLine($im, $x - $setsize, $y, $x, $y - $setsize, $loc_color);
        ImageLine($im, $x + $setsize, $y, $x, $y + $setsize, $loc_color);
        ImageLine($im, $x + $setsize, $y, $x, $y - $setsize, $loc_color);
        ImageFill($im, $x, $y, $loc_color);
    } elseif ($setshape == "Diamond Outline") {
        ImageLine($im, $x - $setsize, $y, $x, $y + $setsize, $loc_color);
        ImageLine($im, $x - $setsize, $y, $x, $y - $setsize, $loc_color);
        ImageLine($im, $x + $setsize, $y, $x, $y + $setsize, $loc_color);
        ImageLine($im, $x + $setsize, $y, $x, $y - $setsize, $loc_color);
    } elseif ($setshape == "Square") {
        ImageFilledRectangle($im, $x - $setsize, $y - $setsize, $x + $setsize, $y + $setsize, $loc_color);
    } elseif ($setshape == "Square Outline") {
        ImageRectangle($im, $x - $setsize, $y - $setsize, $x + $setsize, $y + $setsize, $loc_color);