geo_distance by geo_fencing

This commit is contained in:
Rainer Gümpelein 2022-01-11 10:53:21 +01:00
parent d928abe0ec
commit e79c8f1894
5 changed files with 20 additions and 8 deletions

View file

@ -790,6 +790,7 @@ sub service_work {
sub booking_update(){
my $self = shift;
my $q = shift;
my $varenv = shift;
my $auth = shift;
my $owner = shift || 0;
my $state = $q->escapeHTML($q->param('state')) || "";
@ -962,7 +963,7 @@ sub booking_update(){
my $geo_distance_next = 100000;
my $station_next = 0;
my $geo_debug="";
my ($stations,$stations_raw) = $self->stations_available($q,$auth);
my ($stations,$stations_raw) = $self->stations_available($q,$varenv,$auth);
foreach my $id (sort { $stations_raw->{$a}->{barcode} <=> $stations_raw->{$b}->{barcode} } keys (%$stations_raw)){
my $latitude_station = $1 if($stations_raw->{$id}->{txt06} =~ /^(\d+\.\d+)/);
my $longitude_station = $1 if($stations_raw->{$id}->{txt06} =~ /(\d+\.\d+)$/);
@ -1127,7 +1128,7 @@ sub booking_update(){
#geofencing for Ilockit
my $geo_distance_next = $geo_distance;
my $geo_debug="";
my ($stations,$stations_raw) = $self->stations_available($q,$auth);
my ($stations,$stations_raw) = $self->stations_available($q,$varenv,$auth);
foreach my $id (sort { $stations_raw->{$a}->{barcode} <=> $stations_raw->{$b}->{barcode} } keys (%$stations_raw)){
my $latitude_station = $1 if($stations_raw->{$id}->{txt06} =~ /^(\d+\.\d+)/);
my $longitude_station = $1 if($stations_raw->{$id}->{txt06} =~ /(\d+\.\d+)$/);
@ -1135,6 +1136,7 @@ sub booking_update(){
$geo_debug .= "locked ERROR no user GPS: $stations_raw->{$id}->{barcode}|$latitude,$longitude,$latitude_station,$longitude_station --> $geo_distance Meter\n";
}elsif(looks_like_number($latitude) && looks_like_number($longitude) && looks_like_number($latitude_station) && looks_like_number($longitude_station)){
$geo_distance = $lb->geo_fencing($latitude,$longitude,$latitude_station,$longitude_station);
$bw->log("geo_distance by geo_fencing:$latitude,$longitude,$latitude_station,$longitude_station|$stations_raw->{$id}->{txt06}",$geo_distance,"");
if($geo_distance <= $stations_raw->{$id}->{int06}){
$geo_distance_next = $geo_distance;
#end-Station

View file

@ -221,7 +221,7 @@ elsif($q->param('request') eq "booking_request"){
#just in time booking
if(ref($response_book) eq "HASH" && $response_book->{response_state} =~ /OK/ && $q->param('state') && $q->param('state') =~ /occupied/){
(my $rows, my $booking_values) = $apif->booking_update($q,$authraw,$aowner);
(my $rows, my $booking_values) = $apif->booking_update($q,\%varenv,$authraw,$aowner);
$response = {%$response, %$booking_values};
}else{
$response = {%$response, %$response_book};
@ -274,10 +274,10 @@ elsif($q->param('request') eq "booking_cancel" || $q->param('request') eq "booki
if(ref($auth) eq "HASH" && $auth->{authcookie}){
if($q->param('bike')){
if($q->param('request') eq "booking_update" && $q->param('state') && $q->param('state') =~ /canceled/){
($rows, my $booking_values) = $apif->booking_update($q,$authraw,$aowner);
($rows, my $booking_values) = $apif->booking_update($q,\%varenv,$authraw,$aowner);
$response = {%$response, %$booking_values};
}elsif($q->param('request') eq "booking_update" && (($q->param('state') && $q->param('state') =~ /occupied|available/) || ($q->param('lock_state') && $q->param('lock_state') =~ /locking|locked|unlocked/))){
($rows, my $booking_values) = $apif->booking_update($q,$authraw,$aowner);
($rows, my $booking_values) = $apif->booking_update($q,\%varenv,$authraw,$aowner);
$response = {%$response, %$booking_values};
#keep in mind, it works on operator dependency
@ -422,6 +422,9 @@ elsif($q->param('request') eq "bikes_available"){
#my $stamp = gettimeofday;
#$bw->log("X bikes_available $varenv{syshost} $stamp: $response->{user_group}",$response,"");
}else{
($aowner,my $return_merchant) = $apif->fetch_merchant($q,\%varenv,$coo,$q->param('merchant_id'));
$varenv{merchant_id} = $return_merchant->{merchant_id};
my ($auth,$authraw) = $apif->auth_verify($q);#on operator loop select, operator adr must be select to get user_group
$response = { %$response, %$auth };
$bw->log("Y bikes_available by c_id $authraw->{c_id}, Tarif:",$authraw->{txt30},"");
@ -622,6 +625,9 @@ elsif($q->param('request') eq "stations_available"){
$response = { %$response, %$auth };
($response->{stations},$response->{uri_operator_array},$response->{user_group},$response->{user_tour}) = $jsc->loop_sharees($q,$auth,$aowner);
}else{
($aowner,my $return_merchant) = $apif->fetch_merchant($q,\%varenv,$coo,$q->param('merchant_id'));
$varenv{merchant_id} = $return_merchant->{merchant_id};
my ($auth,$authraw) = $apif->auth_verify($q);
$response = { %$response, %$auth };
($response->{stations}, my $response_raw) = $apif->stations_available($q,\%varenv,$authraw);

View file

@ -58,6 +58,10 @@ sub tpl(){
require "Mod/KMLout.pm";
my $kmlfile = Mod::KMLout::kmlGenerator($api_return,$varenv,$users_sharee);
my $filesize = -s "$varenv->{metahost}/xml/$kmlfile";
my $preserve_view = "false";
$preserve_view = "true" if($filesize < 200);#it's like empty without publixc stations
print "<div style='background-color:#cccccc;width:100%;margin-top:40px;'>\n";
print "$initMap|$varenv->{dbname}|$api_return->{authcookie}|$users_sharee->{c_id}|$kmlfile" if($users_dms->{u_id} == $dbt->{copri_conf}->{superu_id});
@ -76,7 +80,7 @@ print<<EOF
var ctaLayer = new google.maps.KmlLayer({
position: map.getCenter(),
//preserveViewport: true,
preserveViewport: $preserve_view,
//url: '$dbt->{primary}->{sharee_primary}->{primaryApp}/KMLout?kml=' + (new Date()).getTime() + '$users_sharee->{c_id}',
//url: '$varenv->{metahost}/xml/KMLout-3',
//url: '$varenv->{wwwhost}/?kml=' + (new Date()).getTime(),

View file

@ -36,7 +36,7 @@ for i in $(find . -type d -and -name cronjobs); do chown -R root:root $i/*;done
live_sharee="ginger"
echo "You are on Server with hostname: $(hostname)";
echo "";
echo "on main gitlab sourcen there is no live config";
#sharee
echo "KEEP in mind, SHAREE autoLinking is only done if $(hostname) == ${live_sharee}";

View file

@ -103,7 +103,7 @@ sub tpl(){
}
#email tag with little coding against grabber
if($record_cc->{$key} =~ /(\w+\@[\w-]+\.\w+)/){
$record_cc->{$key} =~ s/(\w+\@[\w-]+\.\w+)/\<a href=\'mailto:$1\'\>$1\<\/a\>/;
$record_cc->{$key} =~ s/([\w\.\-_]+\@[\w-]+\.\w+)/\<a href=\'mailto:$1\'\>$1\<\/a\>/;
$record_cc->{$key} =~ s/\@/\&\#64\;/g;
}
$record_cc->{$key} =~ s/\\//g;