1. Import

This commit is contained in:
2026-03-29 10:34:57 +02:00
parent b0e00c1259
commit a1129565af
4899 changed files with 3007593 additions and 0 deletions

View File

@@ -0,0 +1,494 @@
<?
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// ALBasic
//
// Author: Christian Mähler
// Version: 9
// Last update: December 2002
//
// Base library for map&guide TCP/IP communication to
// address locator server and map&guide intranet server
// Batch Control is not supported (!)
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
class ALBasic
{
// common parameter as documented for the public user interface
var $BPParaBCPath; // old batch control path
var $BPParaRequestFileName; // filename of the file to be generated
var $BPBatchUrl; // URL where to find the file
var $BPPictureFormat; // format of picture to be generated
var $BPLogFilePath; // logfile path including filename!!
var $BPUseTCPIP; // use TCP/IP? should be always true because Batch Control is not supported with this class
var $BPMaximumFileAge; // maximum time for a file to stay on hard disk (in minutes)
var $BPStreamDirectory; // directory where to write the maps from the stream
var $BPMapsByStream; // send map as stream?
var $BPStreamToDisk; // write stream to hard disk?
var $BPMapStream; // contains map stream
var $eATCor; // AnswerType for BFGetParam = 1
var $eATAns; // AnswerType for BFGetParam = 0
var $BPALS; // list of all server as string
var $BPUrlNameMap; // name of map file (URL from docroot with filename)
var $BPMaxSocketWait; // time to wait for a server socket connect
var $BPCalcWait; // time to wait for the whole server request to finish including the search for this server
// this is not yet supported in PHP
// constants
var $BPStat_PropriError; // 0
var $BPStat_Error; // 1
var $BPStat_Success; // 2
var $BPGeoStat_Select; // 3
var $BPRouteStat_NoLocFound; // 4
// private variables
var $BPTCPAnswer; // TCP answer; every row in an array (BPTCPAnswer[ANS][0] == row 1 of server answer)
var $BPBCAnswer; // Hier steht die BC-Antwort. Jede Zeile in einem Array (BPBCAnswer[COR][0] == Zeile 1 der Zwischendatei)
var $BPFPTCP; // FileHandle for TCP communication
var $BPFileCount; // unique number for file to generate
var $BPRequest; // internal request string (necessary for BFAddParam)
var $BPALSTCP; // assoc. array with Name, IP, Port and state of the server
var $BCAnswerList; // contains an associative array with the content of the answer file
var $BPWINOS; // true if operating system is windows
var $BPUNIXOS; // true if operating system is UNIX
var $TCPtemp; // temporary variable for TCP/IP answer from server
// the following internal variables define the service to request at server side
// defined by ACTION or SUBACTION in request
var $BPGeoServiceNum;
var $NR_MAPREQUEST; // 2
var $NR_GEO; // 7
var $NR_ROUTEREQUEST_ROUTEID; // 30
var $NR_ROUTEREQUEST; // 3
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// ALBasic
// constructor for class ALBasic
function ALBasic()
{
set_time_limit(60); // set maximum execution time for PHP script
$this->BPMapsByStream=false; // maps are coming as stream by default
$this->BPLogFilePath=""; // set LogFilePath
$this->eATCor = 1; // const for correction part of server answer
$this->eATAns = 0; // const for answer part of server answer
$this->BPMaxSocketWait=60; // wait 60 seconds per server for a socket connect
$this->BPMaximumFileAge=10; // leave the generated maps 10 seconds as a maximum on hard disk
$this->BPStat_PropriError= 0; // unknown error
$this->BPStat_Error = 1; // known error
$this->BPStat_Success = 2; // success (one hit - geocoding)
$this->BPGeoStat_Select = 3; // success (multiple hits - geocoding)
$this->BPRouteStat_Select= 3; // should never happen (old value!)
$this->BPRouteStat_NoLocFound = 4; // should never happen (old value!)
$this->BPWINOS = false; // not used at the moment
$this->BPUNIXOS = false; // not used at the moment
$this->BFSetFileCount(); // get file count
$this->BPStreamToDisk=true;
// BPUrlNameMap = URL to map if correct parameters were passed
$this->BPUrlNameMap = $this->BPParaBCUrl . $this->BPParaRequestFileName . $this->BPFileCount; // . "." . $this->BPPictureFormat;
$this->Log_to_file("ALBasic.ALBasic: Passed successfully.");
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// BFGetTCPAnsLength
// Gets the length from the response stream in byte. The length is defined
// as a 12 byte string with leading 0s. E.g.: #0000000111#, answer is 111
// byte long
function BFGetTCPAnsLength($fp)
{
if (!$fp || feof($fp)) return 0;
$bufferArray = explode("#",fread($fp,12));
return ((int)$bufferArray[1])-11;
$this->Log_to_file("ALBasic.BFGetTCPAnsLength: Passed Succesfully");
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// BFReadALSAnswer
// Reads complete answer from TCP/IP stream and splits stream into
// COR (correction) and ANS (answer) parts. Every line is read into
// a single associative array
function BFReadALSAnswer($servicenum)
{
if($this->TCPtemp=="") return false;
// read complete answer stream into arrays
if ($servicenum==$this->NR_NEXTREQUEST || $servicenum==$this->NR_ROUTEREQUEST || $servicenum==$this->NR_GEOREQUEST)
{
$this->BPTCPAnswer["COR"] = explode("^", $this->TCPtemp[2]);
$this->BPTCPAnswer["ANS"] = explode("^", $this->TCPtemp[6]);
}
else
$this->BPTCPAnswer["ANS"] = explode("^", $this->TCPtemp[2]);
// read every single line of answer section ANS into an assoc. array
for ($i = 0; $i < count($this->BPTCPAnswer["ANS"])-1 ;$i++)
{
$tmp = explode("~", $this->BPTCPAnswer["ANS"][$i]);
$this->BCAnswerList["ANS"][$tmp[0]][$tmp[1]]=$tmp[2];
}
// read every single line of correction section COR into an assoc. array
if(is_array($this->BPTCPAnswer["COR"]))
for ($i = 0; $i < count($this->BPTCPAnswer["COR"])-1 ;$i++)
{
$tmp = explode("~", $this->BPTCPAnswer["COR"][$i]);
$this->BCAnswerList["COR"][$tmp[0]][$tmp[1]]=$tmp[2];
}
// read maps from stream if applicable
if($this->BPMapsByStream)
{
//[MAPS]
//MAPSTREAMS=<Picture name>,<Size>|<Picture name>,<Size>|<Picture name>,<Size>|...
$maps=explode("|",$this->BFGetParam($this->eATAns,"MAPS","MAPSTREAMS",""));
if(count($maps)>0)
{
for($i=0;$i<count($maps);$i++)
{
// read one dummy byte between ASCII stream and binary stream
// this strange behavior is necessary
if($i==0) $temp=fread($this->BPFPTCP,1);
// read map from stream
$mapstream=explode(",",$maps[$i]);
$temp = fread($this->BPFPTCP, $mapstream[1]);
$this->BPMapStream=array($i => $temp);
// write map to file
if($this->BPStreamToDisk && $this->BPStreamDirectory!="")
{
$fp=@fopen($this->BPStreamDirectory."/".$mapstream[0],"wb");
if($fp)
{
fwrite($fp,$temp);
fclose($fp);
}
else
$this->Log_to_file("ALBasic.BFReadALSAnswer: Error while writing map to hard disk: MapFile ".$this->BPStreamDirectory."/".$mapstream[0]);
}
}
srand ((double)microtime()*1000000);
if(rand(0,100)%2 == 0) // deletion is performed
$this->BFDeleteOldFiles();
}
}
$this->Log_to_file("ALBasic.BFReadALSAnswer: Passed Succesfully");
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// BFSetFileCount
// Get single name for the naming of the generated files. Has to be
// explicitly used by the user. This file count is not automatically
// added to a file name!
function BFSetFileCount()
{
$mytime=gettimeofday();
$this->BPFileCount = $mytime["sec"]."--".$mytime["usec"];
$this->Log_to_file("ALBasic.BFSetFileCount: Passed Succesfully");
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// BFBuildOrder()
// assembles request to server according to the content of the associative
// arrays containing the properties and their values
function BFBuildOrder()
{
$request="";
$separator="'^'";
// add user defined parameter for variables of ALBasic
if($this->BPPictureFormat!="")
$this->BPRequest["CLIENT"]["BPPICTUREFORMAT"]=$this->BPPictureFormat;
// build all values concerning SERVER section
reset($this->BPRequest["SERVER"]);
while (list($key, $value) = each ($this->BPRequest["SERVER"]))
$request .= "SERVER~$key~$value" . $separator;
// build all values concerning CLIENT section
reset($this->BPRequest["CLIENT"]);
while (list($key, $value) = each ($this->BPRequest["CLIENT"]))
$request .= "CLIENT~$key~$value" . $separator;
// build all values concerning special section (login) if applicable
// it's necesary for the function WRITE_OPTIONS where a section
// called after the login name is available
$login=strtoupper($this->BPRequest["CLIENT"]["LOGIN"]);
if (sizeof($this->BPRequest[$login])>0)
{
reset($this->BPRequest[$login]);
$numo=0;
while (list($key, $value) = each ($this->BPRequest[$login]))
{
$numo++;
$request .= $login."~OPTION".$numo."~$key^$value".$separator;
}
$request .= $login."~NUMOPTIONS~$numo".$separator;
}
// return ready built request
$this->Log_to_file("ALBasic.BFBuildOrder: Passed Succesfully: Request: #BAL##FN#".$this->BPParaRequestFileName."#ENDFN#" . $request . "#SEP#" . $separator . "#ENDSEP##ENDBAL#");
return "#BAL##FN#".$this->BPParaRequestFileName."#ENDFN#" . $request . "#SEP#" . $separator . "#ENDSEP##ENDBAL#\r\n";
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// BFWriteOrder
// Opens TCP/IP connection and sends request to server.
function BFWriteOrder($request)
{
// split list of all available servers
$serverlist=explode("^",$this->BPALS);
// check every server in round robin manner until timeout or connect
for($x=0;$x<count($serverlist);$x++)
{
// get next server from list
list($this->BPALSTCP["NAME"],$this->BPALSTCP["IP"],$this->BPALSTCP["PORT"],$this->BPALSTCP["ACTIVE"])=explode(",",$serverlist[$x]);
// if server is set to "active" in server list, try to connect
if((int)$this->BPALSTCP["ACTIVE"]==1)
{
// reset connection
$this->BPFPTCP = false;
// connect to IP and port of server
$this->BPFPTCP = @fsockopen ($this->BPALSTCP["IP"], $this->BPALSTCP["PORT"], &$errno, &$errstr, $this->BPMaxSocketWait);
// if connection was enabled, write request
if ($this->BPFPTCP && !feof($this->BPFPTCP))
{
$answerlength=0;
$starttime=time();
while($answerlength<100 && (time()-$starttime<5) && $this->BPFPTCP && !feof($this->BPFPTCP))
{
// write request
@fputs ($this->BPFPTCP,$request);
$this->Log_to_file("ALBasic.BFWriteOrder: succesful server connect: Server: ".$this->BPALSTCP["IP"].":".$this->BPALSTCP["PORT"]);
// get answer length
$answerlength=$this->BFGetTCPAnsLength($this->BPFPTCP);
// #0000000024##DISABLED##ENDDISABLED#
// #0000000037##BUSY#<Milliseconds_working>~<TreadID>#ENDBUSY#
// #0000000042##ERROR#<Error description>#ENDERROR#
$this->TCPtemp="";
$errno=$answerlength;
// if answer length is less than 100, we received an error from server
if($answerlength<100)
{
if($answerlength>0)
$tcptmp=fgets($this->BPFPTCP, $answerlength);
if($answerlength==24)
$this->Log_to_file("ALBasic.BFWriteOrder: Server is disabled: Server: ".$this->BPALSTCP["IP"].":".$this->BPALSTCP["PORT"]." server answer: ".$tcptmp);
else
if($answerlength>0)
$this->Log_to_file("ALBasic.BFWriteOrder: Server error: Server: ".$this->BPALSTCP["IP"].":".$this->BPALSTCP["PORT"]." server answer: ".$tcptmp);
else
$this->Log_to_file("ALBasic.BFWriteOrder: Server error: Server: ".$this->BPALSTCP["IP"].":".$this->BPALSTCP["PORT"]." server answer: none");
fclose($this->BPFPTCP);
usleep(300); // dos not work with windows
$this->BPFPTCP = @fsockopen ($this->BPALSTCP["IP"], $this->BPALSTCP["PORT"], &$errno, &$errstr, $this->BPMaxSocketWait);
}
else
{
$this->TCPtemp = explode("#", fgets($this->BPFPTCP, $answerlength));
return $answerlength;
break;
}
} // try to send request to one server (end while)
}
else
{
$this->Log_to_file("ALBasic.BFWriteOrder: Error while writing to socket: Server: ".$this->BPALSTCP["IP"].":".$this->BPALSTCP["PORT"]);
} // end server connect
} // server active
} // end for
if($this->TCPtemp=='')
$this->Log_to_file("ALBasic.BFWriteOrder: Passed without server connect");
else
$this->Log_to_file("ALBasic.BFWriteOrder: Passed Succesfully");
return $errno;
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// BFCheckParam
// Check whether all necessary parameters are available dependent on
// the service requested by the server.
// returns clear text error message
function BFCheckParam($servicenum)
{
$err_msg='';
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// common parameters
if ($this->BPALS == "")
$err_msg = "Warning: No server defined!";
elseif (($servicenum==$this->NR_MAPREQUEST || $servicenum==$this->NR_ROUTINGREQUEST) && $this->BPParaRequestFileName == "")
$err_msg = "Warning: No name for file to generate!";
$this->Log_to_file("ALBasic.BFCheckParam: Regular error message: ".$err_msg);
if($err_msg!='')
{
if ($servicenum == $this->NR_GEOREQUEST)
$this->GeoResponse = $err_msg;
if ($servicenum == $this->NR_MAPREQUEST)
$this->MapResponse = $err_msg;
if ($servicenum == $this->NR_ROUTINGREQUEST)
$this->RouteResponse = $err_msg;
return $this->BPStat_Error;
}
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// error messages for geocoding service
if ($servicenum == $this->NR_GEOREQUEST)
{
if ($this->ParaRequestType == "")
{
if ($servicenum == $this->NR_GEOREQUEST)
$this->GeoResponse = "Warning: Parameter ParaRequestType not defined!";
$this->Log_to_file("ALBasic.BFCheckParam: Regular error message (geocoding): ".$this->GeoResponse);
return $this->BPStat_Error;
}
}
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// error messages for mapping service
if ($servicenum == $this->NR_MAPREQUEST)
{
if ($this->MapRequestRect == "" and $this->MapObjectList == "" and $this->BPRequest[CLIENT][LOGICALRECT]=="" and $this->BPRequest[CLIENT][CST1] =="")
{
$this->MapResponse = "Warning: No bounding rect and no objects defined!";
$this->Log_to_file("ALBasic.BFCheckParam: Regular error message (geocoding): ".$this->GeoResponse);
return $this->BPStat_Error;
}
}
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// error messages for routing service
if ($servicenum == $this->NR_ROUTINGREQUEST)
{
if (($this->RouteStation[1] == "" and $this->RouteStation[2] == "")
and (($this->BPRequest["CLIENT"]["STATION1"]=="") and ($this->BPRequest["CLIENT"]["STATION2"]=="") ))
{
$this->RouteResponse = "Warning: No starting and destination point defined!";
$this->Log_to_file("ALBasic.BFCheckParam: Regular error message (routing): ".$this->RouteResponse);
return $this->BPStat_Error;
}
}
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// error messages for next search service
if ($servicenum == $this->NR_NEXTREQUEST)
{
if($this->SearchByCoord=="" && $this->SearchByTown=="")
{
$this->Response = "Warning: No search statement as SearchByTown or SearchByCoord defined!";
$this->Log_to_file("ALBasic.BFCheckParam: Regular error message (next search): ".$this->Response);
return $this->BPStat_Error;
}
}
$this->Log_to_file("ALBasic.BFCheckParam: Passed Succesfully");
return $this->BPStat_Success;
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// BFAddParam
// add a property to the request without recheck by system
function BFAddParam($app, $key, $value)
{
$this->BPRequest[strtoupper($app)][strtoupper($key)] = $value;
$this->Log_to_file("ALBasic.BFAddParam: Passed successfully: ".$app." ".$key." ".$value);
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// BFGetParam
// read a property directly from COR or ANS part of the TCP/IP answer
function BFGetParam($answer_type, $section, $name, $def_value)
{
(($answer_type == $this->eATAns) ? $file = "ANS" : $file = "COR");
if($this->BCAnswerList[$file][strtoupper($section)][$name]!="")
return $this->BCAnswerList[$file][strtoupper($section)][$name];
$this->Log_to_file("ALBasic.BFGetParam: Passed successfully: ".$answer_type." ".$section." ".$name." ".$def_value);
return $def_value;
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// BFDeleteOldFiles
// delete old files which are older than BPMaximumFileAge by random
// because it takes a lot of time to check and delete files, we only
// delete every second map generation.
function BFDeleteOldFiles()
{
if(!$this->BPMapsByStream || $this->BPStreamDirectory=="") return false;
$handle = opendir($this->BPStreamDirectory."/");
while (($file = readdir($handle))!==false)
if($file!="." && $file!="..")
if( (time()-filemtime($this->BPStreamDirectory."/".$file))>$this->BPMaximumFileAge*60)
if(!unlink($this->BPStreamDirectory."/".$file))
$this->Log_to_file("AlBasic.BFDeleteOldFiles: Error while deltin old map files on hard disk. Path: ".$this->BPStreamDirectory);
$this->Log_to_file("AlBasic.BFDeleteOldFiles: Passed successfully . Path: ".$this->BPStreamDirectory);
// deletion was performed
return true;
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Log_to_file
// write log output to file defined by BPLogFilePath
function Log_to_file($logtext)
{
if($this->BPLogFilePath=='')
return false;
$fp=@fopen($this->BPLogFilePath,"a");
if($fp)
{
fwrite($fp,$logtext."\r\n");
fclose($fp);
}
else
echo "<br>Error while writing to log file<br>";
return false;
}
} // end of class definition
?>

View File

@@ -0,0 +1,358 @@
<?
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// ALGeo
//
// Author: Christian Mähler
// Version: 9
// Last update: December 2002
//
// Base library for map&guide geocoding functionality.
// Please note that only English speaking properties are used
// there is no support for German speaking properties as
// known by the original COM objects under Windows
//
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//++++++++++ INCLUDE ++++++++++++++++++++++++++//"
@include_once(dirname(__FILE__)."/ALBasic.inc.php");
//+++++++++++++++++++++++++++++++++++++++++++++//"
class ALGeo extends ALBasic
{
// public variables for reading and writing data
var $GeoZIP; // ZIP (put + get)
var $GeoTown; // town
var $GeoDistrict; // district (put + get)
var $GeoStreet; // street (put + get)
var $GeoCoordinate; // coordinates in format "x/y" (put + get)
var $GeoCoordinateX; // x coordinate (put + get)
var $GeoCoordinateY; // y coordinate (put + get)
var $GeoCountry; // country (put + get)
var $GeoTownID; // town ID (put + get)
var $GeoHousenumber; // house number (put + get)
var $GeoResponse; // response from geo object (get)
var $ParaRequestType; // type of option list to be built in res_town_2 (put)
var $ParaUseHNr; // use the house number in a single field? (put)
var $ParaMap; // generate map? (put)
var $ShowDistrict; // show detailed information while geocoding (put)
var $MaxNumNearest; // how many geocoding results at maximum?? (put)
// private variables
var $BPGeoServiceNum; // internal service number
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Constructor
// set all parameters, necessary for geocoding. Contructor sets default
// parameter
function ALGeo()
{
$this->ALBasic();
$this->ParaMap=false;
$this->ShowDistrict=false;
$this->MaxNumNearest=1000;
$this->NR_GEOREQUEST=7; // don't change this value!!
$this->Log_to_file("ALGeo.ALGeo: Constructor passed successfully");
$this->BPGeoServiceNum=1099; // base number for internal service
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// SetOrder
// build request string depending on internal values as ACTION and
// based on the request as defined by the user
function SetOrder()
{
$this->BPRequest["SERVER"]["ACTION"] = 7;
$this->BPRequest["CLIENT"]["SUBACTION"] = 1;
$this->BPRequest["CLIENT"]["MAP"] = (($this->ParaMap) ? "TRUE" : "FALSE");
$this->BPRequest["CLIENT"]["SHOWDISTRICT"] = (($this->ShowDistrict) ? "TRUE" : "FALSE");
$this->BPRequest["CLIENT"]["MAPSBYSTREAM"] = (($this->BPMapsByStream) ? "TRUE" : "FALSE");;
$this->BPRequest["CLIENT"]["SEARCH"] = $this->GeoCountry . $this->GeoZIP . "," . $this->GeoTown .",". $this->GeoDistrict .",". $this->GeoStreet ." ". $this->GeoHousenumber .",,";
$this->BPRequest["CLIENT"]["REQUEST"] = "TRUE";
if ($this->ShowDistrict && $this->MaxNumNearest)
$this->BPRequest["CLIENT"]["MAXNUMNEAREST"] = $this->MaxNumNearest;
$this->Log_to_file("ALGeo.SetOrder: Passed successfully");
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Res_town_0
// no hits found, answer with error code
function res_town_0()
{
$this->GeoResponse = "Error: Your geocoding request could not be handled.";
$this->Log_to_file("ALGeo.res_town_0: Passed successfully. No results found for geocoding");
return $this->BPStat_Error;
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Res_town_1
// exactly one hit found, answer is presented at object properties and
// not as a string in one property
function res_town_1($res_array_)
{
$errco = $this->BFGetParam(0,"SERVER","ERRORCODE","0");
if($errco=="0")
{
$temp = explode(",", $this->BFGetParam(0,"VORSCHLAG1","ORTE1",","));
// fill public variables with values (list(<valuelist>)=array(values))
list($this->GeoZIP,$this->GeoTown,$this->GeoDistrict,$this->GeoStreet,$this->GeoTownID,$this->GeoCoordinateX,$this->GeoCoordinateY)=$temp;
$this->GeoCoordinate = $this->GeoCoordinateX ."/" . $this->GeoCoordinateY;
}
// build a list as known for multiple results (in HTML format = 1)
$this->res_town_2($res_array_,1);
$this->Log_to_file("ALGeo.res_town_1: Passed successfully. One hit found for geocoding");
return $this->BPStat_Success;
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Res_town_2
// more than one hit found, build result string according to prefered format
function res_town_2($res_array_, $countorte_)
{
$pararequest_jc = 0;
$pararequest_html = 1;
$pararequest_full = 2;
$pararequest_coord = 3;
$pararequest_id_coord = 4;
$split = "~";
$num = 2;
$begin = 1;
$end = 0;
switch ($this->ParaRequestType)
{
// +++++++++++++++++++++++++++ $pararequest_jc = 0
case $pararequest_jc :
{
// for every hit
for($i=$begin; $i<=$countorte_+$end ; $i++)
{
$temp = explode($split, $res_array_[$i]);
// build answer string
if(substr($temp[1],0,4)=="ORTE")
{
$temp = explode(",", $temp[$num]);
$erg .= "$temp[0] $temp[1] $temp[2] $temp[3] $temp[4] $temp[5] $temp[6] <br>";
}
} // for
$this->GeoResponse = $erg;
$this->Log_to_file("ALGeo.res_town_2: Passed successfully: pararequest_jc ");
return $this->BPGeoStat_Select;
break;
}
// +++++++++++++++++++++++++++ $pararequest_html = 1
case $pararequest_html :
{
// for every hit found
for($i=$begin; $i<=$countorte_+$end ; $i++)
{
$temp = explode($split, $res_array_[$i]);
if(substr($temp[1],0,4)=="ORTE")
{
$temp = explode(",", $temp[$num]);
// build option tag which can be used directly in
// HTML select statements. Use fpr values only the
// town id
if ($i == $begin)
{
$select_tag = "<option selected value=\"$temp[4]\">";
$select_tag = $select_tag . "$temp[0] $temp[1] $temp[2] $temp[3]";
}
else
{
$select_tag = $select_tag . "<option value=\"$temp[4]\">";
$select_tag = $select_tag . "$temp[0] $temp[1] $temp[2] $temp[3]";
}
}
} // for
$this->Log_to_file("ALGeo.res_town_2: Passed successfully: pararequest_html ");
$this->GeoResponse = $select_tag;
return $this->BPGeoStat_Select;
break;
}
// +++++++++++++++++++++++++++ $pararequest_full = 2
case $pararequest_full :
{
for($i=$begin; $i<=$countorte_+$end ; $i++)
{
$temp = explode($split, $res_array_[$i]);
if(substr($temp[1],0,4)=="ORTE")
{
$temp = explode(",", $temp[$num]);
// build option tag which can be used directly in
// HTML select statements. Use for values all
// parameters
if ($i == $begin)
{
$select_tag = "<option selected value=\"$temp[0]|$temp[1]|$temp[2]|$temp[3]|$temp[4]|$temp[5]|$temp[6]|$this->GeoPLZ|$this->GeoHauptOrt|$this->GeoTeilOrt|$this->GeoStrasse|$this->GeoHausnummer\">";
$select_tag = $select_tag . "$temp[0] $temp[1] $temp[2] $temp[3]";
}
else
{
$select_tag = $select_tag . "<option value=\"$temp[0]|$temp[1]|$temp[2]|$temp[3]|$temp[4]|$temp[5]|$temp[6]\">";
$select_tag = $select_tag . "$temp[0] $temp[1] $temp[2] $temp[3]";
}
}
} // for
$this->GeoResponse = $select_tag;
$this->Log_to_file("ALGeo.res_town_2: Passed successfully: pararequest_full ");
return $this->BPGeoStat_Select;
break;
} // case 2
// +++++++++++++++++++++++++++ $pararequest_coord = 3
case $pararequest_coord :
{
for($i=$begin; $i<=$countorte_+$end ; $i++)
{
$temp = explode($split, $res_array_[$i]);
// build option tag which can be used directly in
// HTML select statements. Use for values
// the coordinates only
if(substr($temp[1],0,4)=="ORTE")
{
$temp = explode(",", $temp[$num]);
if ($i == $begin)
{
$select_tag = "<option selected value=\"$temp[5]/$temp[6]\">";
$select_tag = $select_tag . "$temp[0] $temp[1] $temp[2] $temp[3]";
}
else
{
$select_tag = $select_tag . "<option value=\"$temp[5]/$temp[6]\">";
$select_tag = $select_tag . "$temp[0] $temp[1] $temp[2] $temp[3]";
}
}
} // for
$this->GeoResponse = $select_tag;
$this->Log_to_file("ALGeo.res_town_2: Passed successfully: pararequest_coord ");
return $this->BPGeoStat_Select;
break;
}
// +++++++++++++++++++++++++++ $pararequest_id_coord = 4
case $pararequest_id_coord :
{
for($i=$begin; $i<=$countorte_+$end ; $i++)
{
$temp = explode($split, $res_array_[$i]);
// build option tag which can be used directly in
// HTML select statements. Use for values
// the coordinates and the town id only
if(substr($temp[1],0,4)=="ORTE")
{
$temp = explode(",", $temp[$num]);
if ($i == $begin)
{
$select_tag = "<option selected value=\"$temp[4]|$temp[5]/$temp[6]\">";
$select_tag = $select_tag . "$temp[0] $temp[1] $temp[2] $temp[3]";
}
else
{
$select_tag = $select_tag . "<option value=\"$temp[4]|$temp[5]/$temp[6]\">";
$select_tag = $select_tag . "$temp[0] $temp[1] $temp[2] $temp[3]";
}
}
} // for
$this->GeoResponse = $select_tag;
$this->Log_to_file("ALGeo.res_town_2: Passed successfully: pararequest_id_coord ");
return $this->BPGeoStat_Select;
break;
}
}// switch pararequesttype
}//function res_town_2
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// CheckRes
// check how many hits were found and build answer accordingly
function CheckRes($countorte)
{
// +++++++++++++++ no hit found ++++++++++++++++++++
if ($countorte == 0) return $this->res_town_0();
// +++++++++++++++ exactly one hit found +++++++++++++++++++
if ($countorte == 1) return $this->res_town_1($this->BPTCPAnswer["ANS"]);
// +++++++++++++++ multiple hits found ++++++++++++++++++
if ($countorte >= 2) return $this->res_town_2($this->BPTCPAnswer["ANS"], $countorte);
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// GeoRequest
// send geocoding request to server. the geocoding is based on the
// geocoding algorithm for address locator server. for map&guide-like
// geocoding please use the function MGSearchLocation in class MGClient
function GeoRequest()
{
// check parameter
if (($this->BPStat_Error == $this->BFCheckParam($this->NR_GEOREQUEST)) || ($this->BPMapsByStream && $this->BPStreamDirectory==''))
{
$this->Log_to_file("ALGeo.GeoRequest: Too less parameters ");
return $this->BPStat_Error;
}
// set request type
$this->SetOrder();
// build request
$reqerr=$request = $this->BFBuildOrder();
// send request to server
$answerlength=$this->BFWriteOrder($request);
// if length is less than 45 byte, we had an error
if($answerlength>45)
{
// receive answer
$reqerr=$this->BFReadALSAnswer($this->NR_GEOREQUEST);
// return result code
// count number of hits
$countorte = intval($this->BFGetParam($this->eATAns, "VORSCHLAG1","NUMORTE",-1));
return $this->CheckRes($countorte);
}
else
return $this->BPStat_Error;
}
} //end of class definition
?>

View File

@@ -0,0 +1,164 @@
<?
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// ALMap
//
// Author: Christian Mähler
// Version: 9
// Last update: December 2002
//
// Base library for map&guide mapping functionality
// Please note that only English speaking properties are used
// there is no support for German speaking properties as
// known by the original COM objects under Windows
//
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//++++++++++ INCLUDE ++++++++++++++++++++++++++//"
@include_once(dirname(__FILE__)."/ALBasic.inc.php");
//+++++++++++++++++++++++++++++++++++++++++++++//"
class ALMap extends ALBasic
{
// public variables for reading and writing data
var $ParaBitmapPath; // where to find the bitmaps on the map server (not on web server!)
var $ShowCustomers; // show address layer in map?
var $VisibleCustomers; // which address layer to show?
var $MapObjectList; // objects to be drawn in map
var $MapRequestRect; // rectangle of map to be drawn
var $MapResponse; // answer from map object
// private variables for internal map object usage
var $mapfilename; // filename for map
var $arr_cst; // array containing the CST (objects to draw in map)
var $num_cst; // number of CST (objects to draw in map)
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// ALMap - Constructor
// set default parameters to object
function ALMap()
{
$this->ALBasic();
$this->NR_MAPREQUEST=2; // base number for server ACTION
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// CheckRes
// does the result consist of all necessary information?
function CheckRes()
{
if ($this->BFGetParam($this->eATAns,"SERVER","LOGICALRECT","0,0,0,0")=="0,0,0,0" )
{
$this->MapResponse = "Mapping error";
return $this->BPStat_Error;
}
else
return $this->BPStat_Success;
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// GetCSTCount
// splits an objectlist and finds number of CST entries
function GetCSTCount()
{
$tmp = explode("^", $this->MapObjectList);
$this->num_cst = count($tmp);
for ($i = 1; $i<= count($tmp);$i++)
$this->arr_cst[$i] = $tmp[$i-1];
$this->Log_to_file("ALMap.GetCSTCount: passed successfully: hits: ".count($tmp));
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// SetOrder
// set all parameters, necessary for geocoding
function SetOrder()
{
$this->BPRequest["SERVER"]["ACTION"] = 2;
$this->BPRequest["CLIENT"]["REQUEST"] = "TRUE";
$this->BPRequest["CLIENT"]["MAPSBYSTREAM"] = (($this->BPMapsByStream) ? "TRUE" : "FALSE");
// add logical rect for map if applicable
if (!empty($this->MapRequestRect))
$this->BPRequest["CLIENT"]["LOGICALRECT"] = $this->MapRequestRect;
// add list of customer tables (address layer) to be drawn in map
if (strtoupper($this->ShowCustomers) == "TRUE")
{
$this->BPRequest["CLIENT"]["SHOWCUSTOMERS"] = $this->ShowCustomers;
if (!empty($this->VisibleCustomers))
$this->BPRequest["CLIENT"]["VISIBLECUSTOMERS"] = $this->VisibleCustomers;
}
else
if (!empty($this->ShowCustomers))
$this->BPRequest["CLIENT"]["SHOWCUSTOMERS"]= $this->ShowCustomers;
// where to find bitmaps for draawing objects in map on map server
if (!empty($this->ParaBitmapPath))
$this->BPRequest["CLIENT"]["BITMAPPATH"] = $this->ParaBitmapPath;
// if we have a non-empty objectlist, we have to build the CST entries
if (!empty($this->MapObjectList))
{
$this->GetCSTCount();
for ($i = 1 ; $i<$this->num_cst ; $i++)
{
$cst = "CST" . $i;
$this->BPRequest["CLIENT"][$cst] = $this->arr_cst[$i];
}
}
$this->Log_to_file("ALMap.SetOrder: passed successfully");
} // SetOrder
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// MapRequest
// build request, send request, get answer and check answer
function MapRequest()
{
// check parameter
if ($this->BPStat_Error == $this->BFCheckParam($this->NR_MAPREQUEST))
{
$this->Log_to_file("ALMap.MapRequest: Too less parameters ");
return $this->BPStat_Error;
}
// set request type
$order = $this->SetOrder();
// build request
$request = $this->BFBuildOrder();
// send request
$answerlength=$this->BFWriteOrder($request);
// if length is less than 45 byte, we had an error
if($answerlength>45)
{
// receive answer
$this->BFReadALSAnswer($this->NR_MAPREQUEST);
// return result code
return $this->CheckRes();
}
else
return $this->BPStat_Error;
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// MapRequestRect
// returns bounding rect
function MapRequestRect()
{
return $this->BFGetParam($this->eATAns,"SERVER","LOGICALRECT","0,0,0,0");
}
}// end of class definition

View File

@@ -0,0 +1,224 @@
<?
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// ALNext
//
// Author: Christian Mähler
// Version: 9
// Last update: January 2003
//
// Base library for map&guide next search functionality.
// Please note that only English speaking properties are used
// there is no support for German speaking properties as
// known by the original COM objects under Windows
//
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//++++++++++ INCLUDE ++++++++++++++++++++++++++//"
@include_once(dirname(__FILE__)."/ALBasic.inc.php");
//+++++++++++++++++++++++++++++++++++++++++++++//"
class ALNext extends ALBasic
{
// public variables for reading and writing data
var $Filter1; // filter for address layer search
var $Filter2; // filter for address layer search
var $Filter3; // filter for address layer search
var $Filter4; // filter for address layer search
var $Filter5; // filter for address layer search
var $ShowInfo; // show CST entries in the result
var $Response; // response string for error messages
var $RowCount; // count nunber of results (CST)
var $ShowCompleteRadius; // show the search radius as map radius and not the radius defined by the result
var $SearchByCoord; // search string for direct search around coordinates
var $SearchByTown; // search string for search around a city with geocoding
var $Customers; // define list of address layer to be searched
var $Filter; // add filter to search
var $ReturnFields; // define returnfields
var $ShowCompleteRadius; // show complete radius of search
var $AddToMap; // add additional info to map?
var $ShowInfo; //
var $GraphFilter; // use this grahical filter for search
var $ExportFile; // define an export file where the result is written to as CSV
var $NextID; // define the NextID returned after a radius search for fast zomming
var $ShowInitRect; // add the variable SHOWINITRECT to the request string
var $Logicalrect; // logicalrect to draw
var $ShowSpiderLines; // show spiderlines from center to hits
var $TrafficInfoIDs; // show these traffic info ID
var $VisibleCustomers; // list of layers to show
var $ShowCustomers; // show additional layer ?
var $UsePin; // show the pin in the map after a radius search
var $FileName; // define filename for map
// private variables
var $NR_NEXTREQUEST; // internal service number
var $temp_row; // needed by ReadRow and FieldValue
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Constructor
// set all parameters, necessary for geocoding. Contructor sets default
// parameter
function ALNext()
{
$this->ALBasic();
$this->NR_NEXTREQUEST=1; // don't change this value!!
$this->Customers=""; // set default values
$this->GraphFilter="";
$this->AddToMap=false;
$this->ShowInfo=true;
$this->RowCount=0;
$this->Log_to_file("ALNext.ALNext: Constructor passed successfully");
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// SetOrder
// build request string depending on internal values as ACTION and
// based on the request as defined by the user
function SetOrder()
{
$this->BPRequest["SERVER"]["ACTION"] = $this->NR_NEXTREQUEST;
$this->BPRequest["CLIENT"]["MAPSBYSTREAM"] = (($this->BPMapsByStream) ? "TRUE" : "FALSE");
$this->BPRequest["CLIENT"]["REQUEST"] = "TRUE";
$this->BPRequest["CLIENT"]["CUSTOMERS"] = $this->Customers;
$this->BPRequest["CLIENT"]["GRAPHFILTER"] = $this->GraphFilter;
if($this->SearchByCoord!="")
$this->BPRequest["CLIENT"]["SEARCHBYCOORD"]=$this->SearchByCoord;
else
$this->BPRequest["CLIENT"]["SEARCHBYTOWN"]=$this->SearchByTown;
$this->BPRequest["CLIENT"][$this->Customers."RETURNFIELDS"] = $this->ReturnFields;
$this->BPRequest["CLIENT"]["ADDTOMAP"] = (($this->AddToMap) ? "TRUE" : "FALSE");;
if($this->Filter1!="") $this->BPRequest["CLIENT"][$this->Customers."FILTER1"]==$this->Filter1;
if($this->Filter2!="") $this->BPRequest["CLIENT"][$this->Customers."FILTER2"]==$this->Filter2;
if($this->Filter3!="") $this->BPRequest["CLIENT"][$this->Customers."FILTER3"]==$this->Filter3;
if($this->Filter4!="") $this->BPRequest["CLIENT"][$this->Customers."FILTER4"]==$this->Filter4;
if($this->Filter5!="") $this->BPRequest["CLIENT"][$this->Customers."FILTER5"]==$this->Filter5;
$this->BPRequest["CLIENT"]["SHOWINFO"] = (($this->ShowInfo) ? "TRUE" : "FALSE");
$this->Log_to_file("ALNext.SetOrder: Passed successfully");
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// ReadRow
// read row with number RowNum into internal object cache
// values can be read by FieldValue
function ReadRow($RowNum)
{
if($RowNum<0 || $RowNum>$this->RowCount || !$this->ShowInfo)
{
$this->Log_to_file("ALNext.ReadRow: row number too large or no CST available ");
return "";
}
$this->temp_row=$this->BFGetParam(0,"SERVER","CST".$RowNum,"");
return $this->temp_row;
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// FieldValue
// read from current row (defined by ReadRow) the content of the
// column with the name fName. The list of fName was defined by ReturnFields
function FieldValue($fName)
{
if($fName=="" || !$this->ShowInfo || $this->temp_row=="")
{
$this->Log_to_file("ALNext.FieldValue: field name is empty or no CST available or no row read by ReadRow() ");
return "";
}
$temp_col=explode(",",$this->ReturnFields);
$i=0;
$col_num=-1;
foreach($temp_col as $key => $value)
if($key==$fName)
$col_num=$i;
else
$i++;
if ($col_num==-1)
return "";
else
{
$temp_row_content=explode(",",$temp_row);
return $temp_row_content[$col_num];
}
return "";
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// CheckRes
// check how many hits were found and build answer accordingly
function CheckRes()
{
if ($this->BFGetParam(0,strtoupper($this->Customers),"NUMCST","")=="" )
{
$this->Response = "Next search error";
$this->Log_to_file("ALNext.NextRequest: no NUMCST in result ");
return $this->BPStat_Error;
}
else
return $this->BPStat_Success;
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Execute
// send next search request to server. the next search is based on an
// address layer known by the server
function NextSearch()
{
return $this->Execute();
}
function Execute()
{
// check parameter
if (($this->BPStat_Error == $this->BFCheckParam($this->NR_NEXTREQUEST)) || ($this->BPMapsByStream && $this->BPStreamDirectory==''))
{
$this->Log_to_file("ALNext.NextRequest: Too less parameters ");
return $this->BPStat_Error;
}
// set request type
$this->SetOrder();
// build request
$reqerr=$request = $this->BFBuildOrder();
// send request to server
$answerlength=$this->BFWriteOrder($request);
// if length is less than 45 byte, we had an error
if($answerlength>45)
{
// receive answer
$reqerr=$this->BFReadALSAnswer($this->NR_NEXTREQUEST);
$this->RowCount=intval($this->BFGetParam(0,strtoupper($this->Customers),"NUMCST","0"));
$this->Logicalrect=$this->BFGetParam(0,"SERVER","LOGICALRECT","");
// return result code
// count number of hits
return $this->CheckRes();
}
else
return $this->BPStat_Error;
}
} //end of class definition
?>

View File

@@ -0,0 +1,354 @@
<?
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// ALRoute
//
// Author: Christian Mähler
// Version: 9
// Last update: December 2002
//
// Base library for map&guide routing functionalty
//
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//++++++++++ INCLUDE ++++++++++++++++++++++++++//"
@include_once(dirname(__FILE__)."/ALBasic.inc.php");
//+++++++++++++++++++++++++++++++++++++++++++++//"
class ALRoute extends ALBasic
{
// public variables for reading and writing data
var $RouteStation; // adding stations to the routing request
// NOTE: use BfAddParam to add STATION<x>
// to the request
var $RouteInfo; // show routing list?
var $AddToMap; // add address layer to map?
var $ParaTargetMap; // show map of target area?
var $ParaTargetBorder; // radius for target map
var $RouteNodeLevel; // not longer supported
var $RouteDetailLimit; // not longer supported
var $FixHour; // hour to arrive/depart
var $FixMinute; // minute to arrive/depart
var $RouteAdvancedField; // add aadditional parameters to the request
// NOTE: please use the BFAddParam statement
// instead, because RouteAdvancedField is a very
// old way of adding parameter
var $RouteResponse; // answer of routing object
var $RouteScan; // array of three address layer to scan
var $Vehiclename; // choose vehiclename
var $DistanceAsMile; // get distance in miles? if yes, recalculate values
var $RouteDistance; // distance of route computed
var $RouteTime; // time of route computed
var $RowCount; // number of route list entries
// private variables for internal route object usage
var $numRowBeginTCP; // for function ReadRow() used ans set in GetRowCount()
var $numRowBeginBC; // for function ReadRow() used and set in GetRowCount()
var $row; // content of current row, sparated by "|"
var $rowPrio; // priority of currently selected row
var $Result; // result of route object
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// ALRoute - Constructor
// set default parameters to object
function ALRoute()
{
$this->ALBasic();
$this->NR_ROUTEREQUEST=3; // base number for server ACTION
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// GetRowBegin
// get base element for "node" from answer file ANS
function GetRowBegin()
{
for ($i=0; $i<=count($this->BPTCPAnswer["ANS"]);$i++)
{
$search = explode("~", $this->BPTCPAnswer["ANS"][$i]);
if ($search[0] == "RESULT")
{
$this->numRowBeginTCP = $i-1;
$this->Log_to_file("ALRoute.GetRowBegin: passed successfully");
return 0;
}
}
} //GetRowBegin()
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// KmToMile
// set kilometer to mile, rounded to one decimal
function KmToMile($distance)
{
return round($distance/1.60934,1);
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// CheckRes
// check result and set rowcount
function CheckRes()
{
// get first node
$this->GetRowBegin();
// get routing distance
$this->RouteDistance = $this->BFGetParam($this->eATAns, "SERVER", "DISTTODRIVE", 0);
// distance in miles?
if ($this->DistanceAsMile)
$this->RouteDistance = $this->KmToMile($this->RouteDistance);
// get driving time
$this->RouteTime = $this->BFGetParam($this->eATAns, "SERVER", "TIMETODRIVE", 0);
// check whether station passed to server were geocoded
// that means, that COR section has additional information
$i = 1;
$erg = $this->BFGetParam($this->eATCor, "VORSCHLAG".$i , "NUMDATA", "");
// check every station in COR section if applicable
while ($erg!="")
{
if ($erg<1)
{
$this->RouteResponse .= "Warning: Station" . $i . " could not be found <br>";
$this->Log_to_file("ALRoute.CheckRes: Station passed for geocoding wasn't found");
return $this->BPRouteStat_NoLocFound;
}
$i++;
$erg = $this->BFGetParam($this->eATCor, "VORSCHLAG".$i , "NUMDATA", "");
}
// check error messages from server
$erg = $this->BFGetParam($this->eATAns, "SERVER" , "ERROR1", "");
if ($erg != "")
{
$this->RouteResponse = "Error: Error while routing";
$this->Log_to_file("ALRoute.CheckRes: Error while Routing: " . $erg);
return $this->BPStat_PropriError;
}
// take care of NodeLevel and DetailLimit
// new result array is computed by checking every entry for concerning parameter
// NOTE: if you are using BFGetParam to read the single route list entries,
// the following commands can be ignored. In this case, RouteDetailLimit and
// NodeLevel have no effect on thee request/answer
$answer = $this->BPTCPAnswer;
$split = "~";
$begin = $this->numRowBeginTCP;
$num = 2;
$ArraySize = count($answer["ANS"]);
$ArraySize = $ArraySize-1; //with TCP/IP
$elem = 0;
// check RouteNodeLevel and build new answer list
for ($i = $begin+1 ; $i<$ArraySize; $i++ )
{
$tmp = explode($split, $answer["ANS"][$i]);
$rowPrio = substr($tmp[$num],0,1);
$rowPrio = (int)$rowPrio;
if ($rowPrio <= $this->RouteNodeLevel)
{
$this->Result[$elem] = $answer["ANS"][$i];
$elem++;
}
}
// count new number of route list entries
$this->RowCount = count($this->Result);
// check RouteDetaillimit and build new answer list
if ($this->RouteNodeLevel > 2)
if ( count($this->Result) > $this->RouteDetailLimit )
{
$elem = 0;
for ($i = 0; $i<count($this->Result);$i++)
{
$tmp = explode($split, $this->Result[$i]);
$rowPrio = substr($tmp[$num] ,0,1);
if ($rowPrio < 3 )
{
$this->ResultDetail[$elem] = $this->Result[$i];
$elem++;
}
} // end for
$this->RowCount = count($this->ResultDetail);
}
$this->Log_to_file("ALRoute.CheckRes: Passed successfully");
return $this->BPStat_Success;
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// RouteLogicalRect
// return RouteLogicalRect
function RouteLogicalRect()
{
return $this->BFGetParam($this->eATAns, "SERVER","LOGICALRECT","");
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// TargetLogicalRect
// return TargetLogicalRect
function TargetLogicalRect()
{
return $this->BFGetParam($this->eATAns, "SERVER","LOGICALTARGETRECT","");
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// ReadRow
// read next row of station list
// NOTE: please use BFGetParam instead for reading every single line
// of the route info, because this is an old function
function ReadRow($numRow)
{
if (($this->RouteNodeLevel > 2) and (count($this->Result) > $this->RouteDetailLimit))
$tmp = explode("~", $this->ResultDetail[$numRow] );
else
$tmp = explode("~", $this->Result[$numRow] );
$this->row = $tmp[2];
$this->Log_to_file("ALRoute.ReadRow: Passed successfully. RowNumber: " . $numRow);
return substr($tmp[2],0,1);
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// FieldValue
// return a fieldvalue of the row read by ReadRow; first column is 0
// NOTE: please use BFGetParam instead for reading every single line
// of the route info, because this is an old function
function FieldValue($fieldNum)
{
$tmp = explode("|", $this->row);
$this->Log_to_file("ALRoute.FieldValue: Passed successfully. FieldNum: " . $fieldNum);
if ($fieldNum == 2 && $this->DistanceAsMile)
return round($this->KmToMile($tmp[$fieldNum-1]), 1);
return $tmp[$fieldNum-1];
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// SetOrder
// build server request according to parameter set by user
function SetOrder()
{
$this->BPRequest["SERVER"]["ACTION"] = 3;
$this->BPRequest["CLIENT"]["REQUEST"] = "TRUE";
$this->BPRequest["CLIENT"]["MAPSBYSTREAM"] = (($this->BPMapsByStream) ? "TRUE" : "FALSE");
// add every single station set to RouteStation array
// NOTE: if you are using BFAddParam to add the STATION<x>, this loop
// will be ignored
for ($i=1; $i<=count($this->RouteStation); $i++)
if (!empty($this->RouteStation[$i]))
$this->BPRequest["CLIENT"]["STATION" . $i] = $this->RouteStation[$i];
if (isset($this->RouteInfo))
$this->BPRequest["CLIENT"]["ROUTEINFO"] = (($this->RouteInfo) ? "true" : "false");
if (isset($this->AddToMap))
$this->BPRequest["CLIENT"]["ADDTOMAP"] = (($this->AddToMap) ? "true" : "false");
if (isset($this->ParaTargetMap))
$this->BPRequest["CLIENT"]["TARGETMAP"] = (($this->ParaTargetMap) ? "true" : "false");
if (!empty($this->ParaTargetBorder))
$this->BPRequest["CLIENT"]["TARGETBORDER"] = $this->ParaTargetBorder;
if (!empty($this->FixHour))
$this->BPRequest["CLIENT"]["FIXHOUR"] = $this->FixHour;
if (!empty($this->FixMinute))
$this->BPRequest["CLIENT"]["FIXMINUTE"] = $this->FixMinute;
if (!empty($this->VEHICLENAME))
$this->BPRequest["CLIENT"]["VEHICLENAME"] = $this->Vehiclename;
// set advancedfield parameter if applicable
// NOTE: if you are using BFAddParam to add single
// parameters to the request, this loop can be ignored
/*
for ($i=0; $i<count($this->RouteAdvancedField); $i++)
if (!empty($this->RouteAdvancedField[$i]))
{
$arr = explode("=", $this->RouteAdvancedField[$i]);
$this->BPRequest["CLIENT"][$arr[0]]= $arr[1];
}
*/
// set scan parameter if applicable
// NOTE: if you are using BFAddParam to add single
// parameters to the request, this loop can be ignored
if (!empty($this->RouteScan[1]))
for ($i = 1; $i<=3; $i++)
{
$scan = "SCAN". $i;
if (!empty($this->RouteScan[$i]))
$this->BPRequest["CLIENT"][$scan] = $this->RouteScan[$i];
}
$this->Log_to_file("ALRoute.SetOrder: Passed successfully. ");
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// RouteRequest
// Performs Request
function RouteRequest($indicator)
{
if ($indicator=="")
$rnr=$this->NR_ROUTEREQUEST;
else
$rnr=$this->NR_ROUTEREQUEST_ROUTEID;
// check param
if ($this->BPStat_Error == $this->BFCheckParam($rnr) || ($this->BPMapsByStream && $this->BPStreamDirectory==''))
{
$this->Log_to_file("ALRoute.RouteRequest: Too less parameters ");
return $this->BPStat_Error;
}
// set request type
$this->SetOrder();
// build request
$request = $this->BFBuildOrder();
// send request
$answerlength=$this->BFWriteOrder($request);
if ($answerlength>45)
{
// receive answer
$this->BFReadALSAnswer($rnr);
// return result code
return $this->CheckRes();
}
else
return $this->BPStat_Error;
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// CorridorRequest
// same as RouetRequest, but with additional parameters
function CorridorRequest()
{
return $this->RouteRequest();
}
}//class