[Mapserver-users] Mapfile creation ?

Tommy tommy at dotgamers.com
Sat Dec 6 22:14:07 PST 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> </DIV>
<DIV><FONT face=Arial size=2>This code below is work :</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </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> </DIV>
<DIV><FONT face=Arial size=2>WEB<BR> IMAGEPATH 
"D:/wwwroot/html/mapdki-rosa/htdocs/ms_tmp/"<BR> IMAGEURL 
"/mapdki-rosa/htdocs/ms_tmp/"<BR>END</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>LAYER<BR>  NAME "City"<BR>  TYPE 
POLYGON<BR>  STATUS ON<BR>  DATA "city_adm"<BR>  <BR>  
CLASS<BR>    NAME "City"<BR>  OUTLINECOLOR 128 128 
128<BR>    COLOR 255 234 190<BR>  
END<BR>END<BR>END</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>--- index.php ---</FONT></DIV>
<DIV><FONT face=Arial size=2><?<BR>dl('php_mapscript.dll');</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>$map_path = 
"D:/wwwroot/html/mapdki-rosa/data/map/";<BR>$map_file = "main.map";</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>$newMap = 
ms_newMapObj($map_path.$map_file);</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>$image = $newMap->draw();<BR>$image_url = 
$image->saveWebImage();<BR>?></FONT></DIV>
<DIV><FONT face=Arial size=2><applet name="imgA" 
archive="../etc/rosa_png.jar" code="Rosa2000" 
width="<?=$newMap->width;?>" height="<?=$newMap->height;?>" 
mayscript><BR>    <param name="IMG_URL" 
value="<?=$image_url;?>"></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>     <param 
name="INP_FORM_NAME" value="mapdki"><BR>    <param 
name="INP_TYPE_NAME" value="INPUT_TYPE"><BR>    <param 
name="INP_COORD_NAME" 
value="INPUT_COORD"><BR></applet><BR></FONT></DIV>
<DIV><FONT face=Arial size=2> </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 & class part on the 
original mapfile, but it doesn't work. </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </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> </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> </DIV>
<DIV><FONT face=Arial size=2>WEB<BR> IMAGEPATH 
"D:/wwwroot/html/mapdki-rosa/htdocs/ms_tmp/"<BR> IMAGEURL 
"/mapdki-rosa/htdocs/ms_tmp/"<BR>END</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>#LAYER<BR>#  NAME "City"<BR>#  TYPE 
POLYGON<BR>#  STATUS ON<BR>#  DATA 
"city_adm"<BR>#  <BR>#  CLASS<BR>#    NAME 
"City"<BR>#  OUTLINECOLOR 128 128 128<BR>#    COLOR 255 
234 190<BR>#  END<BR>#END<BR>#END</FONT></DIV>
<DIV> </DIV>
<DIV>
<DIV><FONT face=Arial size=2>--- index.php ---</FONT></DIV>
<DIV><FONT face=Arial size=2><?<BR>dl('php_mapscript.dll');</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>$map_path = 
"D:/wwwroot/html/mapdki-rosa/data/map/";<BR>$map_file = 
"main2.map";</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>$newMap = 
ms_newMapObj($map_path.$map_file);</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV>$newLayer = ms_newLayerObj($newMap);<BR>$newLayer->set("name", 
"City");<BR>$newLayer->set("type", 
MS_LAYER_POLYGON);<BR>$newLayer->set("data", 
"city_adm");<BR>$newLayer->set("status", MS_ON);</DIV>
<DIV> </DIV>
<DIV>$newClass = ms_newClassObj($newLayer);<BR>$newClass->set("name", 
"City");</DIV>
<DIV> </DIV>
<DIV>$newStyle = 
ms_newStyleObj($newClass);<BR>$newStyle->color->setRGB(255, 234, 
190);<BR>$newStyle->outlinecolor->setRGB(128, 128, 128);</DIV>
<DIV> </DIV>
<DIV>$newClass->getStyle(0);</DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>$image = $newMap->draw();<BR>$image_url = 
$image->saveWebImage();<BR>?></FONT></DIV>
<DIV><FONT face=Arial size=2><applet name="imgA" 
archive="../etc/rosa_png.jar" code="Rosa2000" 
width="<?=$newMap->width;?>" height="<?=$newMap->height;?>" 
mayscript><BR>    <param name="IMG_URL" 
value="<?=$image_url;?>"></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>     <param 
name="INP_FORM_NAME" value="mapdki"><BR>    <param 
name="INP_TYPE_NAME" value="INPUT_TYPE"><BR>    <param 
name="INP_COORD_NAME" value="INPUT_COORD"><BR></applet></FONT></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>Thanks in advance.</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>-- Tommy --</DIV></DIV></DIV></FONT></BODY></HTML>

--Boundary_(ID_ArXx0FyLEB4H1kjXNV82Gw)--



More information about the MapServer-users mailing list