![]() |
||||
|
|
||||
[maplab-users] Re: Java Console ErrorSacha Fournier sfournier@dmsolutions.caWed, 28 May 2003 10:15:14 -0400
|
||||
This is a multi-part message in MIME format.
--------------080402020905020007090008
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Hi Chandra,
I think I found you problem. Not sure if it is related to the rosa
applet. Can you take this file and replace your version with it ? Let me
know if it worked.
Sacha
Chandrasekar Balasubramaniam wrote:
> I get this error while running the Tutorial mapFile.
> chandra
>
> -----Original Message-----
> From: Sacha Fournier [mailto:sfournier@dmsolutions.ca]
> Sent: Monday, May 26, 2003 8:57 AM
> To: Chandrasekar Balasubramaniam
> Cc: maplab-users-admin@dmsolutions.ca
> Subject: Re: Java Console Error
>
>
> Hi Chandra,
>
> Do you get this error wjile using the demo mapfile ?
>
> Chandrasekar Balasubramaniam wrote:
>
>>Hello Everyone
>> Iam still struggling to find out why no map is displayed in mapbrowser.I
>>found this following error in Java Console.
>>******************
>>stop
>>1st
>>-1
>> Try as PNG
>>init
>>start : Development Version 2001-09-11
>>*******************
>>(Image Type is PNG)
>> Please could anyone tell me why is this error caused. I found no such
>>error while running mapedit preview.Thanks
>>Revision:
>>* rosa_png.jar had been substituited for rosa.jar
>>
>>regards
>>chandra
>>
>>
>
>
> --
> Sacha Fournier
> Applications Developer
> DM Solutions Group
> sfournier@dmsolutions.ca
> tel: 418.696.5056
> fax: 418.696.5056
>
> www.dmsolutions.ca
> --
> -------------------------------------------------
> /"\ ASCII Ribbon Campaign against HTML
> \ / email and proprietary format
> X attachments.
> / \
> -------------------------------------------------
>
>
>
--
Sacha Fournier
Applications Developer
DM Solutions Group
sfournier@dmsolutions.ca
tel: 418.696.5056
fax: 418.696.5056
www.dmsolutions.ca
--
-------------------------------------------------
/"\ ASCII Ribbon Campaign against HTML
\ / email and proprietary format
X attachments.
/ \
-------------------------------------------------
--------------080402020905020007090008
Content-Type: text/plain;
name="drawmap.php"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="drawmap.php"
<?php
/**
* @project PHP Utils
* @revision $Id: drawmap.php,v 1.29 2003/05/28 14:11:44 sacha Exp $
* @purpose This file outputs the current map file to sceen
* @author William A. Bronsema, C.E.T. (bronsema@dmsolutions.ca)
* @copyright
* <b>Copyright (c) 2002, DM Solutions Group Inc.</b>
* 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.
**/
/*****************************************************************************
* The following parameters are REQUIRED when caling this page:
*
* map_session_mode : integer
* 0 indicates the map session is read-only,
* 1 indicates the map session is read-write.
*
* run_query : integer
* 0 indicates a query is NOT to be run,
* 1 indicates a query is to be run.
*
* The following parameters are OPTIONAL when caling this page:
* (They MUST be set using session variables of the same name)
*
* gszMapName : string
* Path and filename to the mapfile. This value can
* be included in the URL if sessions are NOT used
* OR can be set using a DEFINE statment as outlined
* in the code below.
*
* gszCurrentState : string
* The map session current state key. Defaults to ""
* if not supplied.
*
* gszMapPath : string
* The path to where mapscript "thinks" the mapfile is
* located. Defaults to the path of the given mapfile
* if not given.
*
* gszPHPMapScriptModName : string
* The mapscript module name. Default to
* "php_mapscript.so (or .dll)" if not given.
*
* gszMapscriptModule : string
* alternate for gszPHPMapScriptModName.
*
* gszTmpMapPath : string
* The path for the temporary map files in read-write
* mode. Defaults to the path of the given mapfile if
* not given.
*
* gszQueryLayers : string
* Comma delimited string of layer indexes to query.
* If not supplied and a query is called for then all
* visible layers will be queried.
*
* gszQueryCoords : string
* String of co-ordinates in the following format:
* minx,miny;maxx,maxy
* This value MUST be supplied if a query is performed.
*
*****************************************************************************/
/* ============================================================================
* Un-comment the following code if the mapfile is to be DEFINED instead of in
* session or URL.
* ========================================================================= */
//DEFINE( "MAPFILE", "./mymap.map" );
/* ============================================================================
* Include necessary files
* ========================================================================= */
include_once( "../session/session.php" );
include_once( "../logger/logfile.php" );
include_once( "../logger/error_manager.php" );
include_once( "../logger/logger.php" );
include_once( "./map_session.php" );
include_once( "./map_navigator.php" );
include_once( "./map_query.php" );
installSessionDirectoryHandler();
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// always modified
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
/* ============================================================================
* setup values
* ========================================================================= */
// build an array with the HTTP GET or POST parameters
$http_form_vars = (count($_POST) > 0) ?
$_POST : ((count($_GET) > 0) ? $_GET : array() );
// determine current page location
$szURI = "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
// set max time out
set_time_limit(600);
/* ============================================================================
* Determine the required values
* ========================================================================= */
// default values
$szMapName = ( defined( "MAPFILE" ) ? MAPFILE : "?");
$szMapPath = "?";
$szMSModName = "?";
$szTmpMapPath = "?";
$szCurrentState = "?";
$szQueryLayers = "?";
$szQueryCoords = "?";
$oErrorManager = "?";
$szFatalErrorImage = "?";
$szGDVersion = "?";
$nMinX = "?";
$nMinY = "?";
$nMaxX = "?";
$nMaxY = "?";
$nWidth = "?";
$nHeight = "?";
// check URL if values not yet set
if ( $szMapName == "?" && isset($http_form_vars["gszMapName"]) )
$szMapName = $http_form_vars["gszMapName"];
if ( $szMapPath == "?" && isset($http_form_vars["gszMapPath"]) )
$szMapPath = $http_form_vars["gszMapPath"];
if ( $szFatalErrorImage == "?" && isset($http_form_vars["szFatalErrorImage"]) )
$szFatalErrorImage = $http_form_vars["szFatalErrorImage"];
if ( $nMinX == "?" && isset($http_form_vars["nMinX"]) )
$nMinX = $http_form_vars["nMinX"];
if ( $nMinY == "?" && isset($http_form_vars["nMinY"]) )
$nMinY = $http_form_vars["nMinY"];
if ( $nMaxX == "?" && isset($http_form_vars["nMaxX"]) )
$nMaxX = $http_form_vars["nMaxX"];
if ( $nMaxY == "?" && isset($http_form_vars["nMaxY"]) )
$nMaxY = $http_form_vars["nMaxY"];
if ( $nWidth == "?" && isset($http_form_vars["nWidth"]) )
$nWidth = $http_form_vars["nWidth"];
if ( $nHeight == "?" && isset($http_form_vars["nHeight"]) )
$nHeight = $http_form_vars["nHeight"];
/*
* REMOVED FOR SECURITY REASONS.
*
* TODO: replace with a globprefs include for non-session based apps if
* required.
*
if ( $szMSModName == "?" && isset($http_form_vars["gszPHPMapScriptModName"]) )
$szMSModName = $http_form_vars["gszPHPMapScriptModName"];
if ( $szTmpMapPath == "?" && isset($http_form_vars["gszTmpMapPath"]) )
$szTmpMapPath = $http_form_vars["gszTmpMapPath"];
if ( $szCurrentState == "?" && isset($http_form_vars["gszCurrentState"]) )
$szCurrentState = $http_form_vars["gszCurrentState"];
if ( $szQueryLayers == "?" && isset($http_form_vars["gszQueryLayers"]) )
$szQueryLayers = $http_form_vars["gszQueryLayers"];
if ( $szQueryCoords == "?" && isset($http_form_vars["gszQueryCoords"]) )
$szQueryCoords = $http_form_vars["gszQueryCoords"];
*/
// determine if in session
$sess_name = "sid";
// only setup session if set
if ( isset( $http_form_vars[$sess_name] ) )
{
initializeSession($sess_name);
// print_r($_SESSION);
// check for map name
if ( $szMapName == "?" && isset( $_SESSION["gszMapName"] ) )
$szMapName = $_SESSION["gszMapName"];
// check for map path
if ( $szMapPath == "?" && isset( $_SESSION["gszMapPath"] ) )
$szMapPath = $_SESSION["gszMapPath"];
// check for mapscript module name
if ( $szMSModName == "?" && isset( $_SESSION["gszPHPMapScriptModName"] ) )
$szMSModName = $_SESSION["gszPHPMapScriptModName"];
// an alternate session variable name for mapscript module
if ( $szMSModName == "?" && isset( $_SESSION["gszMapscriptModule"] ) )
$szMSModName = $_SESSION["gszMapscriptModule"];
// check for the temp mapfile path
if ( $szTmpMapPath == "?" && isset( $_SESSION["gszTmpMapPath"] ) )
$szTmpMapPath = $_SESSION["gszTmpMapPath"];
// check for the map session key
if ( $szCurrentState == "?" && isset( $_SESSION["gszCurrentState"] ) )
$szCurrentState = $_SESSION["gszCurrentState"];
// check for the query layers
if ( $szQueryLayers == "?" && isset( $_SESSION["gszQueryLayers"] ) )
$szQueryLayers = $_SESSION["gszQueryLayers"];
// check for the query co-ordinates
if ( $szQueryCoords == "?" && isset( $_SESSION["gszQueryCoords"] ) )
$szQueryCoords = $_SESSION["gszQueryCoords"];
// check for the error manager is set
if ( $oErrorManager == "?" && isset( $_SESSION["gErrorManager"] ) )
$oErrorManager =& $_SESSION["gErrorManager"];
// check for GD version
if ( $szGDVersion == "?" && isset( $_SESSION["gszGDVersion"] ))
$szGDVersion = $_SESSION["gszGDVersion"];
}
// default the map path if not set
if ( $szMapPath == "?" ) $szMapPath = dirname( $szMapName );
// default mapscript module name as a last resort
if ( $szMSModName == "?" )
{
// set according to OS
$szMSModName = ( (PHP_OS == "WINNT" || PHP_OS == "WIN32") ?
"php_mapscript.dll" : "php_mapscript.so" );
}
// default the temp map path as a last resort
if ( $szTmpMapPath == "?" ) $szTmpMapPath = dirname( $szMapName );
// default the statekey as a last resort
if ( $szCurrentState == "?" ) $szCurrentState = "";
// default the query co-ordinates if necessary
if ( $szQueryCoords == "?" ) $szQueryCoords = "0,0";
// check for trailing "/" in path names
$szTmpMapPath = str_replace("\\", "/", $szTmpMapPath);
if (substr($szTmpMapPath, -1) != "/") $szTmpMapPath .= "/";
$szMapPath = str_replace("\\", "/", $szMapPath);
if (substr($szMapPath, -1) != "/") $szMapPath .= "/";
$szMapName = str_replace("\\", "/", $szMapName);
if ( $szGDVersion == "?" )
$szGDVersion = "gd";
if (!extension_loaded( "gd" ))
{
$szGDMod = "php_".$szGDVersion.( (PHP_OS=="WINNT" || PHP_OS=="WIN32") ? ".dll" : ".so" );
dl( $szGDMod );
}
/** DEBUG
echo "MapName: $szMapName<br>";
echo "MapPath: $szMapPath<br>";
echo "ModuleName: $szMSModName<br>";
echo "TmpPath: $szTmpMapPath<br>";
echo "CurrentState: $szCurrentState<br>";
echo "QueryLayers: $szQueryLayers<br>";
echo "QueryCoords: $szQueryCoords<br>";
/*
$aszLog = explode(".", basename($_SERVER["PHP_SELF"]));
$gLogFile = new LogFile( $szTmpMapPath.$aszLog[0]."_drawmap.log", LOG_TO_FILE, true );
$gLogFile->setMaxLogLevel( LOG_ALL );
$gErrorManager = new ErrorManager();
$oLog = new Logger( "General" );
$oLog->setLogFile( $gLogFile );
$oLog->setErrorManager( $gErrorManager );
*/
// ensure that the mapscript module is loaded
if (!extension_loaded("MapScript")) dl($szMSModName);
/* ============================================================================
* Setup the map session & navigator classes
* ========================================================================= */
if ( $http_form_vars["map_session_mode"] == 0 )
{
// create a new map session object in read-only mode
$oMapSession = new MapSession_R;
}
else
{
// create a new map session object in read-write mode
$oMapSession = new MapSession_RW;
// set the temp directory for the map session
$oMapSession->setTempDir( $szTmpMapPath );
}
// $oMapSession->setLogFile( $gLogFile );
if ($oErrorManager != "?")
$oMapSession->setErrorManager( $oErrorManager );
/* ============================================================================
* Re-instate the previous map state
* ========================================================================= */
$oMapSession->restoreState( $szCurrentState, $szMapName, $szMapPath );
if ($nMinX != "?" && $nMinY != "?" &&
$nMaxX != "?" && $nMaxY != "?")
{
$oMapSession->oMap->setextent($nMinX, $nMinY, $nMaxX, $nMaxY);
}
if ($nWidth != "?" && $nHeight != "?")
{
$oMapSession->oMap->set("width", $nWidth);
$oMapSession->oMap->set("height", $nHeight);
}
/* ============================================================================
* Draw map
* ========================================================================= */
//$old_error_handler = set_error_handler("userErrorHandler");
//$GLOBALS['gaErrors'] = array();
$aMs = explode(" ", ms_GetVersion());
if (substr($aMs[2], 0, 3) >= "3.7")
{
// Init error stack
ms_ResetErrorList();
}
// run query if necessary
if ( isset($http_form_vars["run_query"]) &&
$http_form_vars["run_query"] == 1 )
{
// run query
runQuery( $oMapSession, $szQueryCoords, $szQueryLayers, $szURI );
// draw map with query
$oImage = @$oMapSession->oMap->drawQuery();
}
//keymap
else if (isset($http_form_vars["REQUEST"]) &&
(strcasecmp($http_form_vars["REQUEST"],"KEYMAP") == 0) &&
isset($http_form_vars["nWidth"]) &&
isset($http_form_vars["nHeight"]) &&
isset($http_form_vars["szImage"]) &&
isset($http_form_vars["dfKeyMapMinX"]) &&
isset($http_form_vars["dfKeyMapMinY"]) &&
isset($http_form_vars["dfKeyMapMaxX"]) &&
isset($http_form_vars["dfKeyMapMaxY"]) &&
isset($http_form_vars["szOriginalProjection"]) &&
isset($http_form_vars["szColor"]) &&
isset($http_form_vars["szOutlineColor"]))
{
//echo $oMapSession->oMap->reference->image;
DrawKeymap($oMapSession,
$http_form_vars["nWidth"],
$http_form_vars["nHeight"],
$http_form_vars["szImage"],
$http_form_vars["dfKeyMapMinX"],
$http_form_vars["dfKeyMapMinY"],
$http_form_vars["dfKeyMapMaxX"],
$http_form_vars["dfKeyMapMaxY"],
$http_form_vars["szOriginalProjection"],
$http_form_vars["szColor"],
$http_form_vars["szOutlineColor"]);
exit;
}
//scalebar
else if (isset($http_form_vars["REQUEST"]) &&
strcasecmp($http_form_vars["REQUEST"],"SCALEBAR") == 0)
{
$oImage = @$oMapSession->oMap->drawScaleBar();
}
else
{
// draw map
$oImage = $oMapSession->oMap->draw();
}
if (substr($aMs[2], 0, 3) >= "3.7")
{
$oError = ms_GetErrorObj();
while($oError && $oError->code > 0)
{
// Skip errors http
if ($oError->code != MS_HTTPERR)
$oErrorManager->setError(ERR_WARNING, $oError->message);
$oError = $oError->next();
}
}
if ($oImage == MS_FALSE)
{
if ($szFatalErrorImage != "?" &&
($fh = fopen($szFatalErrorImage, "r")) !== false)
{
switch(strtoupper(substr($szFatalErrorImage, -3)))
{
case "GIF":
header("Content-type: image/gif");
break;
case "PNG":
header("Content-type: image/png");
break;
case "JPG":
header("Content-type: image/jpeg");
break;
}
fpassthru($fh);
exit;
}
/*
else
{
$im = @imagecreate ($oMapSession->oMap->width, $oMapSession->oMap->height);
$background_color = imagecolorallocate ($im, 255, 255, 255);
$text_color = imagecolorallocate ($im, 233, 14, 91);
ImageStringWrap($im, "", 10, 10, implode("", getErrors()),
$text_color, $oMapSession->oMap->width);
header("Content-type: image/png");
imagepng ($im);
exit;
}
*/
}
else
{
/* ============================================================================
* Determine image support
* ========================================================================= */
//there is a problem in MS3.7 with MS_GIF not being defined because the output
//stuff has all changed. Hack for now if not defined
if (!defined( "MS_GIF" ))
define( "MS_GIF", 0 );
// check gif first
$aMs = explode(" ", ms_GetVersion());
if (substr($aMs[2], 0, 3) < "3.7")
{
if (strpos( ms_GetVersion(), "OUTPUT=GIF") > 0 )
{
// gif is supportted
$nImageType = MS_GIF;
}
elseif(strpos( ms_GetVersion(), "OUTPUT=PNG") > 0 )
{
// png is supportted
$nImageType = MS_PNG;
}
else
{
// default to JPEG
$nImageType = MS_JPEG;
}
// set the output type
switch ($nImageType)
{
case MS_GIF:
header("Content-type: image/gif");
break;
case MS_PNG:
header("Content-type: image/png");
break;
case MS_JPEG:
header("Content-type: image/jpeg");
break;
}
// output map
$url = $oImage->saveImage("", $nImageType, 0, 0, -1);
}
else
{
// set the output type
switch (strtoupper($oMapSession->oMap->imagetype))
{
case "GIF":
header("Content-type: image/gif");
break;
case "PNG":
case "PNG24":
header("Content-type: image/png");
break;
case "JPEG":
header("Content-type: image/jpeg");
break;
}
// output map
$url = $oImage->saveImage("");
}
}
/**
* This function takes the given query parameters and executes a query on the
* given map session's map object.
*
* @param $oMapSession object - Map Session object.
* @param $szQueryCoords string - Delimited string of co-ordinates.
* @param $szQueryLayers string - Comma delimited string of layer indexes.
* @return boolean - True if successful, False if not.
**/
function runQuery( $oMapSession, $szQueryCoords, $szQueryLayers )
{
// create a new map query object
$oMapQuery = new MapQuery( $oMapSession );
// process coordinates
$aszMinMax = explode( ";", $szQueryCoords );
$adMin = explode( ",", $aszMinMax[0] );
$adMax = explode( ",", $aszMinMax[1] );
// initialize var(s)
$aszLayers = array();
$oMap = $oMapSession->oMap;
// check to see if the list of layers has been supplied
if ( $szQueryLayers != "?" )
{
// get array of layers
$aszLayers = explode( $szQueryLayers );
// loop and get the name of each layer
for ( $i=0; $i<$nCount; $i++ )
{
// get layer
$oLayer = $oMap->getLayer( $aszLayers[$i] );
// update array to be name
$aszLayers[$i] = $oLayer->name;
}
}
else
{
// 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".
$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] );
// return success
return true;
}
function ImageStringWrap($image, $font, $x, $y, $text, $color, $maxwidth)
{
$fontwidth = ImageFontWidth($font);
$fontheight = ImageFontHeight($font);
if ($maxwidth != NULL)
{
$maxcharsperline = floor($maxwidth / $fontwidth);
$text = wordwrap($text, $maxcharsperline, "\n", 1);
}
$lines = explode("\n", $text);
while (list($numl, $line) = each($lines))
{
ImageString($image, $font, $x, $y, $line, $color);
$y += $fontheight;
}
}
function DrawKeyMap($oMapSession, $nWidth, $nHeight, $szImage, $dfKeyMapMinX,
$dfKeyMapMinY, $dfKeyMapMaxX, $dfKeyMapMaxY,
$szOriginalProjection, $szColor="", $szOutlineColor="")
{
$oMapSession->oMap->reference->set("image", $szImage);
$oMapSession->oMap->reference->set("status", MS_ON);
$oMapSession->oMap->reference->set("width", $nWidth);
$oMapSession->oMap->reference->set("height", $nHeight);
$szOriginalExtents = $dfKeyMapMinX.",".
$dfKeyMapMinY.",".
$dfKeyMapMaxX.",".
$dfKeyMapMaxY;
/* -------------------------------------------------------------------- */
/* Here is what is done : */
/* - Get the current extents of the map and reproject It to */
/* the keymap projection */
/* - use these new projected rectangle to draw the keymap red */
/* bbox manually on top of the keymap image. */
/* -------------------------------------------------------------------- */
$aMapExtents[0] = $oMapSession->oMap->extent->minx;
$aMapExtents[1] = $oMapSession->oMap->extent->miny;
$aMapExtents[2] = $oMapSession->oMap->extent->maxx;
$aMapExtents[3] = $oMapSession->oMap->extent->maxy;
$oNav = new MapNavigator( $oMapSession->oMapSession );
$adfKeyMapBBoxExtents = $oNav->reprojectExtentFromCenter(
$aMapExtents, $oMapSession->oMap->width,
$oMapSession->oMap->height, $oMapSession->oMap->getProjection(),
$szOriginalProjection);
if (!file_exists($szImage))
{
$_SESSION['gErrorManager']->setError(ERR_WARNING,
"ERROR: Key map image was not found in KeyMap.widget.php.");
}
else //keymap image found
{
/* -------------------------------------------------------------------- */
/* try to guess the format of the image using the extension. I */
/* thought the imagecreatefromgd would open any gd file but It */
/* does not work. */
/* Note : there is a gd function exif_imagetype which is */
/* supposed to work for version php4.3.0 but was not (at least */
/* on the windows binaries downloaded from php site) */
/* -------------------------------------------------------------------- */
//$nFileFormat = exif_imagetype($szImage);
//echo "$FileFormat = $nFileFormat <br>";
//var_dump(gd_info());
$szImage = trim($szImage);
$szFormat = "";
//is gif ?
if (imagetypes() & IMG_GIF)
{
$szFormat = stristr($szImage, "gif");
if ($szFormat != "")
$szFormat = "gif";
}
//is png
if (imagetypes() & IMG_PNG)
{
if ($szFormat == "")
{
$szFormat = stristr($szImage, "png");
if ($szFormat != "")
$szFormat = "png";
}
}
//is jpeg
if (imagetypes() & IMG_JPG)
{
if ($szFormat == "")
{
$szFormat = stristr($szImage, "jpg");
if ($szFormat == "")
$szFormat = stristr($szImage, "jpeg");
if ($szFormat != "")
$szFormat = "jpeg";
}
}
if ($szFormat == "")
{
$szValidFormats = "";
if (imagetypes() & IMG_GIF)
$szValidFormats .= "GIF (file_name.gif)";
if (imagetypes() & IMG_PNG)
{
if ($szValidFormats != "")
$szValidFormats .= " , ";
$szValidFormats .= "PNG (file_name.png)";
}
if (imagetypes() & IMG_JPG)
{
if ($szValidFormats != "")
$szValidFormats .= " , ";
$szValidFormats .= "JEPG (file_name.jpg)";
}
$_SESSION['gErrorManager']->setError(ERR_WARNING,
"ERROR: Could not determine the format of the keymap image : " .$szImage . ". Valid formats are" . $szValidFormats);
}
else //format found
{
if ($szFormat == "png")
$image = imagecreatefrompng($szImage);
else if ($szFormat == "gif")
$image = @imagecreatefromgif($szImage);
else
$image = imagecreatefromjpeg($szImage);
/* -------------------------------------------------------------------- */
/* get the values in pixels for the rectable bbox. */
/* -------------------------------------------------------------------- */
$dfDeltaGeoX = $adfKeyMapBBoxExtents[0] - $dfKeyMapMinX;
$dfDeltaGeoY = $adfKeyMapBBoxExtents[1] - $dfKeyMapMinY;
//minx, min y of the red bbox
$dfDeltaPixX = $dfDeltaGeoX * $nWidth /
($dfKeyMapMaxX - $dfKeyMapMinX);
$dfDeltaPixY = $dfDeltaGeoY * $nHeight /
($dfKeyMapMaxY - $dfKeyMapMinY);
//width, height of the red bbox
$dfWidthPixBBox = ($nWidth *
($adfKeyMapBBoxExtents[2] -
$adfKeyMapBBoxExtents[0]))/
($dfKeyMapMaxX - $dfKeyMapMinX);
$dfHeightPixBBox = ($nHeight *
($adfKeyMapBBoxExtents[3] -
$adfKeyMapBBoxExtents[1]))/
($dfKeyMapMaxY - $dfKeyMapMinY);
$nWhite = ImageColorAllocate($image, 255, 255, 255);
/* -------------------------------------------------------------------- */
/* set the color : */
/* */
/* - if the "COLOR" parameter is defined, we will use it to */
/* draw a filled rectangle. */
/* - if not and the "OUTLINECOLOR" is defined we will use it */
/* to draw a rectangle. */
/* - if none is defined we will use the red color to draw a rectangle.*/
/* -------------------------------------------------------------------- */
$nRectColor = -1;
$bDrawFillRectangle = 0;
if ($szColor != "")
{
$aColors = explode (" ", $szColor);
if ($aColors[0] >= 0 && $aColors[1] >= 0 && $aColors[2] >= 0 &&
$aColors[0] <= 255 && $aColors[1] <= 255 && $aColors[2] <= 255)
{
$nRectColor = ImageColorAllocate($image, $aColors[0], $aColors[1], $aColors[2]);
$bDrawFillRectangle = 1;
//keep the value for the JSAPI
$aOrigColor[0] = $aColors[0];
$aOrigColor[1] = $aColors[1];
$aOrigColor[2] = $aColors[2];
}
}
if ($nRectColor < 0)
{
if ($szOutlineColor != "")
{
$szColor = $szOutlineColor;
$aColors = explode (" ", $szColor);
if ($aColors[0] >= 0 && $aColors[1] >= 0 && $aColors[2] >= 0 &&
$aColors[0] <= 255 && $aColors[1] <= 255 && $aColors[2] <= 255)
$nRectColor = ImageColorAllocate($image, $aColors[0], $aColors[1], $aColors[2]);
$aOrigOutlineColor[0] = $aColors[0];
$aOrigOutlineColor[1] = $aColors[1];
$aOrigOutlineColor[2] = $aColors[2];
}
}
if ($nRectColor < 0)
{
$nRectColor = ImageColorAllocate($image, 255, 0, 0);
}
/* -------------------------------------------------------------------- */
/* set the colors to -1 so the refernce object won't draw the bbox.*/
/* -------------------------------------------------------------------- */
$oMapSession->oMap->reference->color->setRGB(-1, -1, -1);
$oMapSession->oMap->reference->outlinecolor->setRGB(-1, -1, -1);
/* -------------------------------------------------------------------- */
/* if the size of the box is less than 3 pixels, draw a cross. */
/* -------------------------------------------------------------------- */
if ($dfWidthPixBBox <=3 && $dfHeightPixBBox <=3)
{
$dfMiddleX = ($dfDeltaPixX + ($dfDeltaPixX + $dfWidthPixBBox))/2;
$dfMiddleY = (($nHeight - $dfDeltaPixY) + ($nHeight - ($dfDeltaPixY + $dfHeightPixBBox)))/2;
imageline($image, ($dfMiddleX -7), $dfMiddleY,
($dfMiddleX -2), $dfMiddleY, $nRectColor);
imageline($image, ($dfMiddleX +2), $dfMiddleY,
($dfMiddleX +7), $dfMiddleY, $nRectColor);
imageline($image, ($dfMiddleX), ($dfMiddleY -7),
($dfMiddleX), ($dfMiddleY -2), $nRectColor);
imageline($image, ($dfMiddleX), ($dfMiddleY +2),
($dfMiddleX), ($dfMiddleY +7), $nRectColor);
}
else
{
/* -------------------------------------------------------------------- */
/* if the color is set draw a filled rectangle, else draw a rectangle.*/
/* -------------------------------------------------------------------- */
if ($bDrawFillRectangle)
imagefilledrectangle($image,
$dfDeltaPixX,
($nHeight - ($dfDeltaPixY + $dfHeightPixBBox)),
($dfDeltaPixX + $dfWidthPixBBox),
($nHeight - $dfDeltaPixY), $nRectColor);
else
imagerectangle($image, $dfDeltaPixX,
($nHeight - $dfDeltaPixY),
($dfDeltaPixX + $dfWidthPixBBox),
($nHeight - ($dfDeltaPixY + $dfHeightPixBBox)),
$nRectColor);
}
if ($szFormat == "png")
imagepng($image);
else if ($szFormat == "gif")
imagegif($image);
else
imagejpeg($image);
} //end else format found
}//end else //keymap image found
/* -------------------------------------------------------------------- */
/* draw the image and output it. */
/* -------------------------------------------------------------------- */
$imgObj = $oMapSession->oMap->drawReferenceMap();
$szWebImage = $imgObj->saveWebImage();
/* ==================================================================== */
/* Temp solution for JS API. Set the values and use the */
/* drawmap.php functions to draw the keymap. */
/* ==================================================================== */
if (isset($this->maSharedResourceWidgets["CWCJSAPI"]))
{
$oMapSession->oMap->reference->set("image", realpath($szImage));
if (isset($aOrigColor) && count($aOrigColor) == 3)
{
$oMapSession->oMap->reference->color->setRGB(
$aOrigColor[0], $aOrigColor[1],
$aOrigColor[2]);
}
if (isset($aOrigOutlineColor) && count($aOrigOutlineColor) == 3)
{
$oMapSession->oMap->reference->outlinecolor->setRGB(
$aOrigOutlineColor[0],
$aOrigOutlineColor[1],
$aOrigOutlineColor[2]);
}
$oMapSession->oMap->reference->extent->setextent(
$dfKeyMapMinX, $dfKeyMapMinY,
$dfKeyMapMaxX, $dfKeyMapMaxY);
}
}
?>
--------------080402020905020007090008--
This archive was generated by Pipermail. |
MapTools.org -- Hosted by DM Solutions Group |