~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
Don't make me tell you again.
pickle wrote:I'd need to see the graphing function to help at all, but it's likely one of two things.
1) The data you're getting isn't what you think it is. Output the data (rather than plotting it into the image) & verify it makes sense.
2) Somewhere in your graphing function you're either a) drawing a big black line, or b) not covering the entire image with your background image. The default colour for images created with GD is black, so it might just be some background showing through. Are your points being plotted in black? Change it to another colour temporarily - if the line stays black it's probably not your graphing function, but rather the background.
hi..........
i have checked there is no background color drawing by default and also i am ploting graph in red color. Black color is not at all involved.
when i am defining the constants in this range
Code: Select all
ie.
define("MINLAT", 40);
define("MAXLAT", 2240717);
define("MINLONG", 4783280);
define("MAXLONG", 9262288);
define("GRIDSIZE", 10);
the black border does not come ,
but when i give in this range
Code: Select all
define("MINLAT", -1288000);
define("MAXLAT", 2297000);
define("MINLONG", 4000000);
define("MAXLONG", 9990000);
define("GRIDSIZE", 10);
the thick black border form because of this border the scale of the graph gets hide .
is the problem with range which i am defining
And also when i am ploting graph with
imagefilledarc() ; function, the function of it is in integer and my values stored is in lakhs ie. it is crossing the integer limits so, is it because of it
below is my code
Code: Select all
<?php
//define constants
define("MAPFILE","testmap.png");
define("MINX",0);
define("MAXX",699+MINX);
define("MINY", 0);
define("MAXY", 419+MINY);
define("MINLAT", -1288000);
define("MAXLAT", 2297000);
define("MINLONG", 4000000);
define("MAXLONG", 9990000);
define("GRIDSIZE", 10);
/**no black border
define("MINLAT", 40);
define("MAXLAT", 2240717);
define("MINLONG", 4783280);
define("MAXLONG", 9262288);
define("GRIDSIZE", 10);
**/
if(trim($minLat)=="") $minLat=MINLAT;
if(trim($maxLat)=="") $maxLat=MAXLAT;
if(trim($minLong)=="") $minLong=MINLONG;
if(trim($maxLong)=="") $maxLong=MAXLONG;
function getPixelValueofLat($l)
{
$scaleY = (MAXY - MINY)/(MAXLAT - MINLAT);
$LAT_PIXEL = round(MINY + (MAXLAT - $l) * $scaleY);
return $LAT_PIXEL;
}
function getPixelValueofLong($l)
{
$scaleX = (MAXX - MINX)/( MAXLONG - MINLONG);
$LONG_PIXEL = round(MINX + ($l - MINLONG) * $scaleX);
return $LONG_PIXEL;
}
$im=imagecreatefrompng(MAPFILE);
//$background = imagecolorallocate($im, 150, 200, 255);
//$background = imagecolorallocate($im, 255, 255, 255);
//$background = imagecolorallocate($im,102, 102, 102);
//imagestring ($im, 1, 5, 5, "A Simple Text String", $text_color);
// output image in the browser
$red=imagecolorallocate($im, 255, 0, 0);
$green=imagecolorallocate($im, 0, 255, 0);
$darkgreen=imagecolorallocate($im, 105, 155, 160);
$darkgray=imagecolorallocate($im, 102, 102, 102);
$blue=imagecolorallocate($im, 0, 0, 255);
$black=imagecolorallocate($im, 0, 0, 0);
$linecolour=$darkgray;
$str="(".getPixelValueofLat(-90)." ,".getPixelValueofLong(180).")";
imageline ( $im, MINX, MINY, MAXX, MINY, $darkgreen );
imageline ( $im, MINX, MINY, MINX, MAXY, $darkgreen );
imageline ( $im, MINX, MAXY, MAXX, MAXY, $darkgreen );
imageline ( $im, MAXX, MINY, MAXX, MAXY, $darkgreen );
$text_color = $black;
$font_size=2;
for($i = 0 ; $i <= ((MAXLONG-MINLONG)/GRIDSIZE); $i++)
{
$lo=(MINLONG-(MINLONG-((MINLONG%GRIDSIZE)*GRIDSIZE)))+$i*GRIDSIZE;
if($lo < 0 )
{
$s="- ".($lo*-1);
}
else if($lo == 0 )
{
$s=" ".$lo;
}
else
{
$s="+ ".$lo;
}
$xcord=getPixelValueofLong($lo);
imagestringup($im, $font_size, $xcord-6, MINY-8, $s , $linecolour);
imageline ( $im, $xcord, MINY, $xcord, MAXY, $drakgray);
}
for($j = 0 ; $j <= ((MAXLAT-MINLAT)/GRIDSIZE) ; $j++)
{
$la=(MAXLAT-(MAXLAT-((MAXLAT%GRIDSIZE)*GRIDSIZE)))-$j*GRIDSIZE;
if($la < 0 )
{
$s="- ".($la*-1);
}
else if($la == 0 )
{
$s=" ".$la;
}
else
{
$s="+ ".$la;
}
$ycord=getPixelValueofLat($la);
imagestring($im, $font_size, 7, $ycord-7, str_pad($s,5, " ",STR_PAD_LEFT) , $linecolour);
imageline ($im, MINX, $ycord, MAXX, $ycord, $drakgray);
}
// header("Content-type: image/png");
//Output graph and clear image from memory
// imagepng($im);
?>
//----------------------------------------------------------------------------------------------------
//graph.php
<?php
include_once("connect_db.php");
include_once("map.php");
header("Content-type: image/png");
$colorRed=imagecolorallocate($im, 255, 0, 0);
//query to take values plot graph
$minLat=$_GET["minLat"];
//echo "minlat".$minLat."<br>";
$maxLat=$_GET["maxLat"];
//echo "maxlat".$maxLat."<br>";
$minLong=$_GET["minLong"];
//echo "minlong".$minLong."<br>";
$maxLong=$_GET["maxLong"];
//echo "maxlong".$maxLong."<br>";
$query="select distinct LATITUDE,LONGITUDE from tablename where LATITUDE >= $minLat and LATITUDE <= $maxLat and LONGITUDE >= $minLong and LONGITUDE <= $maxLong";
//echo "query".$query."<br>";
$result = mysql_query($query,$link);
$lat0="";
$lon0="";
$dotSize=2;
while($row = mysql_fetch_array($result))
{
$lat1=getPixelValueofLat($row[0]);
$lon1=getPixelValueofLong($row[1]);
if($lat0<>"" and $lon0<>"")
{
imagefilledarc($im,$lon1,$lat1, $dotSize, $dotSize, 0, 360, $colorRed, IMG_ARC_PIE);
}
$lat0=getPixelValueofLat($row[0]);
$lon0=getPixelValueofLong($row[1]);
}
// Output graph and clear image from memory
imagepng($im);
imagedestroy($im);
mysql_free_result($result);
?>
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.