1. Import
This commit is contained in:
367
html/geo/distance.php
Normal file
367
html/geo/distance.php
Normal file
@@ -0,0 +1,367 @@
|
||||
<?php
|
||||
/*=======================================================================
|
||||
*
|
||||
* distance.php
|
||||
*
|
||||
* Autor: Marc Vollmann
|
||||
*
|
||||
=======================================================================*/
|
||||
|
||||
include_once ("../include/global.inc.php");
|
||||
include_once ("../include/auth.inc.php");
|
||||
|
||||
include_once('../geo/geocode.inc.php');
|
||||
|
||||
|
||||
function draw_route($target,$stationlist,&$GlobalRouteList,&$imageurl,&$imageurlT,$targetmap = false)
|
||||
{
|
||||
global $Application,$map_width,$map_height;
|
||||
|
||||
list($tcpip,$path,$requestname,$imageurl) = GetNextRequestParameter($tcpip,$path,$requestname,$imageurl2,$map,$language);
|
||||
|
||||
$RouteObject=null;
|
||||
|
||||
include_once($Application['OBJECT_BASE'].'alroute.inc.php');
|
||||
|
||||
$RouteObject = new ALRoute;
|
||||
|
||||
$RouteObject->BPUseTCPIP="TRUE";
|
||||
$RouteObject->BPMaxCalcWait=60000;
|
||||
|
||||
if ($Application["COM_LOG"])
|
||||
$RouteObject->BPLogFilePath=$Application["COM_LOG_FILE"];
|
||||
|
||||
$RouteObject->BPParaRequestFileName=$requestname;
|
||||
$RouteObject->BPMapsByStream=false;
|
||||
$RouteObject->BPStreamDirectory=$Application["MAP_PATH"];
|
||||
|
||||
// Language-Code: D=7, F=12, GB=9, I=16, E=10, NL=19, PT=22, SW=29
|
||||
$GetLanguageCode="7";
|
||||
|
||||
$RouteObject->BFAddParam("CLIENT","LANGUAGEID",$GetLanguageCode);
|
||||
|
||||
$RouteObject->BPALS=$tcpip;
|
||||
|
||||
$stationdelimiter="|";
|
||||
|
||||
$RouteObject->BFAddParam("CLIENT","STATIONDELIMITER",$stationdelimiter);
|
||||
|
||||
// $stationen=intval(count($stationlist)/3);
|
||||
// Fixed, because always "start" and "finish"
|
||||
$stationen=2;
|
||||
|
||||
for ($i=1; $i<=$stationen; $i=$i+1)
|
||||
$RouteObject->BFAddParam("CLIENT","STATION" . $i, "COORDINATES" . $stationdelimiter . $stationlist["x" . $i] . $stationdelimiter . $stationlist["y" . $i] . $stationdelimiter . $stationlist["l" . $i]);
|
||||
|
||||
$RouteObject->RouteTableDefString="nothing";
|
||||
$RouteObject->RouteInfo=true;
|
||||
$RouteObject->RouteNodeLevel=5;
|
||||
$RouteObject->RouteDetailLimit=10000;
|
||||
$RouteObject->BFAddParam("CLIENT","PACKEDROUTELIST", "TRUE");
|
||||
$RouteObject->AddToMap=false;
|
||||
|
||||
$result=$RouteObject->RouteRequest("");
|
||||
|
||||
if ($result!=2)
|
||||
$logicalrect="0,0,0,0";
|
||||
else {
|
||||
if ($target=="")
|
||||
$logicalrect=$RouteObject->BFGetParam($RouteObject->eATAns,"SERVER","LOGICALRECT","0,0,0,0");
|
||||
else
|
||||
$logicalrect=$RouteObject->BFGetParam($RouteObject->eATAns,"SERVER","LOGICALTARGETRECT","0,0,0,0");
|
||||
|
||||
$num_objects=intval($RouteObject->BFGetParam($RouteObject->eATAns,"RESULT","NUMNODES","0"));
|
||||
$rowcount=0;
|
||||
|
||||
for ($i=1; $i<=$num_objects; $i=$i+1)
|
||||
$GlobalRouteList["NODE_".$i]=$RouteObject->BFGetParam($RouteObject->eATAns,"RESULT","NODE".$i,"nada");
|
||||
|
||||
$GlobalRouteList["DISTTODRIVE"]= $RouteObject->BFGetParam($RouteObject->eATAns,"SERVER","DISTTODRIVE","");
|
||||
$GlobalRouteList["TIMETODRIVE"]= $RouteObject->BFGetParam($RouteObject->eATAns,"SERVER","TIMETODRIVE","");
|
||||
$GlobalRouteList["COSTS"]= $RouteObject->BFGetParam($RouteObject->eATAns,"SERVER","COSTS","");
|
||||
$GlobalRouteList["ARRIVALTIME"]= $RouteObject->BFGetParam($RouteObject->eATAns,"SERVER","ARRIVALTIME","");
|
||||
$GlobalRouteList["DEPARTURETIME"]= $RouteObject->BFGetParam($RouteObject->eATAns,"SERVER","DEPARTURETIME","");
|
||||
$GlobalRouteList["ARRIVALDATE"]= $RouteObject->BFGetParam($RouteObject->eATAns,"SERVER","ARRIVALDATE","");
|
||||
$GlobalRouteList["DEPARTUREDATE"]= $RouteObject->BFGetParam($RouteObject->eATAns,"SERVER","DEPARTUREDATE","");
|
||||
$RouteObject=null;
|
||||
|
||||
return $logicalrect;
|
||||
} // error while routing
|
||||
|
||||
$RouteObject=null;
|
||||
return $logicalrect;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Inserts the distance of a specified from- and a specified to-address
|
||||
// REMARK: This function should not be called directly! Use the function "getDistance()", because
|
||||
// a specified tour (adress to address) will be checked there and if the distance does not
|
||||
// exist, the route-server would be contacted to get the data which are automatically stored
|
||||
// into the database for invoicing!
|
||||
// $adStreet1 : street of the from-address
|
||||
// $adZipcode1 : zipcode of the from-address
|
||||
// $adCity1 : city of the from-address
|
||||
// $adHsno1 : house-number of the from-address
|
||||
// $adStreet2 : street of the to-address
|
||||
// $adZipcode2 : zipcode of the to-address
|
||||
// $adCity2 : city of the to-address
|
||||
// $adHsno2 : house-number of the to-address
|
||||
function insertDistance($distance, $adStreet1, $adZipcode1, $adCity1, $adCountry1 = "DE", $adHsno1, $adStreet2, $adZipcode2, $adCity2, $adCountry2 = "DE", $adHsno2) {
|
||||
global $db, $PHP_SELF;
|
||||
|
||||
$ok = FALSE;
|
||||
|
||||
$distance = trim($distance);
|
||||
$adStreet1 = trim($adStreet1);
|
||||
$adZipcode1 = trim($adZipcode1);
|
||||
$adCity1 = trim($adCity1);
|
||||
$adCountry1 = trim($adCountry1);
|
||||
$adHsno1 = trim($adHsno1);
|
||||
$adStreet2 = trim($adStreet2);
|
||||
$adZipcode2 = trim($adZipcode2);
|
||||
$adCity2 = trim($adCity2);
|
||||
$adCountry2 = trim($adCountry2);
|
||||
$adHsno2 = trim($adHsno2);
|
||||
|
||||
if ($adStreet1 != "" && $adZipcode1 != "" && $adCity1 != "" && $adCountry1 != "" && $adHsno1 != "" &&
|
||||
$adStreet2 != "" && $adZipcode2 != "" && $adCity2 != "" && $adCountry2 != "" && $adHsno2 != "" && $distance != ""):
|
||||
|
||||
// Insert first address or get the existing address-id
|
||||
$tmpArray = insertAddress($adStreet1, $adZipcode1, $adCity1, $adCountry1);
|
||||
$adId1 = $tmpArray[0];
|
||||
|
||||
// Insert second address or get the existing address-id
|
||||
$tmpArray = insertAddress($adStreet2, $adZipcode2, $adCity2, $adCountry2);
|
||||
$adId2 = $tmpArray[0];
|
||||
|
||||
$distance = str_replace (",", ".", $distance);
|
||||
|
||||
// Insert distance
|
||||
insertStmt("distance", array("ad_id_from", $adId1, "ds_hsno_from", $adHsno1,
|
||||
"ad_id_to", $adId2, "ds_hsno_to", $adHsno2,
|
||||
"ds_distance", $distance));
|
||||
$ok = TRUE;
|
||||
endif;
|
||||
|
||||
return $ok;
|
||||
}
|
||||
|
||||
// Returns the distance of a specified from- and a specified to-address
|
||||
// $adStreet1 : street of the from-address
|
||||
// $adZipcode1 : zipcode of the from-address
|
||||
// $adCity1 : city of the from-address
|
||||
// $adHsno1 : house-number of the from-address
|
||||
// $adStreet2 : street of the to-address
|
||||
// $adZipcode2 : zipcode of the to-address
|
||||
// $adCity2 : city of the to-address
|
||||
// $adHsno2 : house-number of the to-address
|
||||
function getDistance($adStreet1, $adZipcode1, $adCity1, $adCountry1 = "DE", $adHsno1, $adStreet2, $adZipcode2, $adCity2, $adCountry2 = "DE", $adHsno2) {
|
||||
return 0;
|
||||
global $db, $PHP_SELF, $statusMessage;
|
||||
global $MGObject;
|
||||
|
||||
$distance = "";
|
||||
|
||||
$adStreet1 = trim($adStreet1);
|
||||
$adZipcode1 = trim($adZipcode1);
|
||||
$adCity1 = trim($adCity1);
|
||||
$adCountry1 = trim($adCountry1);
|
||||
$adHsno1 = trim($adHsno1);
|
||||
$adStreet2 = trim($adStreet2);
|
||||
$adZipcode2 = trim($adZipcode2);
|
||||
$adCity2 = trim($adCity2);
|
||||
$adCountry2 = trim($adCountry2);
|
||||
$adHsno2 = trim($adHsno2);
|
||||
|
||||
if ($adStreet1 != "" && $adZipcode1 != "" && $adCity1 != "" && $adCountry1 != "" && $adHsno1 != "" &&
|
||||
$adStreet2 != "" && $adZipcode2 != "" && $adCity2 != "" && $adCountry2 != "" && $adHsno2 != ""):
|
||||
|
||||
$sqlquery = "SELECT ds.ds_distance"
|
||||
. " FROM distance AS ds, address AS ad1, address AS ad2"
|
||||
. " WHERE ds.ds_hsno_from = '$adHsno1'"
|
||||
. " AND ds.ds_hsno_to = '$adHsno2'"
|
||||
. " AND ds.ad_id_from = ad1.ad_id"
|
||||
. " AND ds.ad_id_to = ad2.ad_id"
|
||||
. " AND ad1.ad_street = '$adStreet1'"
|
||||
. " AND ad1.ad_zipcode = '$adZipcode1'"
|
||||
. " AND ad1.ad_city = '$adCity1'"
|
||||
. " AND ad1.ad_country = '$adCountry1'"
|
||||
. " AND ad2.ad_street = '$adStreet2'"
|
||||
. " AND ad2.ad_zipcode = '$adZipcode2'"
|
||||
. " AND ad2.ad_city = '$adCity2'"
|
||||
. " AND ad2.ad_country = '$adCountry2'";
|
||||
|
||||
$result = $db->query($sqlquery);
|
||||
if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage());
|
||||
|
||||
if ($row = $result->fetch_assoc()):
|
||||
$distance = $row[ds_distance];
|
||||
endif;
|
||||
$result->free();
|
||||
|
||||
// if $distance = 0 then get distance-data from route-server
|
||||
// ...
|
||||
if ($distance == "") :
|
||||
|
||||
// *** START-ADDRESS ***
|
||||
|
||||
$resultType = getGeoCode($adStreet1,$adZipcode1,$adCity1,$adHsno1,$adCountry1,"");
|
||||
|
||||
// resultType == 2 -> exact match
|
||||
if ($resultType == 2) :
|
||||
|
||||
// Geo-Coordinates
|
||||
$xcoord=$MGObject->GeoCoordinateX;
|
||||
$ycoord=$MGObject->GeoCoordinateY;
|
||||
|
||||
// Check for existing entry in address (because of redundance)
|
||||
if ($xcoord == "" || $xcoord == 0 || $ycoord == "" || $ycoord == 0):
|
||||
|
||||
$statusMessage = "Die Startadresse konnte nicht geocodiert werden!";
|
||||
endif;
|
||||
|
||||
// Initialize object
|
||||
$MGObject=null;
|
||||
endif;
|
||||
|
||||
// *** FINISH-ADDRESS ***
|
||||
|
||||
$resultType = getGeoCode($adStreet2,$adZipcode2,$adCity2,$adHsno2,$adCountry2,"");
|
||||
|
||||
// resultType == 2 -> exact match
|
||||
if ($resultType == 2) :
|
||||
|
||||
// Geo-Coordinates
|
||||
$xcoord2=$MGObject->GeoCoordinateX;
|
||||
$ycoord2=$MGObject->GeoCoordinateY;
|
||||
|
||||
// Check for existing entry in address (because of redundance)
|
||||
if ($xcoord2 == "" || $xcoord2 == 0 || $ycoord2 == "" || $ycoord2 == 0):
|
||||
|
||||
$statusMessage = "Die Zieladresse konnte nicht geocodiert werden!";
|
||||
endif;
|
||||
|
||||
// Initialize object
|
||||
$MGObject=null;
|
||||
endif;
|
||||
|
||||
// *** Computation of the distance and storing into the database ***
|
||||
|
||||
if ($statusMessage == ""):
|
||||
|
||||
$stationlist["x1"]=$xcoord;
|
||||
$stationlist["y1"]=$ycoord;
|
||||
$stationlist["x2"]=$xcoord2;
|
||||
$stationlist["y2"]=$ycoord2;
|
||||
$GlobalRouteList="";
|
||||
$logicalrect=draw_route($target,$stationlist,$GlobalRouteList,$imageurl,$imageurlT);
|
||||
$distance =$GlobalRouteList["DISTTODRIVE"];
|
||||
// $drivingTime = $GlobalRouteList["TIMETODRIVE"];
|
||||
|
||||
// Insert the new distance-data from the route-server into the database for invoicing later on
|
||||
if ($distance != ""):
|
||||
insertDistance($distance, $adStreet1, $adZipcode1, $adCity1, $adCountry1, $adHsno1, $adStreet2, $adZipcode2, $adCity2, $adCountry2, $adHsno2);
|
||||
endif;
|
||||
endif;
|
||||
endif;
|
||||
endif;
|
||||
|
||||
$distance = str_replace (",", ".", $distance);
|
||||
|
||||
return $distance;
|
||||
}
|
||||
|
||||
|
||||
// Returns the distance of a specified from- and a specified to-address
|
||||
// $adId1 : ID of the from-address
|
||||
// $adHsno1 : house-number of the from-address
|
||||
// $adId2 : ID of the to-address
|
||||
// $adHsno2 : house-number of the to-address
|
||||
function getDistancePerID($adId1, $adHsno1, $adId2, $adHsno2) {
|
||||
|
||||
global $db, $PHP_SELF, $statusMessage;
|
||||
global $MGObject;
|
||||
|
||||
$distance = "";
|
||||
|
||||
$adId1 = trim($adId1);
|
||||
$adHsno1 = trim($adHsno1);
|
||||
$adId2 = trim($adId2);
|
||||
$adHsno2 = trim($adHsno2);
|
||||
|
||||
if ($adId1 != "" && $adHsno1 != "" && $adId2 != "" && $adHsno2 != ""):
|
||||
|
||||
$sqlquery = "SELECT ds.ds_distance"
|
||||
. " FROM distance AS ds"
|
||||
. " WHERE ds.ds_hsno_from = '$adHsno1'"
|
||||
. " AND ds.ds_hsno_to = '$adHsno2'"
|
||||
. " AND ds.ad_id_from = $adId1"
|
||||
. " AND ds.ad_id_to = $adId2";
|
||||
|
||||
$result = $db->query($sqlquery);
|
||||
if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage());
|
||||
|
||||
if ($row = $result->fetch_assoc()):
|
||||
$distance = $row[ds_distance];
|
||||
endif;
|
||||
$result->free();
|
||||
|
||||
// if $distance = 0 then get distance-data from route-server
|
||||
// ...
|
||||
if ($distance == "") :
|
||||
|
||||
// Check existence of the address-entries in the table "address"
|
||||
|
||||
// Check from-address
|
||||
$tmpFields = getFieldsValueFromId("address","ad_id",$adId1,array("ad_street","ad_zipcode","ad_city","ad_country"));
|
||||
$adStreet1 = $tmpFields[0];
|
||||
$adZipcode1 = $tmpFields[1];
|
||||
$adCity1 = $tmpFields[2];
|
||||
$adCountry1 = $tmpFields[3];
|
||||
|
||||
// If from-address does not exist then to-address has not to be checked
|
||||
if ($adStreet1 != "" && $adZipcode1 != "" && $adCity1 != "" && $adCountry1 != "" && $adHsno1 != ""):
|
||||
|
||||
// Check to-address
|
||||
$tmpFields = getFieldsValueFromId("address","ad_id",$adId2,array("ad_street","ad_zipcode","ad_city","ad_country"));
|
||||
$adStreet2 = $tmpFields[0];
|
||||
$adZipcode2 = $tmpFields[1];
|
||||
$adCity2 = $tmpFields[2];
|
||||
$adCountry2 = $tmpFields[3];
|
||||
endif;
|
||||
|
||||
|
||||
if ($adStreet1 != "" && $adZipcode1 != "" && $adCity1 != "" && $adCountry1 != "" && $adHsno1 != "" &&
|
||||
$adStreet2 != "" && $adZipcode2 != "" && $adCity2 != "" && $adCountry2 != "" && $adHsno2 != ""):
|
||||
|
||||
// Both addresses are existent and the distance can be computed
|
||||
$distance = getDistance($adStreet1, $adZipcode1, $adCity1, $adCountry1, $adHsno1, $adStreet2, $adZipcode2, $adCity2, $adCountry2, $adHsno2);
|
||||
endif;
|
||||
endif;
|
||||
endif;
|
||||
|
||||
$distance = str_replace (",", ".", $distance);
|
||||
|
||||
return $distance;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// ACTIVATE ONLY FOR TESTING!!!
|
||||
|
||||
// $distance = getDistance("Alsterdorfer Str.", "22297", "Hamburg", "D", "190", "Am Ochsenzoll", "22851", "Norderstedt", "D", "147");
|
||||
// echo "Distanz: " . $distance . "<br><br>";
|
||||
// $distance = getDistance("Langer Kamp", "22850", "Norderstedt", "D", "124a", "Langer Kamp", "22850", "Norderstedt", "D", "1");
|
||||
// echo "Distanz: " . $distance . "<br><br>";
|
||||
// $distance = getDistance("Alsterdorfer Str.", "22297", "Hamburg", "D", "190", "Friedrichshulder Weg", "25469", "Halstenbek", "D", "81");
|
||||
// echo "Distanz: " . $distance . "<br><br>";
|
||||
// $distance = getDistancePerID(1, "124", 2, "147");
|
||||
// echo "Distanz: " . $distance . "<br><br>";
|
||||
|
||||
// $x = getAddressFromGeoCode(52, 13);
|
||||
// echo "DISTANCE: ";
|
||||
// echo $x[0] . " " . $x[1] . " " . $x[2] . "<br>";
|
||||
|
||||
?>
|
||||
170
html/geo/geocode.inc.php
Normal file
170
html/geo/geocode.inc.php
Normal file
@@ -0,0 +1,170 @@
|
||||
<?php
|
||||
/*=======================================================================
|
||||
*
|
||||
* geocode.inc
|
||||
*
|
||||
* Autor: Marc Vollmann
|
||||
*
|
||||
=======================================================================*/
|
||||
|
||||
if (substr(phpversion(), 0, 1) >= "5") :
|
||||
// include('../geo/geoglobal.php');
|
||||
else :
|
||||
include('../geo/geoglobal.php');
|
||||
endif;
|
||||
|
||||
|
||||
// Following include_once is important for function getGeoCode()
|
||||
@include_once($Application['OBJECT_BASE'].'algeo.inc.php');
|
||||
|
||||
|
||||
function GetNextRequestParameter($tcpip,$path,$requestname,$imageurl,$map,$language)
|
||||
{
|
||||
global $Application;
|
||||
|
||||
$path=$Application[strtoupper("MAP".$map."_".$language."_MAPPATH")];
|
||||
$requestname=$Application["ALS_FILE"].date('his')."_".$Application["CURRENTREQUEST"];
|
||||
$imageurl=$Application["ALS_URL"].$requestname.".gif";
|
||||
$tcpip=$Application["ALS_LIST_D7_D"];
|
||||
|
||||
return array($tcpip,$path,$requestname,$imageurl);
|
||||
};
|
||||
|
||||
|
||||
// Generates the result-object containing all informations (distance, time, costs, etc.)
|
||||
function getGeoCode($adStreet, $adZipcode, $adCity, $adHsno, $adCountry = "D", $adDistrict = "") {
|
||||
|
||||
global $MGObject;
|
||||
|
||||
$MGObject = new ALGeo;
|
||||
list($tcpip,$path,$requestname,$imageurl) = GetNextRequestParameter($tcpip,$path,$requestname,$imageurl2,$map,$language);
|
||||
|
||||
$MGObject->BPUseTCPIP=true;
|
||||
$MGObject->BPALS=$tcpip;
|
||||
|
||||
if ($Application["COM_LOG"]) $MGObject->BPLogFilePath=$Application["COM_LOG_FILE"];
|
||||
|
||||
// pass all available parameters to the ALS
|
||||
if ($adZipcode!="") $MGObject->GeoZIP=$adZipcode;
|
||||
if ($adCity!="") $MGObject->GeoTown=$adCity;
|
||||
if ($adDistrict!="") $MGObject->GeoDistrict=$adDistrict;
|
||||
if ($adStreet!="") $MGObject->GeoStreet=$adStreet;
|
||||
if ($adHsno!="") $MGObject->GeoHousenumber=$adHsno;
|
||||
if ($adCountry!="") $MGObject->GeoCountry=$adCountry;
|
||||
|
||||
// try to geocode as exactly as possible and ask the user as detailed as possible
|
||||
// if the location can't be geocoded clearly
|
||||
|
||||
$MGObject->ShowDistrict=true;
|
||||
//$MGObject->BFAddParam("CLIENT","USEHNR","TRUE");
|
||||
|
||||
// we don't need a map for the geocoding process
|
||||
$MGObject->ParaMap=false;
|
||||
|
||||
// as a result we want all the parameters the ALS can provide us with
|
||||
$MGObject->ParaRequestType=2;
|
||||
|
||||
// ++++++++++++++ send request to ALS ++++++++++++++++++++
|
||||
$resultType=$MGObject->GeoRequest();
|
||||
|
||||
return $resultType;
|
||||
};
|
||||
|
||||
|
||||
// Function to check the validity of an address and to get the coordinates if it is valid.
|
||||
// Returns "" if not valid else returns a two-component-array with x- and y-coordinate.
|
||||
function getGeoCoordinates($adStreet, $adZipcode, $adCity, $adHsno, $adCountry = "D", $adDistrict = "") {
|
||||
|
||||
global $MGObject, $hq_id;
|
||||
|
||||
$retCoordinates = "";
|
||||
|
||||
// Checks for M&G-Status is enabled or disabled
|
||||
// If enabled the check has to be done by the M6G-Sever,
|
||||
// if disabled all addresses entered to the system would be valid
|
||||
|
||||
// if (MG_STATUS == "0") : return "DISABLED"; endif; // Do NOT return empty string!
|
||||
$parMgStatus = getParameterValue("0", "MG_STATUS", $hq_id);
|
||||
if ($parMgStatus == "") : $parMgStatus = getParameterValue("0", "MG_STATUS", "0"); endif;
|
||||
|
||||
if ($parMgStatus == "" || $parMgStatus == "0") : return "DISABLED"; endif; // Do NOT return empty string!
|
||||
|
||||
$resultType = getGeoCode($adStreet,$adZipcode,$adCity,$adHsno,$adCountry,$adDistrict);
|
||||
|
||||
// resultType == 2 -> exact match
|
||||
if ($resultType == 2) :
|
||||
|
||||
// Geo-Coordinates
|
||||
$xcoord=$MGObject->GeoCoordinateX;
|
||||
$ycoord=$MGObject->GeoCoordinateY;
|
||||
|
||||
// Check for setting
|
||||
if ($xcoord != "" && $xcoord != 0 && $ycoord != "" && $ycoord != 0):
|
||||
|
||||
$retCoordinates = array($xcoord,$ycoord);
|
||||
endif;
|
||||
|
||||
// Initialize object
|
||||
$MGObject=null;
|
||||
endif;
|
||||
|
||||
return $retCoordinates;
|
||||
};
|
||||
|
||||
|
||||
// Generates the result-address-object according to the specified GEO-coordinates
|
||||
function getAddressFromGeoCode($x, $y, $coordType = "0") {
|
||||
|
||||
global $MGObject;
|
||||
|
||||
// calculate logical coordinates out of pixel coordinates
|
||||
if ($coordType != "0") :
|
||||
$width_pix=(int)$Application["MAP_WIDTH"];
|
||||
$height_pix=(int)$Application["MAP_HEIGHT"];
|
||||
$rect=explode(",",$external_logicalrect);
|
||||
|
||||
$x=(int)($external_x*abs((int)$rect[0]-(int)$rect[2])/$width_pix);
|
||||
$y=(int)($external_y*abs((int)$rect[1]-(int)$rect[3])/$height_pix);
|
||||
endif;
|
||||
|
||||
// instantiate object for reverse geocoding
|
||||
list($tcpip,$path,$requestname,$imageurl) = GetNextRequestParameter($tcpip,$path,$requestname,$imageurl2,$map,$language);
|
||||
|
||||
$MiscObject=null;
|
||||
// included above ... look top of script
|
||||
// include_once($Application['OBJECT_BASE'].'albasic.inc.php');
|
||||
|
||||
$MiscObject = new ALBasic;
|
||||
$MiscObject->BPUseTCPIP=true;
|
||||
$MiscObject->BPALS=$tcpip;
|
||||
|
||||
if ($Application["COM_LOG"]) $MiscObject->BPLogFilePath=$Application["COM_LOG_FILE"];
|
||||
|
||||
$MiscObject->BFAddParam("SERVER","ACTION","7");
|
||||
$MiscObject->BFAddParam("CLIENT","SUBACTION","10");
|
||||
$MiscObject->BFAddParam("CLIENT","COORDINATES",$x.",".$y);
|
||||
|
||||
$MiscObject->BFRequest();
|
||||
|
||||
$result=$MiscObject->BFGetParam(0,"SERVER","NEARBY","");
|
||||
|
||||
$resultAddress = "";
|
||||
if ($result!="" && $MiscObject->BFGetParam(0,"SERVER","ERRORTEXT","")=="") {
|
||||
|
||||
//<LayerName>|<VisibleLayerName>|<ID>|<Description>|<x logical>|<y logical>|<x Pixel>|<y Pixel>|??|ZIP|Town|District
|
||||
$data=explode("|",$result[$i]);
|
||||
|
||||
$resultAddress[0] = $data[9]; // Zipcode
|
||||
$resultAddress[1] = $data[10]; // Town
|
||||
$resultAddress[2] = $data[11]; // District
|
||||
|
||||
};
|
||||
|
||||
$MiscObject=null;
|
||||
|
||||
return $resultAddress;
|
||||
};
|
||||
|
||||
?>
|
||||
|
||||
|
||||
122
html/geo/geoglobal.php
Normal file
122
html/geo/geoglobal.php
Normal file
@@ -0,0 +1,122 @@
|
||||
<?
|
||||
|
||||
////////////////////////////////////////////////
|
||||
////
|
||||
//// GEOGLOBAL.PHP
|
||||
////
|
||||
//// map&guide iNET Server
|
||||
////
|
||||
//// (C) 2003 MAP&GUIDE GmbH
|
||||
//// Last Change: Februrary 2003
|
||||
//// Support: als.support@mapandguide.com
|
||||
////
|
||||
////////////////////////////////////////////////
|
||||
|
||||
// +++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// DETAILED CONFIGURATION INFO FOR EACH SERVER
|
||||
// +++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
// ALS_LIST_<MAP>_<FRONTEND_LANGUAGE>
|
||||
// = list of iNET server that are available for this combination of
|
||||
// map and frontend language
|
||||
// Please note that the map language is not included in this variable
|
||||
//
|
||||
// syntax of the list:
|
||||
// <NAME1>,<IP or NAMEOFHOST>,<PORT>,<ACTIVE=1, INACTIVE=0>^
|
||||
//
|
||||
// example: two iNET server
|
||||
// "inet1,mapmachine1,2000,1^inet2,23.24.25.26,2001,1"
|
||||
|
||||
// name of the map used D7=Germany City, EU7= Europe City
|
||||
$Application["MAP"]="D7";
|
||||
|
||||
// List of MAPS x FRONTEND_LANGUAGE. Yo can define multiple servers
|
||||
$Application["ALS_LIST_D7_D"] ="test,localhost,2001,0^als0,localhost,2000,1";
|
||||
$Application["ALS_LIST_D7_F"] ="test,localhost,2001,0^als0,localhost,2000,1";
|
||||
$Application["ALS_LIST_D7_I"] ="test,localhost,2001,0^als0,localhost,2000,1";
|
||||
$Application["ALS_LIST_D7_E"] ="test,localhost,2001,0^als0,localhost,2000,1";
|
||||
$Application["ALS_LIST_D7_GB"]="test,localhost,2001,0^als0,localhost,2000,1";
|
||||
$Application["ALS_LIST_D7_NL"]="test,localhost,2001,0^als0,localhost,2000,1";
|
||||
|
||||
// The variable map can only be used in case of one map
|
||||
// If multiple maps (maybe with multiple languages) are used, please
|
||||
// refer to the documentation concerning "internationalization"
|
||||
|
||||
// name of the address layer used. The varta address layer is preinstalled with
|
||||
// the server and the sample SQL code is installed in the databases directory
|
||||
$Application["DATABASE"]="Varta";
|
||||
|
||||
// list of fields to be retrieved from the server or the database for radius search
|
||||
$Application["RETURNFIELDS"]="ID,Hauptort,Sterne,Kronen,Name";
|
||||
|
||||
// list of fields to be retrieved from the server or the database for a detailed view
|
||||
$Application["RETURNFIELDS_DETAIL"]="ID,Hauptort,Sterne,Kronen,Name";
|
||||
|
||||
// please indicate the path to the directory where the PHP classes are located
|
||||
// $Application['OBJECT_BASE']="D:/dev/Apache/Apache/htdocs/mgobjects/";
|
||||
$Application['OBJECT_BASE']="D:/Projekte/htdocs/phoenix/geo/mgobjects/";
|
||||
// $Application['OBJECT_BASE']="D:/Projekte/htdocs/mgweb/PHP/mgobjects/";
|
||||
|
||||
// path to the directory where the server writes the generated GIFs to in case
|
||||
// streaming is not used
|
||||
// $Application["MAP_PATH"]='D:/dev/Apache/Apache/htdocs/tmp';
|
||||
$Application["MAP_PATH"]='D:/mgtmp';
|
||||
|
||||
//######################################################
|
||||
|
||||
// ALS_URL describes the URL to the virtual directory which includes
|
||||
// the generated GIFs in case streaming is not used. Please don't forget
|
||||
// the trailing slash "/"
|
||||
$Application["ALS_URL"]="http://localhost:81/tmp/";
|
||||
$Application["ALS_FILE"]="als9php";
|
||||
|
||||
// The ALS_BITMAP_PATH is a path on your harddisk on which the map
|
||||
// server (iNET server) is installed and contains bitmaps you want to
|
||||
// be drawn in map
|
||||
// $Application["ALS_BITMAP_PATH"]="d:\images\\";
|
||||
$Application["ALS_BITMAP_PATH"]="d:\mgtmp\\";
|
||||
|
||||
// DB_PATH points to the directory on the webserver where your database
|
||||
// is located on which the nextsearch is performed
|
||||
// this path is normally irrelevant to PHP user
|
||||
// $Application["DB_PATH"]="d:\\databases\\";
|
||||
$Application["DB_PATH"]="D:\\Projekte\htdocs\phoenix\geo\database\\";
|
||||
|
||||
|
||||
// COM_LOG enables the logging of the PHP objects. This is useful
|
||||
// during the development
|
||||
$Application["COM_LOG"]=false;
|
||||
// $Application["COM_LOG"]=true;
|
||||
|
||||
// COM_LOG_FILE defines the file where the PHP objects log is written to.
|
||||
// It's a file located on the webserver. This is only interesting during dev.
|
||||
// $Application["COM_LOG_FILE"]="c:/php_mgg_class.log";
|
||||
$Application["COM_LOG_FILE"]="D:/Projekte/htdocs/phoenix/geo/php_mgg_class.log";
|
||||
|
||||
// the MAP_WIDTH and MAP_HEIGHT variables define the size of the map
|
||||
$Application["MAP_WIDTH"]=400;
|
||||
$Application["MAP_HEIGHT"]=400;
|
||||
|
||||
// NAV_BAR_WIDTH defines the width of the grey navigation
|
||||
// bar around the map.
|
||||
$Application["nav_bar_width"]=10;
|
||||
$Application["nav_bar_height"]=10;
|
||||
$Application["map_width"]=$Application["MAP_WIDTH"];
|
||||
$Application["map_height"]=$Application["MAP_HEIGHT"];
|
||||
// Database Settings (used for MySQL connection)
|
||||
$Application["DB_HOST"]="localhost:3306";
|
||||
$Application["DB_USER"]="";
|
||||
$Application["DB_PASS"]="";
|
||||
$Application["DB_NAME"]="varta";
|
||||
|
||||
// you can disable the crosshair in the sample applications l2 and l3 in setting
|
||||
// this parameter to true
|
||||
$Application["DISABLE_CROSSHAIR"]=false;
|
||||
|
||||
// internal value for TCP/IP communication. You shouldn't change this value
|
||||
$Application["SEPARATOR"]="'^'";
|
||||
|
||||
// global variable
|
||||
$GlobalResultList=0;
|
||||
|
||||
?>
|
||||
18
html/geo/index.html
Normal file
18
html/geo/index.html
Normal file
@@ -0,0 +1,18 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
|
||||
<html lang="de">
|
||||
<head>
|
||||
<title>votian</title>
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="description" content="votian"> <meta name="keywords" content="votian">
|
||||
<meta http-equiv="refresh" content="0; URL=../index.php">
|
||||
<link rel="stylesheet" type="text/css" href="css/phoenix.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body bgcolor="#FFFFFA" leftmargin="1" topmargin="1" marginwidth="0" marginheight="0" link="#990000" vlink="#990000" alink="#990000">
|
||||
<a href="../index.php">Bitte hier klicken, wenn Sie nicht automatisch weitergeleitet werden...</a>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
556
html/geo/mgobjects/albasic.inc.php
Normal file
556
html/geo/mgobjects/albasic.inc.php
Normal file
@@ -0,0 +1,556 @@
|
||||
<?
|
||||
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// ALBasic
|
||||
//
|
||||
// Author: Christian Mähler
|
||||
// Version: 9.5
|
||||
// Last update: April 2003
|
||||
//
|
||||
// Base library for map&guide TCP/IP communication to
|
||||
// iNET server and map&guide intranet server
|
||||
// Batch Control is not supported (!)
|
||||
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
set_time_limit(300);
|
||||
|
||||
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 $BPMaxCalcWait; // 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
|
||||
var $NR_BFREQUEST;
|
||||
|
||||
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// ALBasic
|
||||
// constructor for class ALBasic
|
||||
|
||||
function ALBasic()
|
||||
{
|
||||
$this->NR_BFREQUEST=9999; // user defined request
|
||||
$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->BPMaxCalcWait=60; // wait 60 seconds per server for the end of a request
|
||||
$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;
|
||||
//socket_set_timeout($fp,$this->BPMaxCalcWait);
|
||||
$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 && $this->BPRequest["CLIENT"]["NEXTID"]=="") || $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]);
|
||||
if(substr($tmp[1],0,4)=="NODE")
|
||||
$this->BCAnswerList["ANS"][$tmp[0]][$tmp[1]]=str_replace($tmp[0]."~".$tmp[1]."~","",$this->BPTCPAnswer["ANS"][$i]);
|
||||
else
|
||||
$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
|
||||
|
||||
if(is_array($this->BPRequest["SERVER"]))
|
||||
{
|
||||
reset($this->BPRequest["SERVER"]);
|
||||
while (list($key, $value) = each ($this->BPRequest["SERVER"]))
|
||||
$request .= "SERVER~$key~$value" . $separator;
|
||||
}
|
||||
|
||||
// build all values concerning CLIENT section
|
||||
if(is_array($this->BPRequest["CLIENT"]))
|
||||
{
|
||||
reset($this->BPRequest["CLIENT"]);
|
||||
while (list($key, $value) = each ($this->BPRequest["CLIENT"]))
|
||||
$request .= "CLIENT~$key~$value" . $separator;
|
||||
}
|
||||
|
||||
// build all values concerning CLIENT section
|
||||
if(is_array($this->BPRequest["DISTMATRIX"]))
|
||||
{
|
||||
reset($this->BPRequest["DISTMATRIX"]);
|
||||
while (list($key, $value) = each ($this->BPRequest["DISTMATRIX"]))
|
||||
$request .= "DISTMATRIX~$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();
|
||||
$small_result_without_error=false;
|
||||
|
||||
while((int)$answerlength<100 && !$small_result_without_error && (time()-$starttime<(int)$this->BPMaxCalcWait))
|
||||
{
|
||||
// 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);
|
||||
|
||||
if(strpos ($tcptmp, "SERVER~ERRORCODE~0"))
|
||||
$small_result_without_error=true;
|
||||
|
||||
if(!$small_result_without_error)
|
||||
{
|
||||
//usleep(300); // does not work with windows
|
||||
$mytime=time();
|
||||
srand ((double)microtime()*1000000);
|
||||
$comp=rand(1,3);
|
||||
while(time()-$mytime<$comp);
|
||||
$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)
|
||||
if(!$small_result_without_error)
|
||||
fclose($this->BPFPTCP);
|
||||
}
|
||||
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 == "" && $this->MapObjectList && "" and $this->BPRequest[CLIENT][LOGICALRECT]=="" && $this->BPRequest["CLIENT"]["CST1"] =="" && $this->BPRequest["CLIENT"]["SHOWINITRECT"] !="TRUE")
|
||||
{
|
||||
$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;
|
||||
}
|
||||
|
||||
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// BFRequest
|
||||
// send user defined request to the server
|
||||
|
||||
function BFRequest()
|
||||
{
|
||||
// build request
|
||||
$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)
|
||||
{
|
||||
// return result code
|
||||
// count number of hits
|
||||
$reqerr=$this->BFReadALSAnswer($this->NR_BFREQUEST);
|
||||
if($this->BFGetParam(0,"SERVER","ERRORCODE","-1")=="0" || $this->BFGetParam(0,"DISTMATRIX","ERRORCODE","-1")=="0")
|
||||
return 2;
|
||||
else
|
||||
return $this->BPStat_Error;
|
||||
}
|
||||
else
|
||||
return $this->BPStat_Error;
|
||||
}
|
||||
|
||||
|
||||
} // end of class definition
|
||||
|
||||
?>
|
||||
356
html/geo/mgobjects/algeo.inc.php
Normal file
356
html/geo/mgobjects/algeo.inc.php
Normal file
@@ -0,0 +1,356 @@
|
||||
<?
|
||||
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// ALGeo
|
||||
//
|
||||
// Author: Christian Mähler
|
||||
// Version: 9.5
|
||||
// Last update: April 2003
|
||||
//
|
||||
// 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["CLIENT"]["MAP"] = (($this->ParaMap) ? "TRUE" : "FALSE");
|
||||
$this->BPRequest["CLIENT"]["SHOWDISTRICT"] = (($this->ShowDistrict) ? "TRUE" : "FALSE");
|
||||
$this->BPRequest["CLIENT"]["MAPSBYSTREAM"] = (($this->BPMapsByStream) ? "TRUE" : "FALSE");;
|
||||
if ($this->ShowDistrict && $this->MaxNumNearest)
|
||||
$this->BPRequest["CLIENT"]["MAXNUMNEAREST"] = $this->MaxNumNearest;
|
||||
$this->BPRequest["CLIENT"]["SEARCH"] = $this->GeoCountry . $this->GeoZIP . "," . $this->GeoTown .",". $this->GeoDistrict .",". $this->GeoStreet ." ". $this->GeoHousenumber .",,";
|
||||
$this->BPRequest["CLIENT"]["SUBACTION"] = 1;
|
||||
$this->BPRequest["SERVER"]["ACTION"] = 7;
|
||||
$this->BPRequest["CLIENT"]["REQUEST"] = "TRUE";
|
||||
|
||||
$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 iNETServer. 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)
|
||||
{
|
||||
// return result code
|
||||
// count number of hits
|
||||
$reqerr=$this->BFReadALSAnswer($this->NR_GEOREQUEST);
|
||||
$countorte = intval($this->BFGetParam($this->eATAns, "VORSCHLAG1","NUMORTE",-1));
|
||||
return $this->CheckRes($countorte);
|
||||
}
|
||||
else
|
||||
return $this->BPStat_Error;
|
||||
}
|
||||
|
||||
} //end of class definition
|
||||
|
||||
?>
|
||||
224
html/geo/mgobjects/alnext.inc.php
Normal file
224
html/geo/mgobjects/alnext.inc.php
Normal file
@@ -0,0 +1,224 @@
|
||||
<?
|
||||
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// ALNext
|
||||
//
|
||||
// Author: Christian Mähler
|
||||
// Version: 9.5
|
||||
// Last update: April 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->BFGetParam(0,"SERVER","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",$this->BFGetParam(0,"SERVER","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
|
||||
|
||||
?>
|
||||
355
html/geo/mgobjects/alroute.inc.php
Normal file
355
html/geo/mgobjects/alroute.inc.php
Normal file
@@ -0,0 +1,355 @@
|
||||
<?
|
||||
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// ALRoute
|
||||
//
|
||||
// Author: Christian Mähler
|
||||
// Version: 9.5
|
||||
// Last update: April 2003
|
||||
//
|
||||
// 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
|
||||
$this->NR_ROUTEREQUEST_ROUTEID=30;
|
||||
}
|
||||
|
||||
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// 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()
|
||||
{
|
||||
if ($this->BPRequest["CLIENT"]["ROUTEID"]=="")
|
||||
$rnr=$this->NR_ROUTEREQUEST;
|
||||
else
|
||||
$rnr=$this->NR_ROUTEREQUEST_ROUTEID;
|
||||
|
||||
// check param
|
||||
if ($this->BPStat_Error == $this->BFCheckParam($this->NR_ROUTEREQUEST) || ($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
|
||||
|
||||
|
||||
494
html/geo/mgobjects_onlywindows/ALBasic.inc.php
Normal file
494
html/geo/mgobjects_onlywindows/ALBasic.inc.php
Normal 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
|
||||
|
||||
?>
|
||||
358
html/geo/mgobjects_onlywindows/ALGeo.inc.php
Normal file
358
html/geo/mgobjects_onlywindows/ALGeo.inc.php
Normal 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
|
||||
|
||||
?>
|
||||
164
html/geo/mgobjects_onlywindows/ALMap.inc.php
Normal file
164
html/geo/mgobjects_onlywindows/ALMap.inc.php
Normal 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
|
||||
|
||||
224
html/geo/mgobjects_onlywindows/ALNext.inc.php
Normal file
224
html/geo/mgobjects_onlywindows/ALNext.inc.php
Normal 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
|
||||
|
||||
?>
|
||||
354
html/geo/mgobjects_onlywindows/ALRoute.inc.php
Normal file
354
html/geo/mgobjects_onlywindows/ALRoute.inc.php
Normal 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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user