[Geomoose-users] can not use multiple mapbook.xml files and php services

TC Haddad tchaddad at gmail.com
Wed Mar 18 12:28:13 PDT 2015


Hello,

I'm not sure which wiki page you are referring to but it might be out of
date. Perhaps you can share the URL and we can confirm if the contents are
current or not?

It has been some time since I tried to use multiple mapbooks (GM 2.6). But
when I did, I was successful by using the method outlined below. You can
try and see if you can get it to work with 2.7.x.

Below the instructions, I will also paste the text of the "config.php" file
that is mentioned,

good luck!

Tanya

------------------ fwd ------------------------ > >


*Modification to use multiple mapbooks*



 1.    Replace php/config.php with updated version.  This file starts a PHP
session and looks at a session variable passed by the HTML to set which
settings.ini file to use.

2.     In the config folder, make copies of settings.ini and mapbook.xml
with new names and leave them in the config folder.   For example, they
could be called “internal_settings.ini” and “internal_mapbook.xml”.

3.     Make a copy of geomoose.html (the main HTML page) and re-name it,
for example “internal.php” (note the PHP extension).

4.    Open “internal.php” and add the following lines to the very top of
the file:

<?php
        session_start();

         $_SESSION['settings'] = 'internal_settings.ini';
?>

Note the value for settings is “internal_settings.ini” – this will be what
you called the file in step

 5.    Open “internal_settings.ini” and set the mapbook name to
“internal_mapbook.ini”

Give it a try.  You can also use different CSS files by specifying them in
the internal.php file.


+++++++++++++++++++++++++++++++++++++++

contents of new 'config.php' below

+++++++++++++++++++++++++++++++++++++++

<?php

session_start();

/*Copyright (c) 2009, Dan "Ducky" Little & GeoMOOSE.org

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.*/

#
# This is meant to allow specific environmental includes for
# GeoMOOSE 2 PHP Services.  Substantive configuraiton options
# should be added to settings.ini
#

/* Check for the required libraries
 * g2/curl are used for printing. If you're not using printing
 * you can avoid using these modules.
 *
 * mapscript and dbase are used for most operations using them
 * cannot be avoided
 */

if(!extension_loaded('gd') && !extension_loaded('gd2')) {
    dl('php_gd2.'.PHP_SHLIB_SUFFIX);
}

if(!extension_loaded('curl')) {
    dl('php_curl.'.PHP_SHLIB_SUFFIX);
}

if(!extension_loaded('MapScript')) {
    dl('php_mapscript.'.PHP_SHLIB_SUFFIX);
}

if(!extension_loaded('dbase')) {
    dl('php_dbase.'.PHP_SHLIB_SUFFIX);
}


# Load the configration file
$settings = "settings.ini";

if($_SESSION['settings']) {
    $settings = $_SESSION['settings'];
}

$CONFIGURATION = parse_ini_file('../../conf/' . $settings);

function getMapbook() {
    global $CONFIGURATION;
    $mapbook = new DOMDocument();
    $mapbook->load('../../conf/'.$CONFIGURATION['mapbook']);
    return $mapbook;
}

function getUsername() {
    session_start();
    return $_SESSION['username'];
}


# Select Functionality ONLY works for Mapserver Layers
function getMapfile($mb, $layerName) {
    $services = $mb->getElementsByTagName('map-source');
    $mapfiles = array();
    for($i = 0; $i < $services->length; $i++) {
        $service = $services->item($i);
        $root = $service->getAttribute('name');
        $layers = $service->getElementsByTagName('layer');
        for($l = 0; $l < $layers->length; $l++) {
            $layer = $layers->item($l);
            $path = $root.'/'.$layer->getAttribute('name');
            if($path == $layerName) {
                return
$service->getElementsByTagName('file')->item(0)->nodeValue;
            }
        }
    }
    return null;
}

# get a source based on it's name
function getMapSource($mb, $layerName) {
    $services = $mb->getElementsByTagName('map-source');
    $mapfiles = array();
    for($i = 0; $i < $services->length; $i++) {
        if($services->item($i)->getAttribute('name') == $layerName) {
            return $services->item($i);
        }
    }
    return null;
}

//LK Get a CONFIGURATION parameter from the Mapbook
function getParam($mb, $paramTest) {
    $paramValue = "null";
    $configuration = $mb->getElementsByTagName('configuration');
    $params = $configuration->item(0)->getElementsByTagName('param');
    for($i = 0; $i < $params->length; $i++) {
        $param = $params->item($i);
        if($param->getAttribute("name") == $paramTest) {
            $paramValue = $param->firstChild->nodeValue;
        }
    }
    return $paramValue;
}
?>


On Tue, Mar 3, 2015 at 11:16 AM, biswajit giri <biswajit_giri at yahoo.com>
wrote:

> All the users
> Really need all of your help.
> I am using geomoose 2.7.1-ms4w. the problem is I cannot use multiple
> mapbooks using multiple settings.ini files as mentioned in the geomoose
> wiki.
> Even I tried alternative options such as avoid the getmapbook.php file
> then send the mapbook.xml file as url as mentioned by some users. it is
> fine but php services are not working.
> Please somebody help me to overcome this problem. personally I like the
> geomoose wiki solution but helpless.
>
> Biswajit Giri
> CAD centre
> Jadavpur University
> Kolkata, India
>
> _______________________________________________
> Geomoose-users mailing list
> Geomoose-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/geomoose-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/geomoose-users/attachments/20150318/8c1147fa/attachment.html>


More information about the Geomoose-users mailing list