mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2025-02-22 11:46:27 +01:00
geo_distance by geo_fencing
This commit is contained in:
parent
d928abe0ec
commit
e79c8f1894
5 changed files with 20 additions and 8 deletions
|
@ -790,6 +790,7 @@ sub service_work {
|
||||||
sub booking_update(){
|
sub booking_update(){
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $q = shift;
|
my $q = shift;
|
||||||
|
my $varenv = shift;
|
||||||
my $auth = shift;
|
my $auth = shift;
|
||||||
my $owner = shift || 0;
|
my $owner = shift || 0;
|
||||||
my $state = $q->escapeHTML($q->param('state')) || "";
|
my $state = $q->escapeHTML($q->param('state')) || "";
|
||||||
|
@ -962,7 +963,7 @@ sub booking_update(){
|
||||||
my $geo_distance_next = 100000;
|
my $geo_distance_next = 100000;
|
||||||
my $station_next = 0;
|
my $station_next = 0;
|
||||||
my $geo_debug="";
|
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)){
|
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 $latitude_station = $1 if($stations_raw->{$id}->{txt06} =~ /^(\d+\.\d+)/);
|
||||||
my $longitude_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
|
#geofencing for Ilockit
|
||||||
my $geo_distance_next = $geo_distance;
|
my $geo_distance_next = $geo_distance;
|
||||||
my $geo_debug="";
|
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)){
|
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 $latitude_station = $1 if($stations_raw->{$id}->{txt06} =~ /^(\d+\.\d+)/);
|
||||||
my $longitude_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";
|
$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)){
|
}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);
|
$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}){
|
if($geo_distance <= $stations_raw->{$id}->{int06}){
|
||||||
$geo_distance_next = $geo_distance;
|
$geo_distance_next = $geo_distance;
|
||||||
#end-Station
|
#end-Station
|
||||||
|
|
|
@ -221,7 +221,7 @@ elsif($q->param('request') eq "booking_request"){
|
||||||
|
|
||||||
#just in time booking
|
#just in time booking
|
||||||
if(ref($response_book) eq "HASH" && $response_book->{response_state} =~ /OK/ && $q->param('state') && $q->param('state') =~ /occupied/){
|
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};
|
$response = {%$response, %$booking_values};
|
||||||
}else{
|
}else{
|
||||||
$response = {%$response, %$response_book};
|
$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(ref($auth) eq "HASH" && $auth->{authcookie}){
|
||||||
if($q->param('bike')){
|
if($q->param('bike')){
|
||||||
if($q->param('request') eq "booking_update" && $q->param('state') && $q->param('state') =~ /canceled/){
|
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};
|
$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/))){
|
}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};
|
$response = {%$response, %$booking_values};
|
||||||
|
|
||||||
#keep in mind, it works on operator dependency
|
#keep in mind, it works on operator dependency
|
||||||
|
@ -422,6 +422,9 @@ elsif($q->param('request') eq "bikes_available"){
|
||||||
#my $stamp = gettimeofday;
|
#my $stamp = gettimeofday;
|
||||||
#$bw->log("X bikes_available $varenv{syshost} $stamp: $response->{user_group}",$response,"");
|
#$bw->log("X bikes_available $varenv{syshost} $stamp: $response->{user_group}",$response,"");
|
||||||
}else{
|
}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
|
my ($auth,$authraw) = $apif->auth_verify($q);#on operator loop select, operator adr must be select to get user_group
|
||||||
$response = { %$response, %$auth };
|
$response = { %$response, %$auth };
|
||||||
$bw->log("Y bikes_available by c_id $authraw->{c_id}, Tarif:",$authraw->{txt30},"");
|
$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 = { %$response, %$auth };
|
||||||
($response->{stations},$response->{uri_operator_array},$response->{user_group},$response->{user_tour}) = $jsc->loop_sharees($q,$auth,$aowner);
|
($response->{stations},$response->{uri_operator_array},$response->{user_group},$response->{user_tour}) = $jsc->loop_sharees($q,$auth,$aowner);
|
||||||
}else{
|
}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);
|
my ($auth,$authraw) = $apif->auth_verify($q);
|
||||||
$response = { %$response, %$auth };
|
$response = { %$response, %$auth };
|
||||||
($response->{stations}, my $response_raw) = $apif->stations_available($q,\%varenv,$authraw);
|
($response->{stations}, my $response_raw) = $apif->stations_available($q,\%varenv,$authraw);
|
||||||
|
|
|
@ -58,6 +58,10 @@ sub tpl(){
|
||||||
|
|
||||||
require "Mod/KMLout.pm";
|
require "Mod/KMLout.pm";
|
||||||
my $kmlfile = Mod::KMLout::kmlGenerator($api_return,$varenv,$users_sharee);
|
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 "<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});
|
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({
|
var ctaLayer = new google.maps.KmlLayer({
|
||||||
position: map.getCenter(),
|
position: map.getCenter(),
|
||||||
//preserveViewport: true,
|
preserveViewport: $preserve_view,
|
||||||
//url: '$dbt->{primary}->{sharee_primary}->{primaryApp}/KMLout?kml=' + (new Date()).getTime() + '$users_sharee->{c_id}',
|
//url: '$dbt->{primary}->{sharee_primary}->{primaryApp}/KMLout?kml=' + (new Date()).getTime() + '$users_sharee->{c_id}',
|
||||||
//url: '$varenv->{metahost}/xml/KMLout-3',
|
//url: '$varenv->{metahost}/xml/KMLout-3',
|
||||||
//url: '$varenv->{wwwhost}/?kml=' + (new Date()).getTime(),
|
//url: '$varenv->{wwwhost}/?kml=' + (new Date()).getTime(),
|
||||||
|
|
|
@ -36,7 +36,7 @@ for i in $(find . -type d -and -name cronjobs); do chown -R root:root $i/*;done
|
||||||
|
|
||||||
live_sharee="ginger"
|
live_sharee="ginger"
|
||||||
echo "You are on Server with hostname: $(hostname)";
|
echo "You are on Server with hostname: $(hostname)";
|
||||||
echo "";
|
echo "on main gitlab sourcen there is no live config";
|
||||||
|
|
||||||
#sharee
|
#sharee
|
||||||
echo "KEEP in mind, SHAREE autoLinking is only done if $(hostname) == ${live_sharee}";
|
echo "KEEP in mind, SHAREE autoLinking is only done if $(hostname) == ${live_sharee}";
|
||||||
|
|
|
@ -103,7 +103,7 @@ sub tpl(){
|
||||||
}
|
}
|
||||||
#email tag with little coding against grabber
|
#email tag with little coding against grabber
|
||||||
if($record_cc->{$key} =~ /(\w+\@[\w-]+\.\w+)/){
|
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/\@/\&\#64\;/g;
|
||||||
}
|
}
|
||||||
$record_cc->{$key} =~ s/\\//g;
|
$record_cc->{$key} =~ s/\\//g;
|
||||||
|
|
Loading…
Add table
Reference in a new issue