[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 10:39:45 EST 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>&nbsp;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>&nbsp;<B><I>YC Nyon &lt;ycnyon at pd.jaring.my&gt;</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>&nbsp;&nbsp; SIZEUNITS meters<BR>&nbsp; TRANSPARENCY 50<BR>&nbsp; CLASS<BR>&nbsp;&nbsp;&nbsp; SIZE 100<BR>&nbsp;&nbsp;&nbsp; NAME 'transcircle'<BR>&nbsp;&nbsp;&nbsp; SYMBOL 'transcircle'<BR>&nbsp;&nbsp;&nbsp; COLOR 0 0 255<BR>&nbsp;&nbsp; END<BR>END</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</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>&nbsp; NAME 'transcircle'<BR>&nbsp; TYPE ELLIPSE<BR>&nbsp; POINTS 1 1 END<BR>&nbsp; FILLED TRUE<BR>END</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</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>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;GLOBAL $shpFile, $dbfFile;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Create shape<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;$oShp = ms_newShapeObj(MS_SHP_POINT);<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;$oLine = ms_newLineObj();<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;$oLine-&gt;addXY($x, $y);<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;$oShp-&gt;add( $oLine );<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;$shpFile-&gt;addShape($oShp);</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;// Write attribute record<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;dbase_add_record($dbfFile, array($programId));<BR>&nbsp;&nbsp;&nbsp;}</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp;$shpFname = "c:\web\test\proximity";<BR>&nbsp;&nbsp;&nbsp;$shpFile = ms_newShapeFileObj( $shpFname, MS_SHP_POINT);<BR>&nbsp;&nbsp;&nbsp;$dbfFile = dbase_create( $shpFname.".dbf", array(array("ID", "N", 5, 0)));</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp;createPoint($real_geo_width, $real_geo_height, 1);<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;//----------------------------------------------------------<BR>&nbsp;&nbsp;&nbsp;// done... cleanup<BR>&nbsp;&nbsp;&nbsp;//----------------------------------------------------------<BR>&nbsp;&nbsp;&nbsp;$shpFile-&gt;free();<BR>&nbsp;&nbsp;&nbsp;dbase_close($dbfFile);</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;// Set the buffer distance &nbsp;<BR>&nbsp;&nbsp;&nbsp;$pt_layer = $map-&gt;getLayerByName("proximity");<BR>&nbsp;&nbsp;&nbsp;$pt_layer-&gt;set("status", 1);<BR>&nbsp;&nbsp;&nbsp;$pt_class = $pt_layer-&gt;getclass(0);<BR>&nbsp;&nbsp;&nbsp;$pt_class-&gt;set("size", 500);</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</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>&lt;?php<BR>dl("php_mapscript_37.dll");</P>
<P>$map = ms_newMapObj("try1.map");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>function Cal($x,$y,$radius)<BR>{<BR>&nbsp;<BR>&nbsp;$lineObj = ms_newLineObj();<BR>&nbsp;for ($i=0 ; $i &lt;=360 ;$i = $i +10)<BR>&nbsp;{<BR>&nbsp;&nbsp;$angulo = deg2rad($i);<BR>&nbsp;&nbsp;$xcal = $x + ($radius*cos($angulo));<BR>&nbsp;&nbsp;$ycal = $y + ($radius*sin($angulo));<BR>&nbsp;&nbsp;$lineObj-&gt;addXY($xcal,$ycal);<BR>&nbsp;}<BR>&nbsp;return($lineObj);<BR>}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>$array=$map-&gt;getAllLayerNames();<BR>$p= ms_newpointObj();<BR>$circle= ms_newshapeObj(MS_LINE);<BR>$line= ms_newlineObj();<BR>$layer = $map-&gt;getLayerByName('Circle');<BR>$class = $layer-&gt;getClass(0);<BR>$image = $map-&gt;draw();</P>
<P>$x=200;<BR>$y=200;<BR>$radius = 50;<BR>$line = Cal($x,$y,$radius);<BR>$test=$circle-&gt;add($line);<BR>$test1=$circle-&gt;draw($map,$layer,$image,undef,"damage");<BR>var_dump($line);<BR>var_dump($test);<BR>var_dump($test1);<BR>$image_url = $image-&gt;saveWebImage(MS_GIF,1,1,0);<BR>?&gt;<BR>//end code </P>
<P>comments: the line show the $line-&gt;numpoints member containing the appropriate number of points. However for the $circle-&gt;add($line) the result returns int(0). I suppose that the process failed. Also, for the $test1=$circle-&gt;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>&nbsp;</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>&nbsp;</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>&nbsp;</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