Copyright (c) 2002, 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. */ /***************************************************************************** * $Log: app_query.phtml,v $ * Revision 1.7 2002/07/29 12:48:16 bronsema * changed wms rectangle query to query center of rectangle. * * Revision 1.6 2002/07/08 18:32:28 bronsema * Added "Default" layers to the query. * * Revision 1.5 2002/07/03 14:32:34 bronsema * corrected missing $_SESSION reference * * Revision 1.4 2002/07/03 13:44:12 bronsema * Updated to the new _GET and _POST * * Revision 1.3 2002/06/13 14:15:30 sacha * Change copywrite msg * * Revision 1.2 2002/05/28 19:55:00 bronsema * Changed scalebar to use map defaults. * * Revision 1.1 2002/05/28 18:33:55 bronsema * Added queries * * Revision 1.2 2002/05/21 17:18:45 bronsema * Added generate keymap functionality * * Revision 1.1 2002/05/21 04:46:20 bronsema * Initial addition * *****************************************************************************/ // include the global preferences include_once( "./globprefs.php" ); /* ============================================================================ * HTTP_FORM_VARS array contains the HTTP GET or POST parameters * ========================================================================= */ $http_form_vars = count( $_POST ) > 0 ? $_POST : ( count($_GET) > 0 ? $_GET : array("") ); //DEBUG /*foreach ($http_form_vars as $key => $value) { echo "Key: $key; Value: $value
\n"; } /* ============================================================================ * Re-instate the previous map state * ========================================================================= */ // determine previous state key if ( isset( $http_form_vars["PrevStateKey"] ) ) $szPrevStateKey = $http_form_vars["PrevStateKey"]; else $szPrevStateKey = ""; // restore the previous state $oMapSession->restoreState( $szPrevStateKey, MAPFILE ); /* ============================================================================ * Run query * ========================================================================= */ // only process if coordinates are given if ( isset( $http_form_vars["INPUT_COORD"] ) && strlen( trim( $http_form_vars["INPUT_COORD"] ) ) > 0 ) { // initalize vars $gaszWMSResults = array(); // process coordinates $aszMinMax = explode(";", $http_form_vars["INPUT_COORD"]); $adMin = explode(",", $aszMinMax[0]); $adMax = explode(",", $aszMinMax[1]); // loop through all layers and add to list of layers to query // NOTE: Layers will only have results generated for them if they // have a "template" value set. The template value does not have // to be valid, it could be as simple as "ttt". $aszLayers = array(); $oMap = $oMapSession->oMap; $nCount = $oMap->numlayers; for ( $i=0; $i<$nCount; $i++ ) { // get layer name $oLayer = $oMap->getLayer( $i ); // only add if on if ( $oLayer->status == MS_ON || $oLayer->status == MS_DEFAULT ) array_push( $aszLayers, $oLayer->name ); } // commit $oMapQuery->setQueryLayersByName( $aszLayers ); // execute query if ( is_numeric( $adMax[0] ) && is_numeric( $adMax[1] ) ) $oResultSet = $oMapQuery->executeRectQuery( $adMin[0], $adMin[1],$adMax[0], $adMax[1] ); else $oResultSet = $oMapQuery->executePointQuery( $adMin[0], $adMin[1] ); // format the query results $szResults = formatQueryResults( $oResultSet, $aszLayers ); } else $szResults = "No results"; /** * This function takes the query result set object and processes all result * sets and formats them into a single html table string. * * @param $oResultSet object - The result set object to read. * @return string - An html table of result values. **/ function formatQueryResults( $oResultSet, $aszLayers ) { global $gaszWMSResults; // initialize the variables $szReturnValue = ""; $aszNoResults = array(); // loop through each result set and return $nCount = $oResultSet->nNumResults; for ( $i=0; $i<$nCount; $i++ ) { // process each result set $aRows = $oResultSet->getResultSet( $i ); // check if single or multiple results were returned if ( is_array( $aRows ) ) { // build title rows $szReturnValue .= "\n"; $szReturnValue .= "\n"; $szReturnValue .= "\n"; $szReturnValue .= "\n"; $szReturnValue .= "\n"; $szReturnValue .= "\n"; $szReturnValue .= "\n"; //***********ADDED FOR HYPERLINK*************************************************************** // loop and use key for titles // $Key is equal to the attribute name, which is also the header of column foreach ($aRows[0] as $key => $value) { // The purpose of this if loop is to find the only attribute name we want to display if (strcasecmp($key, "Long_DD") == "Long_DD"; strcasecmp($key, "Lat_DD") == "Lat_DD"; strcasecmp($key, "MS_PATH2") == "MS_PATH2"; $szReturnValue .= "\n"; } //********************************************************************************************* $szReturnValue .= "\n"; // loop through the results and format each row foreach ( $aRows as $aRow ) { // add a row for each $szReturnValue .= "\n"; //***********ADDED FOR HYPERLINK*************************************************************** // loop and add a cell for each result foreach ( $aRow as $xCell ) { // $xCell is the attribute value, in this case,when the $key attribute name is equal to "Long_DD" and "Lat_DD" only display the value of attribute. if (strcasecmp($key, "Long_DD") == "Long_DD"; strcasecmp($key, "Lat_DD") == "Lat_DD" ) {$szReturnValue .= "\n";} //when the attribute name is equal to MS_PATH2, hyperlink according to the value of attribute, the attribute value of MS_PATH2 should be simliar as http://localhost/photoalbum/image.jpg //photoalbum folder with images is put at your web server. else if (strcasecmp($key, "MS_PATH2") == "MS_PATH2"; {$szReturnValue .= "\n";} } $szReturnValue .= "\n"; } //********************************************************************************************* // close the table $szReturnValue .= "
".$aszLayers[$i]."
".$key."
". $xCell." Click here to document
\n"; $szReturnValue .= "\n"; $szReturnValue .= "\n"; } else { // check if wms if ( substr( $aRows, 0, 26 ) = "No results found for layer" ) array_push( $aszNoResults, $aszLayers[$i] ); else { $nTmpCount = count( $gaszWMSResults ); $gaszWMSResults[$nTmpCount][0] = $aRows; $gaszWMSResults[$nTmpCount][1] = $aszLayers[$i]; } } // end loop of layers } // add the list of layer that return no results $nCountNoResults = count( $aszNoResults ); if ( $nCountNoResults > 0 ) { $szReturnValue .= "\n"; $szReturnValue .= "\n"; $szReturnValue .= "\n"; $szReturnValue .= "\n"; $szReturnValue .= "\n"; $szReturnValue .= "\n"; $szReturnValue .= "\n"; $szReturnValue .= "\n"; $szReturnValue .= "\n"; $szReturnValue .= "
The following layers did not return any results:
"; for ($i=0; $i<$nCountNoResults; $i++) { $szReturnValue .= $aszNoResults[$i]; if ( $i < $nCountNoResults - 1) $szReturnValue .= ", "; } $szReturnValue .= "
\n"; $szReturnValue .= "\n"; $szReturnValue .= "\n"; } // return the formated string return $szReturnValue; // end formatQueryResults function } ?> Query Results
0 ) { // add a warnning message for WMS layers echo "\n"; echo "\n"; echo "\n"; // loop for ( $i=0; $i<$nCountWMS; $i++ ) { // add header echo "\n"; echo "\n"; echo "\n"; } } // display the rest if the query results echo $szResults; ?>
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
Note: WMS layers can only be queried as a point. If a rectangle query is used, the center of the rectangle will be used as the query location.
\n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; // begin new row echo "\n"; echo "\n"; echo "\n"; echo "
".$gaszWMSResults[$i][1]."
\n";

        // read URL
        readfile( $gaszWMSResults[$i][0] );

        // close row
        echo "
\n"; echo "