[Mapserver-users] ProBlem Drawing a Line(circle) AS a second Layer on top the first Layer
Terrence Lalla
t_lalla20 at yahoo.com
Sat Feb 8 07:39:45 PST 2003
--0-1751218456-1044718785=:30844
Content-Type: text/plain; charset=us-ascii
Hello
Thanks for the help YC Nyon.
However, I am not getting this to work. Can you explain a bit about the $programId variable's purpose and the what the database record is suppose to do with only one field.
Also I believe the $shpFile =ms_newShapeFileObj($shpFname,MS_SHP_POINT) line is causing the php interpreter to crash when i uncomment this line of code.
Another thing, when i uncomment the above line of code, i cannot create the database. Is Something wrong the dbase_create statement.
Thank in advance. Your help is greatly appreciated.
Terrence.
YC Nyon <ycnyon at pd.jaring.my> wrote:use a point feature with a size valueMap file:LAYER
NAME "proximity"
data proximity
STATUS off
TYPE POINT
SIZEUNITS meters
TRANSPARENCY 50
CLASS
SIZE 100
NAME 'transcircle'
SYMBOL 'transcircle'
COLOR 0 0 255
END
END SYMBOL #########:SYMBOL
NAME 'transcircle'
TYPE ELLIPSE
POINTS 1 1 END
FILLED TRUE
END PHP CODE:########function createPoint( $x, $y, $programId )
{
GLOBAL $shpFile, $dbfFile;
// Create shape
$oShp = ms_newShapeObj(MS_SHP_POINT);
$oLine = ms_newLineObj();
$oLine->addXY($x, $y);
$oShp->add( $oLine );
$shpFile->addShape($oShp); // Write attribute record
dbase_add_record($dbfFile, array($programId));
} $shpFname = "c:\web\test\proximity";
$shpFile = ms_newShapeFileObj( $shpFname, MS_SHP_POINT);
$dbfFile = dbase_create( $shpFname.".dbf", array(array("ID", "N", 5, 0))); createPoint($real_geo_width, $real_geo_height, 1);
//----------------------------------------------------------
// done... cleanup
//----------------------------------------------------------
$shpFile->free();
dbase_close($dbfFile);
// Set the buffer distance
$pt_layer = $map->getLayerByName("proximity");
$pt_layer->set("status", 1);
$pt_class = $pt_layer->getclass(0);
$pt_class->set("size", 500); 500 is the radius/diameter (can't remember which one) value ----- Original Message ----- From: Terrence Lalla To: users Sent: Friday, February 07, 2003 8:14 AMSubject: [Mapserver-users] ProBlem Drawing a Line(circle) AS a second Layer on top the first Layer
Hello all,
// the code
<?php
dl("php_mapscript_37.dll");
$map = ms_newMapObj("try1.map");
function Cal($x,$y,$radius)
{
$lineObj = ms_newLineObj();
for ($i=0 ; $i <=360 ;$i = $i +10)
{
$angulo = deg2rad($i);
$xcal = $x + ($radius*cos($angulo));
$ycal = $y + ($radius*sin($angulo));
$lineObj->addXY($xcal,$ycal);
}
return($lineObj);
}
$array=$map->getAllLayerNames();
$p= ms_newpointObj();
$circle= ms_newshapeObj(MS_LINE);
$line= ms_newlineObj();
$layer = $map->getLayerByName('Circle');
$class = $layer->getClass(0);
$image = $map->draw();
$x=200;
$y=200;
$radius = 50;
$line = Cal($x,$y,$radius);
$test=$circle->add($line);
$test1=$circle->draw($map,$layer,$image,undef,"damage");
var_dump($line);
var_dump($test);
var_dump($test1);
$image_url = $image->saveWebImage(MS_GIF,1,1,0);
?>
//end code
comments: the line show the $line->numpoints member containing the appropriate number of points. However for the $circle->add($line) the result returns int(0). I suppose that the process failed. Also, for the $test1=$circle->draw($map,$layer,$image,undef,"damage") the result returns int(0). Hence the circle layer is not drawn on top the first layer.
//mapscript code
NAME Trinidad
EXTENT 606030.98 1108051.15 739443.72 1201934.19
SIZE 400 400
UNITS METERS
SHAPEPATH "data"
WEB
IMAGEPATH "c:\apache\htdocs\tmp\"
IMAGEURL "\tmp\"
END
LAYER
NAME "Coastline1"
DATA coastline1
STATUS ON
TYPE line
CLASS
COLOR 220 220 220
OUTLINECOLOR 100 100 100
END
END
LAYER
NAME "Circle"
STATUS on
TYPE Point
CLASS
COLOR 220 220 220
OUTLINECOLOR 100 100 100
END
END
END
//end mapscript code.
Can anyone suggest a possible solution to the problem ?
Also for the x,y, and radius values should I use pixel coordinates or georef coordinates for the map?
Thanks in Advance.
Terrence
---------------------------------
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.443 / Virus Database: 248 - Release Date: 10/01/2003
---------------------------------
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now
--0-1751218456-1044718785=:30844
Content-Type: text/html; charset=us-ascii
<P>Hello
<P>Thanks for the help YC Nyon.
<P> However, I am not getting this to work. Can you explain a bit about the $programId variable's purpose and the what the database record is suppose to do with only one field.
<P>Also I believe the $shpFile =ms_newShapeFileObj($shpFname,MS_SHP_POINT) line is causing the php interpreter to crash when i uncomment this line of code.
<P>Another thing, when i uncomment the above line of code, i cannot create the database. Is Something wrong the dbase_create statement.
<P>Thank in advance. Your help is greatly appreciated.
<P>Terrence.
<P> <B><I>YC Nyon <ycnyon at pd.jaring.my></I></B> wrote:
<BLOCKQUOTE style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">
<META content="MSHTML 6.00.2800.1106" name=GENERATOR>
<STYLE></STYLE>
<DIV><FONT face=Arial size=2>use a point feature with a size value</FONT></DIV>
<DIV><FONT face=Arial size=2>Map file:</FONT></DIV>
<DIV><FONT face=Arial size=2>LAYER<BR>NAME "proximity" <BR>data proximity<BR>STATUS off<BR>TYPE POINT<BR> SIZEUNITS meters<BR> TRANSPARENCY 50<BR> CLASS<BR> SIZE 100<BR> NAME 'transcircle'<BR> SYMBOL 'transcircle'<BR> COLOR 0 0 255<BR> END<BR>END</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>SYMBOL </FONT></DIV>
<DIV><FONT face=Arial size=2>#########:</FONT></DIV>
<DIV><FONT face=Arial size=2>SYMBOL<BR> NAME 'transcircle'<BR> TYPE ELLIPSE<BR> POINTS 1 1 END<BR> FILLED TRUE<BR>END</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>PHP CODE:</FONT></DIV>
<DIV><FONT face=Arial size=2>########</FONT></DIV>
<DIV><FONT face=Arial size=2>function createPoint( $x, $y, $programId )<BR> {<BR> GLOBAL $shpFile, $dbfFile;<BR> // Create shape<BR> $oShp = ms_newShapeObj(MS_SHP_POINT);<BR> $oLine = ms_newLineObj();<BR> $oLine->addXY($x, $y);<BR> $oShp->add( $oLine );<BR> $shpFile->addShape($oShp);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> // Write attribute record<BR> dbase_add_record($dbfFile, array($programId));<BR> }</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> $shpFname = "c:\web\test\proximity";<BR> $shpFile = ms_newShapeFileObj( $shpFname, MS_SHP_POINT);<BR> $dbfFile = dbase_create( $shpFname.".dbf", array(array("ID", "N", 5, 0)));</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> createPoint($real_geo_width, $real_geo_height, 1);<BR> <BR> //----------------------------------------------------------<BR> // done... cleanup<BR> //----------------------------------------------------------<BR> $shpFile->free();<BR> dbase_close($dbfFile);</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> <BR> // Set the buffer distance <BR> $pt_layer = $map->getLayerByName("proximity");<BR> $pt_layer->set("status", 1);<BR> $pt_class = $pt_layer->getclass(0);<BR> $pt_class->set("size", 500);</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>500 is the radius/diameter (can't remember which one) value </FONT></DIV>
<BLOCKQUOTE style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B> <A title=t_lalla20 at yahoo.com href="mailto:t_lalla20 at yahoo.com">Terrence Lalla</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=mapserver-users at lists.gis.umn.edu href="mailto:mapserver-users at lists.gis.umn.edu">users</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Friday, February 07, 2003 8:14 AM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> [Mapserver-users] ProBlem Drawing a Line(circle) AS a second Layer on top the first Layer</DIV>
<DIV><BR></DIV>
<P>Hello all,</P>
<P>// the code</P>
<P><?php<BR>dl("php_mapscript_37.dll");</P>
<P>$map = ms_newMapObj("try1.map");<BR> <BR>function Cal($x,$y,$radius)<BR>{<BR> <BR> $lineObj = ms_newLineObj();<BR> for ($i=0 ; $i <=360 ;$i = $i +10)<BR> {<BR> $angulo = deg2rad($i);<BR> $xcal = $x + ($radius*cos($angulo));<BR> $ycal = $y + ($radius*sin($angulo));<BR> $lineObj->addXY($xcal,$ycal);<BR> }<BR> return($lineObj);<BR>}<BR> <BR>$array=$map->getAllLayerNames();<BR>$p= ms_newpointObj();<BR>$circle= ms_newshapeObj(MS_LINE);<BR>$line= ms_newlineObj();<BR>$layer = $map->getLayerByName('Circle');<BR>$class = $layer->getClass(0);<BR>$image = $map->draw();</P>
<P>$x=200;<BR>$y=200;<BR>$radius = 50;<BR>$line = Cal($x,$y,$radius);<BR>$test=$circle->add($line);<BR>$test1=$circle->draw($map,$layer,$image,undef,"damage");<BR>var_dump($line);<BR>var_dump($test);<BR>var_dump($test1);<BR>$image_url = $image->saveWebImage(MS_GIF,1,1,0);<BR>?><BR>//end code </P>
<P>comments: the line show the $line->numpoints member containing the appropriate number of points. However for the $circle->add($line) the result returns int(0). I suppose that the process failed. Also, for the $test1=$circle->draw($map,$layer,$image,undef,"damage") the result returns int(0). Hence the circle layer is not drawn on top the first layer.</P>
<P> </P>
<P>//mapscript code</P><FONT size=2>
<P>NAME Trinidad</P>
<P>EXTENT 606030.98 1108051.15 739443.72 1201934.19</P>
<P>SIZE 400 400</P>
<P>UNITS METERS</P>
<P>SHAPEPATH "data"</P>
<P>WEB</P>
<P>IMAGEPATH "c:\apache\htdocs\tmp\"</P>
<P>IMAGEURL "\tmp\"</P>
<P>END</P>
<P>LAYER</P>
<P>NAME "Coastline1"</P>
<P>DATA coastline1</P>
<P>STATUS ON</P>
<P>TYPE line</P>
<P>CLASS</P>
<P>COLOR 220 220 220</P>
<P>OUTLINECOLOR 100 100 100</P>
<P>END</P>
<P>END</P>
<P>LAYER</P>
<P>NAME "Circle"</P>
<P>STATUS on</P>
<P>TYPE Point</P>
<P>CLASS</P>
<P>COLOR 220 220 220</P>
<P>OUTLINECOLOR 100 100 100</P>
<P>END</P>
<P>END</P>
<P> </P>
<P>END</P>
<P></FONT>//end mapscript code.</P>
<P>Can anyone suggest a possible solution to the problem ?</P>
<P>Also for the x,y, and radius values should I use pixel coordinates or georef coordinates for the map?</P>
<P>Thanks in Advance.</P>
<P>Terrence<BR></P>
<P><BR>
<DIV>
<HR SIZE=1>
</DIV>
<DIV>Do you Yahoo!?<BR><A href="http://rd.yahoo.com/mail/mailsig/*http://mailplus.yahoo.com">Yahoo! Mail Plus</A> - Powerful. Affordable. <A href="http://rd.yahoo.com/mail/mailsig/*http://mailplus.yahoo.com">Sign up now</A><U><FONT color=#0000ff></FONT></U></DIV>
<DIV> </DIV>
<DIV><U><FONT color=#0000ff><BR>---<BR>Outgoing mail is certified Virus Free.<BR>Checked by AVG anti-virus system (<A href="http://www.grisoft.com/">http://www.grisoft.com</A>).<BR>Version: 6.0.443 / Virus Database: 248 - Release Date: 10/01/2003</FONT></U></DIV></BLOCKQUOTE></BLOCKQUOTE><p><br><hr size=1>Do you Yahoo!?<br>
<a href="http://rd.yahoo.com/mail/mailsig/*http://mailplus.yahoo.com">Yahoo! Mail Plus</a> - Powerful. Affordable. <a href="http://rd.yahoo.com/mail/mailsig/*http://mailplus.yahoo.com">Sign up now</a>
--0-1751218456-1044718785=:30844--
More information about the MapServer-users
mailing list