Add Testabfragen
This commit is contained in:
parent
ee315cc3d3
commit
3472ca4b7e
3 changed files with 373 additions and 0 deletions
67
test_gui.html
Normal file
67
test_gui.html
Normal file
|
@ -0,0 +1,67 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, user-scalable=no"/>
|
||||
<title>Ticketfinder</title>
|
||||
<link rel="stylesheet" href="/auer/static/inline.min.css"/>
|
||||
<script src="/auer/static/jquery-3.6.0.min.js"></script>
|
||||
<script src="/auer/static/jquery.autocomplete.min.js"></script>
|
||||
</head>
|
||||
<body class="loading">
|
||||
|
||||
<header>
|
||||
<h1 class="link search">Ticketfinder</h1>
|
||||
</header>
|
||||
|
||||
<div id="bps">
|
||||
<form method="post">
|
||||
<p><input type="search" placeholder="Starthaltestelle" id="from" autocomplete="off" autofocus></p>
|
||||
<p><input type="search" placeholder="Zielhaltestelle" id="to" autocomplete="off" autofocus></p>
|
||||
<input type="hidden" name="from"/>
|
||||
<input type="hidden" name="to"/>
|
||||
<p><input type="submit" vaue="Los!"/></p>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$('input[type=search]').autocomplete({
|
||||
minChars: 2,
|
||||
autoSelectFirst: true,
|
||||
paramName: 'name_sf',
|
||||
dataType: 'json',
|
||||
serviceUrl: 'https://www3.vvs.de/mngvvs/XML_STOPFINDER_REQUEST?SpEncId=0&coordOutputFormat=EPSG:4326&serverInfo=1&suggestApp=vvs&type_sf=any&version=10.2.10.139&suggest_macro=vvs',
|
||||
transformResult: transform,
|
||||
onSelect: function (suggestion) {
|
||||
console.log(suggestion.data);
|
||||
$("input[name="+$(this).attr('id')+"]").val(suggestion.data);
|
||||
}
|
||||
});
|
||||
|
||||
function transform (data) {
|
||||
var result = [];
|
||||
$.each(data.stopFinder.points, function( index, val ) {
|
||||
if (val.ref.gid) {
|
||||
result.push({data: val.ref.gid, value: val.name});
|
||||
}
|
||||
});
|
||||
|
||||
console.log({query: 'test', suggestions: result});
|
||||
return {query: 'test', suggestions: result};
|
||||
}
|
||||
|
||||
function func(data){
|
||||
var result = [];
|
||||
$.each(data.stopFinder.points, function( index, val ) {
|
||||
if (val.ref.gid) {
|
||||
result.push({data: val.ref.gid, value: val.name});
|
||||
}
|
||||
});
|
||||
|
||||
console.log({query: 'test', suggestions: result});
|
||||
return {query: 'test', suggestions: result};
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
153
test_route.php
Normal file
153
test_route.php
Normal file
|
@ -0,0 +1,153 @@
|
|||
<?php
|
||||
|
||||
// EFA Base URI
|
||||
#$efa_url = "http://www2.vvs.de/vvs/";
|
||||
$efa_url = "https://www.bwegt.de/efabw/";
|
||||
|
||||
|
||||
function getURL($url)
|
||||
{
|
||||
$ch = curl_init();
|
||||
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 5);
|
||||
curl_setopt ($ch, CURLOPT_URL, $url);
|
||||
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
$file_contents = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
return iconv('UTF-8', 'UTF-8//IGNORE', $file_contents);
|
||||
}
|
||||
|
||||
|
||||
$src_ifopt = filter_input(INPUT_POST, 'from', FILTER_SANITIZE_SPECIAL_CHARS);
|
||||
$dst_ifopt = filter_input(INPUT_POST, 'to', FILTER_SANITIZE_SPECIAL_CHARS);
|
||||
$datetime = explode("T", str_replace(":", "", str_replace("-", "", filter_input(INPUT_POST, 'datetime', FILTER_SANITIZE_SPECIAL_CHARS))));
|
||||
|
||||
// Bei Request
|
||||
if ($src_ifopt) {
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$trips = json_decode(getURL($efa_url."XML_TRIP_REQUEST2?SpEncId=0&changeSpeed=normal&computationType=sequence&coordOutputFormat=EPSG:4326&cycleSpeed=14&deleteAssignedStops=0&deleteITPTWalk=0&descWithElev=1&illumTransfer=on&imparedOptionsActive=1&itOptionsActive=1&itdDate=".$datetime[0]."&itdTime=".$datetime[1]."&language=de&locationServerActive=1¯oWebTrip=true&name_destination=".$dst_ifopt."&name_origin=".$src_ifopt."&noElevationProfile=1&noElevationSummary=1&outputFormat=json&outputOptionsActive=1&ptOptionsActive=1&routeType=leasttime&searchLimitMinutes=360&securityOptionsActive=1&serverInfo=1&showInterchanges=1&trITArrMOT=100&trITArrMOTvalue=15&trITDepMOT=100&trITDepMOTvalue=15&tryToFindLocalityStops=1&type_destination=any&type_origin=any&useElevationData=1&useLocalityMainStop=0&useRealtime=1&useUT=1&w_objPrefAl=12&w_regPrefAm=1"))->trips;
|
||||
|
||||
// DEBUG
|
||||
if($_GET["debug"]) print_r($trips);
|
||||
|
||||
$result;
|
||||
$result2;
|
||||
foreach ($trips as $i => $trip) {
|
||||
$result[$i]["duration"] = $trip->duration;
|
||||
$result[$i]["interchange"] = $trip->interchange;
|
||||
$k = 0;
|
||||
foreach ($trip->legs as $leg) {
|
||||
$line = $leg->mode->number;
|
||||
foreach ($leg->stopSeq as $stop) {
|
||||
$result[$i]["stops"][$k]["name"] = $stop->name;
|
||||
$result[$i]["stops"][$k]["gid"] = $stop->ref->gid;
|
||||
$result[$i]["stops"][$k]["zone"] = $stop->ref->zone;
|
||||
$result2[$i][] = $stop->ref->zone;
|
||||
|
||||
$result[$i]["stops"][$k]["time"] = ($stop->ref->depDateTime)?$stop->ref->depDateTime:$stop->ref->arrDateTime;
|
||||
$result[$i]["stops"][$k]["delay"] = $stop->ref->arrDelay;
|
||||
$result[$i]["stops"][$k]["line"] = $line;
|
||||
|
||||
$k++;
|
||||
}
|
||||
}
|
||||
}
|
||||
$result3;
|
||||
foreach($result2 as $i => $trip) {
|
||||
$verbund_name;
|
||||
foreach($trip as $item) {
|
||||
$zones = explode(';', $item);
|
||||
foreach($zones as $zone) {
|
||||
$ding = explode(':', $zone);
|
||||
$verbund_name = $ding[0];
|
||||
$maybe_multiple_zones = $ding[1];
|
||||
$multiple_zones = explode('|', $maybe_multiple_zones);
|
||||
if ($result3[$i][$verbund_name] == null) {
|
||||
$result3[$i][$verbund_name] = [];
|
||||
}
|
||||
if (!is_array($multiple_zones)) {
|
||||
$mutliple_zones = [$multiple_zones];
|
||||
}
|
||||
$result3[$i][$verbund_name] = array_unique(array_merge($result3[$i][$verbund_name], $multiple_zones));
|
||||
sort($result3[$i][$verbund_name]);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
echo json_encode($result, JSON_PRETTY_PRINT | JSON_NUMERIC_CHECK);
|
||||
|
||||
} else {
|
||||
?>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, user-scalable=no"/>
|
||||
<title>Ticketfinder</title>
|
||||
<link rel="stylesheet" href="/auer/static/inline.min.css"/>
|
||||
<script src="/auer/static/jquery-3.6.0.min.js"></script>
|
||||
<script src="/auer/static/jquery.autocomplete.min.js"></script>
|
||||
</head>
|
||||
<body class="loading">
|
||||
|
||||
<header>
|
||||
<h1 class="link search">Ticketfinder</h1>
|
||||
</header>
|
||||
|
||||
<div id="bps">
|
||||
<form method="post">
|
||||
<p><input type="search" placeholder="Starthaltestelle" id="from" autocomplete="off" autofocus></p>
|
||||
<p><input type="search" placeholder="Zielhaltestelle" id="to" autocomplete="off"></p>
|
||||
<p><input type="datetime-local" name="datetime"></p>
|
||||
<input type="hidden" name="from"/>
|
||||
<input type="hidden" name="to"/>
|
||||
<p><input type="submit" vaue="Los!"/></p>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
$(function() {
|
||||
const now = new Date();
|
||||
now.setMinutes(now.getMinutes() - now.getTimezoneOffset());
|
||||
$("input[name='datetime']").val(now.toISOString().slice(0, -8));
|
||||
});
|
||||
|
||||
|
||||
|
||||
$('input[type=search]').autocomplete({
|
||||
minChars: 2,
|
||||
autoSelectFirst: true,
|
||||
paramName: 'name_sf',
|
||||
dataType: 'json',
|
||||
serviceUrl: 'https://www.bwegt.de/efabw/XML_STOPFINDER_REQUEST?SpEncId=0&coordOutputFormat=EPSG:4326&type_sf=any&outputFormat=json&anyMaxSizeHitList=20',
|
||||
transformResult: transform,
|
||||
onSelect: function (suggestion) {
|
||||
console.log(suggestion.data);
|
||||
$("input[name="+$(this).attr('id')+"]").val(suggestion.data);
|
||||
}
|
||||
});
|
||||
|
||||
function transform (data) {
|
||||
var result = [];
|
||||
//data.stopFinder.points.sort();
|
||||
$.each(data.stopFinder.points, function( index, val ) {
|
||||
if (val.ref.gid) {
|
||||
result.push({data: val.ref.gid, value: val.name});
|
||||
}
|
||||
});
|
||||
|
||||
console.log({query: 'test', suggestions: result});
|
||||
return {query: 'test', suggestions: result};
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<?php
|
||||
}
|
153
test_route2.php
Normal file
153
test_route2.php
Normal file
|
@ -0,0 +1,153 @@
|
|||
<?php
|
||||
|
||||
// EFA Base URI
|
||||
#$efa_url = "http://www2.vvs.de/vvs/";
|
||||
$efa_url = "https://www.bwegt.de/efabw/";
|
||||
|
||||
|
||||
function getURL($url)
|
||||
{
|
||||
$ch = curl_init();
|
||||
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 5);
|
||||
curl_setopt ($ch, CURLOPT_URL, $url);
|
||||
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
$file_contents = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
return iconv('UTF-8', 'UTF-8//IGNORE', $file_contents);
|
||||
}
|
||||
|
||||
|
||||
$src_ifopt = filter_input(INPUT_POST, 'from', FILTER_SANITIZE_SPECIAL_CHARS);
|
||||
$dst_ifopt = filter_input(INPUT_POST, 'to', FILTER_SANITIZE_SPECIAL_CHARS);
|
||||
$datetime = explode("T", str_replace(":", "", str_replace("-", "", filter_input(INPUT_POST, 'datetime', FILTER_SANITIZE_SPECIAL_CHARS))));
|
||||
|
||||
// Bei Request
|
||||
if ($src_ifopt) {
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$trips = json_decode(getURL($efa_url."XML_TRIP_REQUEST2?SpEncId=0&changeSpeed=normal&computationType=sequence&coordOutputFormat=EPSG:4326&cycleSpeed=14&deleteAssignedStops=0&deleteITPTWalk=0&descWithElev=1&illumTransfer=on&imparedOptionsActive=1&itOptionsActive=1&itdDate=".$datetime[0]."&itdTime=".$datetime[1]."&language=de&locationServerActive=1¯oWebTrip=true&name_destination=".$dst_ifopt."&name_origin=".$src_ifopt."&noElevationProfile=1&noElevationSummary=1&outputFormat=json&outputOptionsActive=1&ptOptionsActive=1&routeType=leasttime&searchLimitMinutes=360&securityOptionsActive=1&serverInfo=1&showInterchanges=1&trITArrMOT=100&trITArrMOTvalue=15&trITDepMOT=100&trITDepMOTvalue=15&tryToFindLocalityStops=1&type_destination=any&type_origin=any&useElevationData=1&useLocalityMainStop=0&useRealtime=1&useUT=1&w_objPrefAl=12&w_regPrefAm=1"))->trips;
|
||||
|
||||
// DEBUG
|
||||
if($_GET["debug"]) print_r($trips);
|
||||
|
||||
$result;
|
||||
$result2;
|
||||
foreach ($trips as $i => $trip) {
|
||||
$result[$i]["duration"] = $trip->duration;
|
||||
$result[$i]["interchange"] = $trip->interchange;
|
||||
$k = 0;
|
||||
foreach ($trip->legs as $leg) {
|
||||
$line = $leg->mode->number;
|
||||
foreach ($leg->stopSeq as $stop) {
|
||||
$result[$i]["stops"][$k]["name"] = $stop->name;
|
||||
$result[$i]["stops"][$k]["gid"] = $stop->ref->gid;
|
||||
$result[$i]["stops"][$k]["zone"] = $stop->ref->zone;
|
||||
$result2[$i][] = $stop->ref->zone;
|
||||
|
||||
$result[$i]["stops"][$k]["time"] = ($stop->ref->depDateTime)?$stop->ref->depDateTime:$stop->ref->arrDateTime;
|
||||
$result[$i]["stops"][$k]["delay"] = $stop->ref->arrDelay;
|
||||
$result[$i]["stops"][$k]["line"] = $line;
|
||||
|
||||
$k++;
|
||||
}
|
||||
}
|
||||
}
|
||||
$result3;
|
||||
foreach($result2 as $i => $trip) {
|
||||
$verbund_name;
|
||||
foreach($trip as $item) {
|
||||
$zones = explode(';', $item);
|
||||
foreach($zones as $zone) {
|
||||
$ding = explode(':', $zone);
|
||||
$verbund_name = $ding[0];
|
||||
$maybe_multiple_zones = $ding[1];
|
||||
$multiple_zones = explode('|', $maybe_multiple_zones);
|
||||
if ($result3[$i][$verbund_name] == null) {
|
||||
$result3[$i][$verbund_name] = [];
|
||||
}
|
||||
if (!is_array($multiple_zones)) {
|
||||
$mutliple_zones = [$multiple_zones];
|
||||
}
|
||||
$result3[$i][$verbund_name] = array_unique(array_merge($result3[$i][$verbund_name], $multiple_zones));
|
||||
sort($result3[$i][$verbund_name]);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
echo json_encode($result3, JSON_PRETTY_PRINT | JSON_NUMERIC_CHECK);
|
||||
|
||||
} else {
|
||||
?>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, user-scalable=no"/>
|
||||
<title>Ticketfinder</title>
|
||||
<link rel="stylesheet" href="/auer/static/inline.min.css"/>
|
||||
<script src="/auer/static/jquery-3.6.0.min.js"></script>
|
||||
<script src="/auer/static/jquery.autocomplete.min.js"></script>
|
||||
</head>
|
||||
<body class="loading">
|
||||
|
||||
<header>
|
||||
<h1 class="link search">Ticketfinder</h1>
|
||||
</header>
|
||||
|
||||
<div id="bps">
|
||||
<form method="post">
|
||||
<p><input type="search" placeholder="Starthaltestelle" id="from" autocomplete="off" autofocus></p>
|
||||
<p><input type="search" placeholder="Zielhaltestelle" id="to" autocomplete="off"></p>
|
||||
<p><input type="datetime-local" name="datetime"></p>
|
||||
<input type="hidden" name="from"/>
|
||||
<input type="hidden" name="to"/>
|
||||
<p><input type="submit" vaue="Los!"/></p>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
$(function() {
|
||||
const now = new Date();
|
||||
now.setMinutes(now.getMinutes() - now.getTimezoneOffset());
|
||||
$("input[name='datetime']").val(now.toISOString().slice(0, -8));
|
||||
});
|
||||
|
||||
|
||||
|
||||
$('input[type=search]').autocomplete({
|
||||
minChars: 2,
|
||||
autoSelectFirst: true,
|
||||
paramName: 'name_sf',
|
||||
dataType: 'json',
|
||||
serviceUrl: 'https://www.bwegt.de/efabw/XML_STOPFINDER_REQUEST?SpEncId=0&coordOutputFormat=EPSG:4326&type_sf=any&outputFormat=json&anyMaxSizeHitList=20',
|
||||
transformResult: transform,
|
||||
onSelect: function (suggestion) {
|
||||
console.log(suggestion.data);
|
||||
$("input[name="+$(this).attr('id')+"]").val(suggestion.data);
|
||||
}
|
||||
});
|
||||
|
||||
function transform (data) {
|
||||
var result = [];
|
||||
//data.stopFinder.points.sort();
|
||||
$.each(data.stopFinder.points, function( index, val ) {
|
||||
if (val.ref.gid) {
|
||||
result.push({data: val.ref.gid, value: val.name});
|
||||
}
|
||||
});
|
||||
|
||||
console.log({query: 'test', suggestions: result});
|
||||
return {query: 'test', suggestions: result};
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<?php
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue