[Mapserver-users] happiness

Hugo Nathaniel Rodrigues hugo at pbh.gov.br
Fri Jan 9 05:07:51 PST 2004


sure, this is the email i sended to one of the forum users about all my
work:

------------------------------ start
i use two php files, one to make my search (the search screen) and other to
send my results to the map (the result screen)...
this are my files:
my map file:
NAME FIRSTMAP
SIZE 400 300
STATUS ON
EXTENT 598047.223047 781652.733880 619791.428883 812944.406142
UNITS METERS
IMAGECOLOR 255 255 255
SYMBOLSET ../etc/symbols.sym

WEB
IMAGEPATH '/tmp/ms_tmp/'
IMAGEURL '/ms_tmp/'

LOG '/tmp/gmap.log'
END

LAYER
  NAME prov_bound
  CONNECTIONTYPE OGR
  CONNECTION 'mapinfo_files/distrito.tab'
  METADATA
    'DESCRIPTION' 'Province'
  END
  TYPE POLYGON
  STATUS ON
  DATA province
  CLASS
    NAME 'Province'
    OUTLINECOLOR 120 120 120
  END
END

LAYER
  NAME pontomapa
  TRANSFORM TRUE
  STATUS DEFAULT
  TYPE POINT
  CLASS
    SYMBOL 2
    COLOR 0 0 0
    SIZE 8
  END
#  FEATURE
#    POINTS 618579.06 806912.68 END
#  END
END

END

the php search intro file
<?
// Projeto: Pesquisa de XY em php
// Hugo Nathaniel Rodrigues (hugo at pbh.gov.br / hugonr at terra.com.br)
// Consultor SSSS - Prodabel
// Criação deste modulo: 07/01/2004
// Ultima atualizacao: 07/01/2004
// include("config.php");
error_reporting  (E_ERROR | E_PARSE);
if ($btpesquisa != ""){
 $conn=mssql_connect($ServidorBanco,$UsuarioBanco,$SenhaBanco);
 $lbxendereco = "";
 $sql = "SELECT put your fields name here FROM database..table WHERE
STREETNAME LIKE '$rua%' AND TOWNNAME LIKE '$bairro%'";
 $resultado = mssql_query($sql);
 while($registro = mssql_fetch_array($resultado)){
  $lbxendereco = $lbxendereco . "<OPTION VALUE='" . $registro["CODE"] . "'>"
. $registro["TYPE"] . " " . $registro["STREETNAME"] . " - " .
$registro["TOWNTYPE"] . " " . $registro["TOWN"] . "</option>";
 }
 mssql_close();
}

if ($btselecionar != ""){
 if (strlen($numimovel) == 1){
  $numimovel = "0000" . $numimovel;
 }
 if (strlen($numimovel) == 2){
  $numimovel = "000" . $numimovel;
 }
 if (strlen($numimovel) == 3){
  $numimovel = "00" . $numimovel;
 }
 if (strlen($numimovel) == 4){
  $numimovel = "0" . $numimovel;
 }
 $numimovel = $numimovel . strtoupper($letraimovel);
 $conn=mssql_connect($ServidorBanco,$UsuarioBanco,$SenhaBanco);
 $sql = "SELECT Val_Cood_X, Val_Cood_Y FROM put your xy table here WHERE
NUM_IMOV = '$numimovel' AND STREETCODE = $enderecoselecionado";
 $resultado = mssql_query($sql);
 $valorx = mssql_result($resultado,0,"Val_Cood_X");
 $valory = mssql_result($resultado,0,"Val_Cood_Y");
 mssql_close();
}


?>
<html>
<head>
<title>Pesquisa Endereço XY no mapa</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="pesquisaphp.php">
<input type="hidden" name="valorx" value="<? echo $valorx; ?>">
<input type="hidden" name="valory" value="<? echo $valory; ?>">
<input type="hidden" name="r" value="<? echo $r; ?>">
<input type="hidden" name="b" value="<? echo $b; ?>">
<input type="hidden" name="num" value="<? echo $numimovel; ?>">
<script language="JavaScript">
 if (document.forms[0].valorx.value != ""){
  document.forms[0].action =
"http://localhost/pesquisaphp/pesquisaphp.php?pontox=" +
document.forms[0].valorx.value + "&pontoy=" + document.forms[0].valory.value
+ "&rua=" + document.forms[0].r.value + "&bairro=" +
document.forms[0].b.value + "&num=" + document.forms[0].num.value;
  document.forms[0].submit();
 }
</script>
 <table width="100%" border="1">
 <tr>
   <td colspan=2> <div align="center"><font color="#FF8000" size="3"
face="Verdana, Arial, Helvetica, sans-serif"><strong>Pesquisa
Endereço</strong></font> </div></td>
  </tr>
<? if ($lbxendereco != ""){ ?>
 <tr>
       <td colspan=2 width="100%" align="left"><b> <font  size="3"
face="Verdana, Arial, Helvetica, sans-serif">
            Selecione um Endereço e digite o número do seu
imóvel:
            </font></b> <br>
 <select name="enderecoselecionado" size="2" style="height: 92; width: 638">
    <? echo $lbxendereco; ?>
   </select>
  <br>
               <font  size="2" face="Verdana, Arial, Helvetica,
sans-serif">Número
               do Imóvel:</font>
               <input type="text" name="numimovel" value="" size="7">
            <font  size="2" face="Verdana, Arial, Helvetica,
sans-serif">Letra: </font><input type="text" name="letraimovel" value=""
size="2">
            <center>
 <INPUT TYPE="SUBMIT" NAME="btselecionar" VALUE="SELECIONAR"
style="background-color: #FFFFFF; color: #000000; font-weight: bold;
font-size: 10 px; border-style: solid; border-color: #808080">
 <input type="hidden" name="rua" value="<? echo $rua; ?>">
 <input type="hidden" name="bairro" value="<? echo $bairro; ?>">
 </center>
 </td>
 </tr>
<? } else { ?>
 <tr>
 <td width="25%">
  <font  size="2" face="Verdana, Arial, Helvetica, sans-serif">Digite o nome
da rua</font>
 </td>
 <td>
  <input type="text" name="rua" value="" size="80">
 </td>
 </tr>
 <tr>
 <td width="25%">
  <font  size="2" face="Verdana, Arial, Helvetica, sans-serif">Digite o nome
do bairro</font>
 </td>
 <td>
  <input type="text" name="bairro" value="" size="80">
 </td>
 </tr>
 <tr>
 <td colspan=2 ALIGN="CENTER">
 <INPUT TYPE="SUBMIT" NAME="btpesquisa" VALUE="PESQUISAR"
style="background-color: #FFFFFF; color: #000000; font-weight: bold;
font-size: 10 px; border-style: solid; border-color: #808080">
 </td>
 </tr>
<? } ?>

  </table>
</form>

</body>
</html>


the php map file:
<?
// $pontox = 610539.39;
// $pontoy = 794816.04;

dl('php_mapscript.dll');

$map_path="/tmp/ms_tmp/";

$map = ms_newMapObj("mapinfo.map");
$l_pontomapa=$map->getLayerByName("pontomapa");
$l_pontomapa->set("status",1);
$pt = ms_newPointObj();
$pt->setXY( $pontox, $pontoy );
$image=$map->draw();
$pt->draw($map, $l_pontomapa, $image, 0, "anyname");
$image_url=$image->saveWebImage(MS_PNG,1,1,0);
?>

<HTML>
  <HEAD>
  <TITLE>Example 1: Displaying a map</TITLE>
  </HEAD>
  <BODY>
 <font color="#FF8000" size="3" face="Verdana, Arial, Helvetica,
sans-serif"><strong>Endereço:</strong></font>
 <br>
 <font  size="2" face="Verdana, Arial, Helvetica, sans-serif">
 <? echo $rua . ", " . $num . " - " . $bairro; ?>
 </font>
 <br>
 <br>
   <IMG SRC=<?php echo $image_url; ?> >
  </BODY>
</HTML>
------------------------------ end

cheers
Hugo Rodrigues
Analista/Consultor
SSSS - Prodabel
----- Original Message ----- 
From: "Tyler Mitchell" <TMitchell at lignum.com>
To: "Hugo Nathaniel Rodrigues" <hugo at pbh.gov.br>
Sent: Thursday, January 08, 2004 6:05 PM
Subject: Re: [Mapserver-users] happiness


>
>
>
>
>
> Congratulations.  I'd love to see how you did it if you were willing to
> share :)
>
> mapserver-users-admin at lists.gis.umn.edu wrote on 01/08/2004 08:58:19 AM:
>
> > i just finished one little application (my first) where you can type
> > one address with incomplete names of street and town, the
> > application will found all the matches and will give you the list to
> > you to choose one, then you type the number of your address and the
> > application will show you the map of the city with one star symbol
> > in the location of the address you typed... worked very well!!!!!!!!
> >
> > i make it in php accessing ms-sql database and php_mapscript +
> > mapserver (apache / php)
> >
> > thanks for all the support from the forum, special thanks to you
> > daniel, good work guys, good work!!!!!!
> > Hugo Rodrigues
> > Analista/Consultor
> > SSSS - Prodabel




More information about the MapServer-users mailing list