[Mapserver-users] Mapfile creation ?

Tommy tommy at dotgamers.com
Sun Dec 7 01:14:07 EST 2003


This is a multi-part message in MIME format.

--Boundary_(ID_ArXx0FyLEB4H1kjXNV82Gw)
Content-type: text/plain; charset=iso-8859-1
Content-transfer-encoding: 7BIT

I use PHP 4.3.2 on Apache 1.3.29 run on Windows XP. With Mapserver (mapserver-4.0-win32-php4.3.2.zip)
and Rosa installed too.

This code below is work :

--- main.map ---
NAME DEMO
SIZE 610 530
STATUS OFF
EXTENT 29100.00000 32500.00000 68500.00000 55000.00000
UNITS METERS
SYMBOLSET "../../symbols/symbols.sym"
SHAPEPATH "../"
FONTSET "../../symbols/fonts.txt"

WEB
 IMAGEPATH "D:/wwwroot/html/mapdki-rosa/htdocs/ms_tmp/"
 IMAGEURL "/mapdki-rosa/htdocs/ms_tmp/"
END

LAYER
  NAME "City"
  TYPE POLYGON
  STATUS ON
  DATA "city_adm"
  
  CLASS
    NAME "City"
  OUTLINECOLOR 128 128 128
    COLOR 255 234 190
  END
END
END

--- index.php ---
<?
dl('php_mapscript.dll');

$map_path = "D:/wwwroot/html/mapdki-rosa/data/map/";
$map_file = "main.map";

$newMap = ms_newMapObj($map_path.$map_file);

$image = $newMap->draw();
$image_url = $image->saveWebImage();
?>
<applet name="imgA" archive="../etc/rosa_png.jar" code="Rosa2000" width="<?=$newMap->width;?>" height="<?=$newMap->height;?>" mayscript>
    <param name="IMG_URL" value="<?=$image_url;?>">

     <param name="INP_FORM_NAME" value="mapdki">
    <param name="INP_TYPE_NAME" value="INPUT_TYPE">
    <param name="INP_COORD_NAME" value="INPUT_COORD">
</applet>


Now, I think, is it possible to create the mapfile (layer and class part) dynamically (on the fly) ? I use this below code, 
disabling the layer & class part on the original mapfile, but it doesn't work. 

Can anybody tell me why ? And how to make this works ?

--- main.map ---
NAME DEMO
SIZE 610 530
STATUS OFF
EXTENT 29100.00000 32500.00000 68500.00000 55000.00000
UNITS METERS
SYMBOLSET "../../symbols/symbols.sym"
SHAPEPATH "../"
FONTSET "../../symbols/fonts.txt"

WEB
 IMAGEPATH "D:/wwwroot/html/mapdki-rosa/htdocs/ms_tmp/"
 IMAGEURL "/mapdki-rosa/htdocs/ms_tmp/"
END

#LAYER
#  NAME "City"
#  TYPE POLYGON
#  STATUS ON
#  DATA "city_adm"
#  
#  CLASS
#    NAME "City"
#  OUTLINECOLOR 128 128 128
#    COLOR 255 234 190
#  END
#END
#END

--- index.php ---
<?
dl('php_mapscript.dll');

$map_path = "D:/wwwroot/html/mapdki-rosa/data/map/";
$map_file = "main2.map";

$newMap = ms_newMapObj($map_path.$map_file);

$newLayer = ms_newLayerObj($newMap);
$newLayer->set("name", "City");
$newLayer->set("type", MS_LAYER_POLYGON);
$newLayer->set("data", "city_adm");
$newLayer->set("status", MS_ON);

$newClass = ms_newClassObj($newLayer);
$newClass->set("name", "City");

$newStyle = ms_newStyleObj($newClass);
$newStyle->color->setRGB(255, 234, 190);
$newStyle->outlinecolor->setRGB(128, 128, 128);

$newClass->getStyle(0);

$image = $newMap->draw();
$image_url = $image->saveWebImage();
?>
<applet name="imgA" archive="../etc/rosa_png.jar" code="Rosa2000" width="<?=$newMap->width;?>" height="<?=$newMap->height;?>" mayscript>
    <param name="IMG_URL" value="<?=$image_url;?>">

     <param name="INP_FORM_NAME" value="mapdki">
    <param name="INP_TYPE_NAME" value="INPUT_TYPE">
    <param name="INP_COORD_NAME" value="INPUT_COORD">
</applet>


Thanks in advance.


-- Tommy --

--Boundary_(ID_ArXx0FyLEB4H1kjXNV82Gw)
Content-type: text/html; charset=iso-8859-1
Content-transfer-encoding: 7BIT

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1276" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>I use PHP 4.3.2 on Apache 1.3.29 run on Windows XP. 
With Mapserver (mapserver-4.0-win32-php4.3.2.zip)</FONT></DIV>
<DIV><FONT face=Arial size=2>and Rosa installed too.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>This code below is work :</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>--- main.map ---</FONT></DIV>
<DIV><FONT face=Arial size=2>NAME DEMO<BR>SIZE 610 530<BR>STATUS OFF<BR>EXTENT 
29100.00000 32500.00000 68500.00000 55000.00000<BR>UNITS METERS<BR>SYMBOLSET 
"../../symbols/symbols.sym"<BR>SHAPEPATH "../"<BR>FONTSET 
"../../symbols/fonts.txt"</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>WEB<BR>&nbsp;IMAGEPATH 
"D:/wwwroot/html/mapdki-rosa/htdocs/ms_tmp/"<BR>&nbsp;IMAGEURL 
"/mapdki-rosa/htdocs/ms_tmp/"<BR>END</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>LAYER<BR>&nbsp; NAME "City"<BR>&nbsp; TYPE 
POLYGON<BR>&nbsp; STATUS ON<BR>&nbsp; DATA "city_adm"<BR>&nbsp;&nbsp;<BR>&nbsp; 
CLASS<BR>&nbsp;&nbsp;&nbsp; NAME "City"<BR>&nbsp;&nbsp;OUTLINECOLOR 128 128 
128<BR>&nbsp;&nbsp;&nbsp; COLOR 255 234 190<BR>&nbsp; 
END<BR>END<BR>END</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>--- index.php ---</FONT></DIV>
<DIV><FONT face=Arial size=2>&lt;?<BR>dl('php_mapscript.dll');</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>$map_path = 
"D:/wwwroot/html/mapdki-rosa/data/map/";<BR>$map_file = "main.map";</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>$newMap = 
ms_newMapObj($map_path.$map_file);</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>$image = $newMap-&gt;draw();<BR>$image_url = 
$image-&gt;saveWebImage();<BR>?&gt;</FONT></DIV>
<DIV><FONT face=Arial size=2>&lt;applet name="imgA" 
archive="../etc/rosa_png.jar" code="Rosa2000" 
width="&lt;?=$newMap-&gt;width;?&gt;" height="&lt;?=$newMap-&gt;height;?&gt;" 
mayscript&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;param name="IMG_URL" 
value="&lt;?=$image_url;?&gt;"&gt;</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp;&nbsp; &lt;param 
name="INP_FORM_NAME" value="mapdki"&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;param 
name="INP_TYPE_NAME" value="INPUT_TYPE"&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;param 
name="INP_COORD_NAME" 
value="INPUT_COORD"&gt;<BR>&lt;/applet&gt;<BR></FONT></DIV>
<DIV><FONT face=Arial size=2>&nbsp;</DIV></FONT>
<DIV><FONT face=Arial size=2>Now, I think, is it possible to create the mapfile 
(layer and class part) dynamically (on the fly) ? </FONT><FONT face=Arial 
size=2>I use this below code, </FONT></DIV>
<DIV><FONT face=Arial size=2>disabling the layer &amp; class part on the 
original mapfile, but it doesn't work. </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Can anybody tell me why ? And how to make this 
works ?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>
<DIV><FONT face=Arial size=2>--- main.map ---</FONT></DIV>
<DIV><FONT face=Arial size=2>NAME DEMO<BR>SIZE 610 530<BR>STATUS OFF<BR>EXTENT 
29100.00000 32500.00000 68500.00000 55000.00000<BR>UNITS METERS<BR>SYMBOLSET 
"../../symbols/symbols.sym"<BR>SHAPEPATH "../"<BR>FONTSET 
"../../symbols/fonts.txt"</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>WEB<BR>&nbsp;IMAGEPATH 
"D:/wwwroot/html/mapdki-rosa/htdocs/ms_tmp/"<BR>&nbsp;IMAGEURL 
"/mapdki-rosa/htdocs/ms_tmp/"<BR>END</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>#LAYER<BR>#&nbsp; NAME "City"<BR>#&nbsp; TYPE 
POLYGON<BR>#&nbsp; STATUS ON<BR>#&nbsp; DATA 
"city_adm"<BR>#&nbsp;&nbsp;<BR>#&nbsp; CLASS<BR>#&nbsp;&nbsp;&nbsp; NAME 
"City"<BR>#&nbsp;&nbsp;OUTLINECOLOR 128 128 128<BR>#&nbsp;&nbsp;&nbsp; COLOR 255 
234 190<BR>#&nbsp; END<BR>#END<BR>#END</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>
<DIV><FONT face=Arial size=2>--- index.php ---</FONT></DIV>
<DIV><FONT face=Arial size=2>&lt;?<BR>dl('php_mapscript.dll');</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>$map_path = 
"D:/wwwroot/html/mapdki-rosa/data/map/";<BR>$map_file = 
"main2.map";</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>$newMap = 
ms_newMapObj($map_path.$map_file);</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV>$newLayer = ms_newLayerObj($newMap);<BR>$newLayer-&gt;set("name", 
"City");<BR>$newLayer-&gt;set("type", 
MS_LAYER_POLYGON);<BR>$newLayer-&gt;set("data", 
"city_adm");<BR>$newLayer-&gt;set("status", MS_ON);</DIV>
<DIV>&nbsp;</DIV>
<DIV>$newClass = ms_newClassObj($newLayer);<BR>$newClass-&gt;set("name", 
"City");</DIV>
<DIV>&nbsp;</DIV>
<DIV>$newStyle = 
ms_newStyleObj($newClass);<BR>$newStyle-&gt;color-&gt;setRGB(255, 234, 
190);<BR>$newStyle-&gt;outlinecolor-&gt;setRGB(128, 128, 128);</DIV>
<DIV>&nbsp;</DIV>
<DIV>$newClass-&gt;getStyle(0);</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>$image = $newMap-&gt;draw();<BR>$image_url = 
$image-&gt;saveWebImage();<BR>?&gt;</FONT></DIV>
<DIV><FONT face=Arial size=2>&lt;applet name="imgA" 
archive="../etc/rosa_png.jar" code="Rosa2000" 
width="&lt;?=$newMap-&gt;width;?&gt;" height="&lt;?=$newMap-&gt;height;?&gt;" 
mayscript&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;param name="IMG_URL" 
value="&lt;?=$image_url;?&gt;"&gt;</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp;&nbsp; &lt;param 
name="INP_FORM_NAME" value="mapdki"&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;param 
name="INP_TYPE_NAME" value="INPUT_TYPE"&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;param 
name="INP_COORD_NAME" value="INPUT_COORD"&gt;<BR>&lt;/applet&gt;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>Thanks in advance.</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>-- Tommy --</DIV></DIV></DIV></FONT></BODY></HTML>

--Boundary_(ID_ArXx0FyLEB4H1kjXNV82Gw)--



More information about the mapserver-users mailing list