Preparing ka-Map/fr

From Ka-Map Wiki

Jump to: navigation, search

much of the text of this page is from Tyler Mitchell article Build AJAX-Based Web Maps Using ka-Map .

Contents

[edit] Preparer ka-Map

Si vous avez déjà créer une carte web avec Mapserver de manière traditionnelle, l'étape suivante est de créer des formulaires HTML et de les traiter avec les exécutable CGI de Mapserver. Avec Ka-Map, on peut démarrer avec une configuration minimale. D'abord, on a besoin des fichiers de configuration de Ka-Map et de PHP scripts.

ka-Map est livré sous trois manières différentes.

Comme un paquetage source dans la section ka-Map de Maptools sous la forme de:

  • Une archive compressée au format tar ball
  • Une archive au format zip
  • Un dépot CVS en ligne An online CVS repository
  • Comme un module pour le FGS Linux Installer, en utilisant la commande :

fgs install kamap-base:0.1.1 http://dl.maptools.org/dl/fgs/modules/ As a zip package for MapServer For Windows (MS4W).

Vous aurez besoin d'un client CVS afin de télécharger la version CVS. Sous Linux vous pouvez télécharger la version CVS en utilisant la commande suivante:

cvs -d (server_path) checkout ka-map (local_folder_name)

Dans la commande ci-dessus (server_path) doit être remplacé par le répertoire se trouvant sur cette page [1] et (local_folder_name) par le nom du dossier sur la machine où l'on veut télécharger les fichiers. en se plassant directement dans le dossier local, on n'a pas besoin de mettre de (local_folder_name)


Les fichiers sont stockés dans une structure de dossier trés simple:

.../kamap/
.../kamap/docs/
.../kamap/htdocs/
.../kamap/htdocs/images/
.../kamap/include/
...
.../kamap/htdocs/tmp/

All the files you are going to deal with are in the htdocs folder. To keep things really simple, move the map file and data folder here as well.


[edit] Sécurité Security Warning

Dans un environnement de production ce n'est pas une bonne manière de mettre votre fichier global.map dans un endroit à accés public. Cet exemple est fait seulement pour un test en interne et pour avoir une gestion des dossier minimale pour pouvoir débuter. Parce que le fichier global.map est dans le dossier htdocs il peut être atteint par une URL WEB. C'est particulièrement une mauvaise idée si vous vous connectez à une base de données dans votre mapfile car les paramètres de conection sont indiqués en clair.

Cette structure de dossier généralement utilisée permet de garder séparés le dossier htdocs des fichiers mapfile et de données:

.../kamap-1.0/map/global.map
.../kamap-1.0/data/countries_simpl.*
.../kamap-1.0/data/day_clouds.*

[edit] Alias de Serveur Web

Pour autoriser votre serveur à utiliser, vous avez besoin de créer des aliass. Avec FGS et MS4W ceci devrait être fait pour vous automatiquement. Autrement, vous devrait ajouter quelquechose comme cela à la configuration de votre serveur internet, par exemple dans le fichier httpd.conf d'Apache:

Alias /ka-map/ "/opt/fgs/apps/kmap-0.1.1/htdocs/"
<Directory "/opt/fgs/apps/kmap-0.1.1/htdocs/">
       Options Indexes
       AllowOverride None
       Order allow,deny
       Allow from all
</Directory>

Ceci vous permet de saisir une simple URL (/ka-map/) et de l'avoir qui pointe vers le chemin où le contenu de ka-Map! est stocké. This allows you to enter a simple URL (/ka-map/) and have it point to the file path where ka-Map content is stored.

[edit] ka-Map Configuration Files

ka-Map est livré avec un fichier de configuration principal:

..../ka-map/include/config.dist.php

qui doit être renomé en

 .../ka-map/include/config.php

Once the handful of settings in this file are set, you will have a fully functioning ka-Map application. For FGS and MS4W packages, many of these settings are already taken care of. There is documentation throughout config.php to guide you through each setting. There are only three different types of settings that you really need to worry about.

[edit] Setting Up Library Pointers

K-Map nécessite PHP MapScript ainsi que le module GD pour PHP. config.php à besoin de pointer vers ses fichiers librairies (aux alentours de la ligne 23). ka-Map requires both PHP MapScript and the GD module for PHP. config.php needs to point to these library files (around line 23):

$szPHPMapScriptModule = 'php_mapscript_cvs_rel.4.6.0.beta2.'.PHP_SHLIB_SUFFIX;
$szPHPGDModule = 'php_gd.'.PHP_SHLIB_SUFFIX;

The first one points to the file name prefix for the PHP MapScript library. This looks somewhat verbose, because the above example uses a very recent beta version of PHP MapScript. You change this to match the filename for the php_mapscript library that is on your system. In many cases this looks as simple as:

$szPHPMapScriptModule = 'php_mapscript.'.PHP_SHLIB_SUFFIX;

Ou:

$szPHPMapScriptModule = 'php_mapscript_46.'.PHP_SHLIB_SUFFIX;

La documentation dit que que le pointeur vers php_gd devra être modifierr en php_gd2, si vous êtes sous Windows.

Note that the PHP_SHLIB_SUFFIX variable will automatically add the filename suffix. For example, .so or .dll, depending on your operating system. Don't include the suffix in this filename setting.

[edit] Adding Your Map File

To have your custom application show up in ka-Map, you need to tell ka-Map where your map file is, as well as some other map-specific settings. Around line 80 you'll find the settings for the $aszMapFiles array. It will already be set to use a mapping application called GMap, but you can change it to match this one:

$aszMapFiles = array(
       "weather"     => array( "Global Weather",
                               "/opt/fgs/apps/kamap-0.1.1/htdocs/global.map",
                               array( 100000000, 50000000, 15000000 ),
                               "PNG")
);

This sets up an array of information, all stored within the $aszMapFiles variable. The first setting is the name of the ka-Map instance you are configuring; in this case the application is called "weather" and uses the global.map file you created earlier. This name is used in other places, as you will see later on.

The second setting is the text, "Global Weather", which is the name that will appear in the drop-down box on the web page. From this drop-down you can choose which map file you want to use.

The third setting points to the location of the global.map file. Depending on how your system is configured, this will vary. In this example, global.map was stored in the ka-Map htdocs folder, alongside the data folder.

[edit] Paramétrage des échelles de la carte et des Formats d'Images

The fourth setting is a list of scales. These are the map scales that the user will be allowed to view the map at. For example, 1,000 would be the map scale as a representative fraction of 1:1,000. This means that one inch on screen represents one thousand inches on the ground.

Le dernier réglage est le format d'image de sortie à utiliser, dans ce cas "PNG".

Note that there are two closing parentheses, one after "PNG", which ends the settings for the "weather" array. If you want to add more than one instance to ka-Map, put a comma after this parenthesis and create a whole new instance key.

The second closing parenthesis is on a separate line and followed by a semicolon. It ends the settings for the $aszMapFiles array.

Avec ces changement éffectués à config.php, vous êtes pret à tester votre carte.

Personal tools