Languages

User login


Com fer que el MapServer serveixi mapes de l'ICC


 

 

La idea principal és tenir un fitxer .map que faci el lligam amb el servidor de mapes al qual volem fer peticions i definir-hi les capes que ens interessen.

Ho podem fer sobre la instal·lació de la 'demo' que haurà creat el directori 'workshop', aquí podem posar el fitxer.map que construïm i ens caldrà editar el fitxer 'itasca_basic.html' i el 'index.html' perquè sàpiga quin és el fitxer.map que nosaltres estem fent i quines capes demanem.

Anem a veure i comentar un fitxer.map:

# Inici arxiu MAP
MAP

#Nom aplicacio
NAME HELLO

#Estat
STATUS ON

#Extensió mapa [minx] [miny] [maxx] [maxy]
EXTENT 263747.60 4484436.53 527495.20 4748184.13

#Mida en pixels de la imatge
SIZE 400 400

#Unitats del mapa
UNITS METERS

#Ruta de la cartografia
#SHAPEPATH "dades"

#Color de fons
IMAGECOLOR 255 255 255

#Format de sortida de la imatge
IMAGETYPE PNG

#Projecció en coordenades geogràfiques
PROJECTION
#epsg 23031 correspon a utm de Catalunya
"init=epsg:23031"
END

# Patró que fa servir per presentar les dades
TEMPLATEPATTERN "itasca"

#Definició de les capacitats
WEB
IMAGEPATH "/home/ldalmau/fgs2/tmp/ms_tmp/"
IMAGEURL "/ms_tmp/"
METADATA
WMS_TITLE "Aplicació OGC"
WMS_ABSTRACT "Exemple d'interoperabilitat utilitzant Minnesota mapserver"
WMS_ONLINERESOURCE "http://10.138.32.132:8082/cgi-bin/mapserv?map=/home/ldalmau/fgs2/apps/gmap-ms40/htdocs/wms5_lluis.map"
WMS_SRS "EPSG:23031"
END
END


LEGEND
KEYSIZE 18 12
LABEL
TYPE BITMAP
SIZE MEDIUM
COLOR 0 0 89
END

STATUS ON
END

#
# Start of scalebar
#
SCALEBAR
IMAGECOLOR 255 255 255
LABEL
COLOR 0 0 0
SIZE SMALL
END
SIZE 150 5
COLOR 255 255 255
BACKGROUNDCOLOR 0 0 0
OUTLINECOLOR 0 0 0
UNITS kilometers
INTERVALS 5
STATUS ON
END


QUERYMAP
STYLE HILITE
COLOR 255 0 0
END


#Peticio al servidor ICC topo 250.000
LAYER
NAME "Topo250K"
TYPE RASTER
STATUS ON
CONNECTION "http://galileo.icc.es/wms/servlet/icc_bt250m_r_r?"
CONNECTIONTYPE WMS
METADATA
"wms_srs" "EPSG:23031"
"wms_name" "MTC250000"
"wms_server_version" "1.1.0"
"wms_format" "image/jpeg"
END
END


#Peticio al servidor ICC ortos 5.000
LAYER
NAME "Orto5K"
TYPE RASTER
STATUS ON
CONNECTION "http://galileo.icc.es/wms/servlet/icc_orto5m_r_r?"
CONNECTIONTYPE WMS
METADATA
"wms_srs" "EPSG:23031"
"wms_name" "Ortofoto_5000"
"wms_server_version" "1.1.0"
"wms_format" "image/png"
END
END



#Final de l'arxiu MAP
END

 

També com quedaria el fitxer 'itasca_basic.html':

<html>
<head>
<title>guifiMapServer</title>
</head>
<body bgcolor="#ffffff">

<center><h1>guifiMapServer - Servidor de mapes</h1></center>
<hr>
<form method="GET" action="[program]" name="mapserv">

<center>
<table border="0" cellspacing="0" cellpadding="4">
<tr>
<td valign="top" align="center">
  <table width="390" border="0" cellspacing="0" cellpadding="4" align="center" bgcolor="#666666">
<tr>
<td align="center"><input type="image" name="img" src="[img]" width="[mapwidth]" height="[mapheight]" border="0" alt="this is the map"></td>
</tr>
<tr><td bgcolor="#666666">
<img title="scalebar (mi)" alt="scalebar (mi)" src="[scalebar]">
</td></tr>
</table>
</td>
<td valign="top" bgcolor="#ffffff">
<table cellpadding="5" cellspacing="0" border="0" bgcolor="#ffffff">
    <tr><td>
<center><input type="submit" value="Refresh/Query"></center>
<p>

<input type="radio" name="mode" value="browse" checked> <b>Veure el mapa</b><br>
<input type="radio" name="mode" value="query"> <b>Demanar dades</b><br>
<input type="radio" name="mode" value="nquery"> <b>Demanar diverses dades</b>
      <hr>

<p>
<b>Escull les capes que vols veure: </b><br>
<select multiple name="layer" size=3>
<option value="Topo250K" [Topo250K] checked> Topo250K
<option value="Orto5K" [Orto5K]> Orto5K
</select>
      <p>
<input type=radio name=zoomdir value=1 [zoomdir_1_check]> Zoom +<br>
<input type=radio name=zoomdir value=0 [zoomdir_0_check]> Moure<br>
<input type=radio name=zoomdir value=-1 [zoomdir_-1_check]> Zoom -
<p>
Mida del zoom que vols fer <input type=text name=zoomsize size=4 value=[zoomsize]>
      <p>

<font size=+1><b>Llegenda</b></font><br><hr>
<img src="[legend]"><hr>

<p>
<center><input name="ref" type="image" src="[ref]" border="0"></center>
</td></tr></table>

</td></tr>
</table>
</center>

<input type="hidden" name="imgxy" value="[center]">
<input type="hidden" name="imgext" value="[mapext]">
<input type="hidden" name="map" value="[map]">
<input type="hidden" name="root" value="[root]">
<input type="hidden" name="savequery" value="true">

<input type="hidden" name="program" value="[program]">
<input type="hidden" name="map_web_imagepath" value="[map_web_imagepath]">
<input type="hidden" name="map_web_imageurl" value="[map_web_imageurl]">
<input type="hidden" name="map_web_template" value="[map_web_template]">

</form>

<p><hr><p>
<a href="[root]/index.html">inici</a><p>
<i>[map_web_template]</i>

</body></html>

 

Bàsicament, hem afegit informació sobre les dues capes que hem definit al 'fitxer.map'

I el fitxer 'index.html' podria quedar així:

<html>
<head>
<title>guifiMapServer - Servidor de mapes</title>
<script language="javascript">
function submit_form() {
var template = document.demo.map_web_template.options[document.demo.map_web_template.selectedIndex].value;
if(template.indexOf("frame") != -1) document.demo.action = "frames.html";
if(template.indexOf("dhtml") != -1) document.demo.action = "frames_dhtml.html";
}
</script>
</head>
<body bgcolor="#FFFFFF">

<center><h2>guifiMapServer - Servidor de mapes</h2></center>
    <p><hr><p>
Proves amb diferents nivells de complexitat. Hi ha una aplicatiu basic que permet fer zoom/pan i canviar les capes:
<ul>
<li> escales dinamiques
<li> moviments de mapa basats en javascript
<li> demanar resultats en un marc
<li> DHTML rubber-band zoom/query capabilty
</ul>

<!-- EDIT THE FORM ACTION -->
    <form name="demo" method="GET" action="/cgi-bin/mapserv" onSubmit="submit_form()">

<input type="hidden" name="layer" value="Topo250K">
<input type="hidden" name="layer" value="Orto5K">
<input type="hidden" name="zoomsize" value=2>

<!-- EDITAR AQUESTES VARIABLES OCULTES -->
<input type="hidden" name="map" value="/home/ldalmau/fgs2/www/htdocs/workshop/wms5_lluis.map">
<input type="hidden" name="program" value="/cgi-bin/mapserv">
<!--editar segons url-->
      <input type="hidden" name="root" value="/workshop">
<input type="hidden" name="map_web_imagepath" value="/home/ldalmau/fgs2/tmp/ms_tmp/">
<input type="hidden" name="map_web_imageurl" value="/ms_tmp/">

<select name="map_web_template" size="1">
<option value="itasca_basic.html"> Aplicatiu basic
<option value="itasca_adds_scalebar.html"> &nbsp;&nbsp;-- Afegir segona escala
<option value="itasca_adds_pan.html"> &nbsp;&nbsp;-- Afegir controls pan (moviment)
<option value="itasca_adds_frames.html"> &nbsp;&nbsp;-- Afegir marcs
<option value="itasca_adds_dhtml.html"> &nbsp;&nbsp;-- Afegir dhtml rubber-ba2nd box
</select>
      <input type="submit" value="Initialitza"></center>

</form>

<p><hr><p>
</body>
</html>

 

En aquest fitxer necessitem editar les referències a les capes i a les variables ocultes que apunten al fitxer executable 'mapserv' i al 'fitxer.map'

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Un petit error

Només dir que al principi de l'arxiu .map has posat:

#SHAREPATH "dades"

i encara que està comentat i per tant no passa res, hauria de ser SHAPEPATH, no?

Merci.