Copyright (c) 2003, DM Solutions Group Inc.
* 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.
**/
if (!extension_loaded("MapScript"))
{
if (PHP_OS == "WINNT" || PHP_OS == "WIN32")
dl("php_mapscript_41.dll");
else
dl("php_mapscript_41.so");
}
// set to 1 for detailed report of params and query string result
$debug=0;
include "fn_cfs_demo.php";
// no support for context files in this demo
// mapfile is hardcoded - could come from http vars with the selected server
$oMap = ms_newMapObj("ns_wfsclient.map");
if (sizeof($_POST) > 0)
$HTTP_FORM_VARS = $_POST;
else if (sizeof($_GET) > 0)
$HTTP_FORM_VARS = $_GET;
else
$HTTP_FORM_VARS = array("");
$bFlag = 0;
if( ($HTTP_FORM_VARS['andClicked']==1) || ($HTTP_FORM_VARS['orClicked']==1) )
$bFlag = 1;
/* ==================================================================== */
/* returned array has sorted HTTP filter parameters */
/* multidimensional - each index is an assoc array for one filter */
/* ==================================================================== */
if($bFlag==1)
$nFilters = 2;
else
$nFilters = 1;
$aParams = parseWFSURL( $HTTP_FORM_VARS, $nFilters, "__" );
/* ==================================================================== */
/* builds an array of formatted WFS filters. each index of the array */
/* is one filter. no inter-filter logic is handled (ie, AND or OR). */
/* ==================================================================== */
$aURI = array();
$aURI = buildFEString( $aParams,
$nFilters,
$HTTP_FORM_VARS['wildCard'],
$HTTP_FORM_VARS['singleChar'],
$HTTP_FORM_VARS['escapeChar']
);
/* ==================================================================== */
/* check for AND or OR */
/* ==================================================================== */
$szStartWrap='';
$szEndWrap='';
if( $bFlag==1 )
{
if( intval($HTTP_FORM_VARS['andClicked']==1))
{
$szStartWrap = '';
$szEndWrap = '';
$szStartOutput = 'AND';
}
else
{
$szStartWrap = '';
$szEndWrap = '';
$szStartOutput = 'OR';
}
}
/* ==================================================================== */
/* build the request string to be passed to the WFS server */
/* ==================================================================== */
$szWFSRequest = $szStartWrap;
for( $i=0; $igetlayerbyname($HTTP_FORM_VARS["layer"]);
//$oLayer->setMetaData("wfs_request_method", "GET");
$oLayer->setMetaData("wfs_filter", $szWFSRequest);
//echo $oLayer->getMetaData("wfs_filter");
}
//else
//{
// echo 'no layer was specified - should have been caught by the query form';
//}
$img = $oMap->draw();
$url = $img->saveWebImage();
// fix up the WFS string all pertty like with some ugly code
$szModRequest = str_replace('>', '> ', $szWFSRequest);
$szModRequest = str_replace('<', ' <', $szModRequest);
$szModRequest = str_replace(' ', ' ', $szModRequest);
echo "";
echo "
*Note: Spaces in query string are for visual purposes only
";
echo "
";
echo "
Layer queried:
".$HTTP_FORM_VARS["layer"]."
";
echo "
Number of filters applied:
$nFilters
";
echo "
Logical Operator:
".$szStartOutput."
";
echo "
";
echo "
";
}
echo "
";
echo "";
echo "
";
echo "
";
echo "";
/* ==================================================================== */
/* DEBUGGING INFO set $debug=1 at top of script to display */
/* ==================================================================== */
if($debug==1)
{
echo '
';
echo 'HTTP VARS ';
print_r($HTTP_FORM_VARS);
echo '
';
echo '
';
echo 'Parsed URL VARS ';
print_r($aParams);
echo '