\n";
//$allCoords[] = array($coords[0][1], $coords[0][2], 8*3600, 14*3600);
//$coords = XSfindAddress("D", "22848", "Norderstedt", "Ochsenzoller Straße", "31");
//echo $coords[0][1] . ", " . $coords[0][2] . "
\n";
//$allCoords[] = array($coords[0][1], $coords[0][2], 12.5*3600, 19*3600);
//$coords = XSfindAddress("D", "21502", "Geesthacht", "Gerhart-Hauptmann-Weg", "14");
//echo $coords[0][1] . ", " . $coords[0][2] . "
\n";
//$allCoords[] = array($coords[0][1], $coords[0][2], 8*3600, 14*3600);
//$coords = XSfindAddress("D", "25421", "Pinneberg", "Oeltingsallee", "1b");
//echo $coords[0][1] . ", " . $coords[0][2] . "
\n";
//$allCoords[] = array($coords[0][1], $coords[0][2], 13*3600, 19*3600);
//$coords = XSfindAddress("D", "22041", "Hamburg", "Holzmühlenstraße", "41");
//echo $coords[0][1] . ", " . $coords[0][2] . "
\n";
//$allCoords[] = array($coords[0][1], $coords[0][2], 8*3600, 14*3600);
//$coords = XSfindAddress("D", "22525", "Hamburg", "Ottensener Straße", "8");
//echo $coords[0][1] . ", " . $coords[0][2] . "
\n";
//$allCoords[] = array($coords[0][1], $coords[0][2], 13*3600, 19*3600);
//print_r(XSplanTimewindowTour($allCoords));
//XSplanTour(array(
// array(843650, 4901137),
// array(842164, 4901883),
// array(843914, 4900754),
// array(841020, 4900941),
// array(841050, 4900578))
//);
function XSfindAddress($ad_country, $ad_zipcode, $ad_city, $ad_street, $tr_hsno)
{
// $XS_HOST = 'localhost';
$XS_HOST = '172.16.0.154';
$XS_PORT = 50020;
$XS_SERVICE = '/xlocate/ws/XLocate';
$out =
'' . "\n" .
'' . "\n" .
' ' . "\n" .
' ' . "\n" .
' ' . "\n" .
' ' . "\n" .
' ' . "\n" .
' ' . "\n" .
' ' . "\n" .
' ' . "\n" .
' ' . "\n" .
' ' . "\n" .
' ' . "\n" .
' ' . "\n" .
' ' . "\n" .
' ' . "\n" .
'' . "\n" .
"\n";
$res = xmlRequest($XS_HOST, $XS_PORT, $XS_SERVICE, $out);
$vals = $res[0];
$index = $res[1];
$log_txt = "********************************************************************************\n" . $out;
$retA = array();
if (array_key_exists('SOAP:FAULT', $index)) {
echo $vals[$index['FAULTCODE'][0]]['value'] . " : " . $vals[$index['FAULTSTRING'][0]]['value'] . "\n";
writeLog($log_txt, "xServer.inc");
die();
} else {
$log_txt .= "ERRORCODE=" . $vals[$index['RESULT'][0]]['attributes']['ERRORCODE'] . "\n";
$i = 0;
for ($i = 0, $j = 0; $i < count($index['NS6:POINT']); $i++, $j += 2) {
$log_txt .= "\n";
foreach ($vals[$index['NS2:RESULTADDRESS'][$j]]['attributes'] AS $attr => $val) {
$log_txt .= "$attr: " . $val . "\n";
}
$log_txt .= "Y, X = " . $vals[$index['NS6:POINT'][$i]]['attributes']['Y'] . ", " . $vals[$index['NS6:POINT'][$i]]['attributes']['X'] . "\n";
$retA[] = array($vals[$index['NS2:RESULTADDRESS'][$j]]['attributes']['TOTALSCORE'], $vals[$index['NS6:POINT'][$i]]['attributes']['X'], $vals[$index['NS6:POINT'][$i]]['attributes']['Y']);
}
// echo "Index array\n";
// print_r($index);
// echo "\nVals array\n";
// print_r($vals);
}
writeLog($log_txt, "xServer.inc");
return $retA;
}
function XSplanTimewindowTour($stopCoordinates, $predPos = 0, $succPos = 0)
{
// $XS_HOST = 'localhost';
$XS_HOST = '172.16.0.154';
$XS_PORT = 50050;
$XS_SERVICE = '/xsequence/ws/XSequence';
// if $predPos == 0
if ($succPos == 0)
$succPos = count($stopCoordinates) + 1;
$outStops = '';
$subStops = '';
foreach ($stopCoordinates as $idx => $pairs) {
$outStops .=
' ' . "\n" .
// ' ' . "\n" .
' ' . "\n" .
' ' . "\n" .
' ' . "\n" .
' ' . "\n" .
' ' . "\n";
$subStops .= ' ' . "\n";
}
// $planningParams->costDistanceKm = 10;
// $planningParams->costPeriodMinute = 50;
// $planningParams->maxProcessorPeriod = 5;
// $planningParams->distanceCalculation->dimaCoordFormat = 'GEODECIMAL';
$out =
'' . "\n" .
'' . "\n" .
' ' . "\n" .
' ' . "\n" .
' ' . "\n" .
$outStops .
' ' . "\n" .
' ' . "\n" .
' ' . "\n" .
' ' . "\n" .
' ' . "\n" .
' ' . "\n" .
' ' . "\n" .
' ' . "\n" .
' ' . "\n" .
$subStops .
' ' . "\n" .
' ' . "\n" .
' ' . "\n" .
' ' . "\n" .
' ' . "\n" .
' ' . "\n" .
'' . "\n" .
"\n";
//echo $out;
$res = xmlRequest($XS_HOST, $XS_PORT, $XS_SERVICE, $out);
$vals = $res[0];
$index = $res[1];
$log_txt = "********************************************************************************\n" . $out;
$retA = array();
if (array_key_exists('SOAP:FAULT', $index)) {
$log_txt .= $vals[$index['FAULTCODE'][0]]['value'] . " : " . $vals[$index['FAULTSTRING'][0]]['value'] . "\n";
// die();
} else {
$log_txt .= "RESULT=" . $vals[$index['NS2:RESULT'][0]]['attributes']['RESULT'] . "\n\n";
foreach ($vals[$index['NS17:TOUR'][0]]['attributes'] AS $attr => $val) {
$log_txt .= "$attr: $val\n";
}
for ($i = 0; $i < count($index['NS17:OUTPUTTOURPOINT']); $i += 2) {
$otp = $index['NS17:OUTPUTTOURPOINT'][$i];
$log_txt .= "\n";
$retA[] = $vals[$otp]['attributes']['STOPID'];
foreach ($vals[$otp]['attributes'] AS $attr => $val) {
$log_txt .= "$attr: $val\n";
}
}
// echo "Index array\n";
// print_r($index);
// echo "\nVals array\n";
// print_r($vals);
}
writeLog($log_txt, "xServer.inc");
return $retA;
}
function XSplanTourJob($jb_id_plan, $predPos = 0, $succPos = 0)
{
global $db;
$stopCoordinates = array();
$sqlquery = "SELECT tr_cs_freetext, tr_commission_no FROM tour WHERE jb_id = $jb_id_plan ORDER BY tr_sort";
$res = $db->query($sqlquery);
if (DB::isError($res)) reportDie ("$PHP_SELF: '$sqlquery'" . $res->getMessage());
$i = 0;
while ($row = $res->fetch_assoc()):
$interval = array();
if ($row["tr_commission_no"] == "07 - 09 Uhr")
$interval = array(7*3600, 9*3600);
if ($row["tr_commission_no"] == "08 - 19 Uhr")
$interval = array(8*3600, 19*3600);
if ($row["tr_commission_no"] == "08 - 14 Uhr")
$interval = array(8*3600, 14*3600);
if ($row["tr_commission_no"] == "13 - 19 Uhr")
$interval = array(13*3600, 19*3600);
if ($row["tr_commission_no"] == "16 - 20 Uhr")
$interval = array(16*3600, 20*3600);
$coords = explode(",", $row["tr_cs_freetext"]);
$stopCoordinates[$i++] = array($coords[0], $coords[1], $interval[0], $interval[1]);
endwhile;
$res->free();
$stopIt = false;
do {
$planTour = XSplanTimewindowTour($stopCoordinates, $predPos, $succPos);
if (count($planTour) == 0):
for ($i = 1; $i < count($stopCoordinates); $i++):
$stopCoordinates[$i][2] -= 300;
$stopCoordinates[$i][3] += 300;
if ($stopCoordinates[$i][2] < 0 OR $stopCoordinates[$i][3] > 86400):
$stopIt = true;
break;
endif;
endfor;
endif;
} while (count($planTour) == 0 && !$stopIt);
if (count($planTour) > 0):
// bestehenden tr_sort mit 100 addieren
for ($i = 0; $i < count($planTour); $i++) {
updateStmt("tour", "jb_id", $jb_id_plan, array("tr_sort", 100 + $i + 1), "tr_sort = " . ($i+1));
}
// jetzt können die neuen tr_sort geschrieben werden
for ($i = 0; $i < count($planTour); $i++) {
updateStmt("tour", "jb_id", $jb_id_plan, array("tr_sort", $i + 1), "tr_sort = " . (100 + $planTour[$i]));
}
return true;
endif;
return false;
}
function xmlRequest($host, $port, $service, $xmlReq)
{
$fp = fsockopen($host, $port, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)
\n";
} else {
fputs ($fp, "POST $service HTTP/1.1\r\n");
fputs ($fp, "Host: localhost\r\n");
fputs ($fp, "Content-type: text/xml; charset=utf-8\r\n");
fputs ($fp, "Content-length: " . strlen($xmlReq) . "\r\n");
fputs ($fp, "Connection: close\r\n\r\n");
fputs ($fp, $xmlReq);
$line = "";
while (substr($line, 0, 14) != "
Not working:
*******************************************************************************/
?>