[freeside-commits] branch FREESIDE_3_BRANCH updated. 65ea9da86b63c56dd577bb0688e8ba01b735bedf

Mark Wells mark at 420.am
Thu Dec 29 19:30:50 PST 2016


The branch, FREESIDE_3_BRANCH has been updated
       via  65ea9da86b63c56dd577bb0688e8ba01b735bedf (commit)
       via  fcba1f6878fcfba20e445889ef24856c90ef3f07 (commit)
      from  7d7ec20bcb3105021ac074d1e86896aa2a5104be (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 65ea9da86b63c56dd577bb0688e8ba01b735bedf
Author: Mark Wells <mark at freeside.biz>
Date:   Thu Dec 29 19:30:25 2016 -0800

    fix coverage map display when there are no services, #73972

diff --git a/httemplate/search/elements/gmap.html b/httemplate/search/elements/gmap.html
index b7d135d..47db150 100644
--- a/httemplate/search/elements/gmap.html
+++ b/httemplate/search/elements/gmap.html
@@ -99,11 +99,16 @@ function initMap() {
   // construct bounds around all of the features
   var bounds = new google.maps.LatLngBounds;
   map.data.forEach(function(feature) {
-    var g = feature.getGeometry();
-    if (g.getType() == 'Point') {
-      bounds.extend(g.get());
-    } else if (g.getArray) {
-      g.getArray().forEach(function(point) { bounds.extend(point); });
+    var b = feature.getProperty('bounds');
+    if (b) { // if it specifies an ROI, include all of it 
+      bounds.union(b);
+    } else {
+      var g = feature.getGeometry();
+      if (g.getType() == 'Point') {
+        bounds.extend(g.get());
+      } else if (g.getArray) {
+        g.getArray().forEach(function(point) { bounds.extend(point); });
+      }
     }
   });
 
diff --git a/httemplate/search/svc_broadband-map.html b/httemplate/search/svc_broadband-map.html
index fe3c095..95a31d3 100755
--- a/httemplate/search/svc_broadband-map.html
+++ b/httemplate/search/svc_broadband-map.html
@@ -114,9 +114,44 @@ foreach my $svc_broadband (@rows) {
   } # if tower has coords
 } # foreach $svc_broadband
 
+# if we were given a towernum or sectornum, ensure that the map includes
+# that tower/sector, even if there are no services
+
+foreach my $towernum ($cgi->param('towernum')) {
+  next if $towernum !~ /^\d+$/;
+  next if exists($towers{$towernum});
+  $towers{$towernum} = FS::tower->by_key($towernum);
+}
+
+foreach my $sectornum ($cgi->param('sectornum')) {
+  next if $sectornum !~ /^\d+$/;
+  next if exists($sectors{$sectornum});
+  $sectors{$sectornum} = FS::tower_sector->by_key($sectornum)
+    or die "bad sectornum $sectornum";
+  # and put it on the tower list also
+  my $towernum = $sectors{$sectornum}->towernum;
+  if (!exists($towers{$towernum})) {
+    $towers{$towernum} = FS::tower->by_key($towernum);
+  }
+}
+
+# if the tower/sector was included in the search, but has no services, set
+# default bounds around it of 1 minute in each direction
+my $default_bounds = 0.017;
+
 foreach my $tower (values(%towers)) {
   my $towernum = $tower->towernum;
-  my $bounds = $tower_bounds{$towernum};
+  $tower_coord{$towernum} ||= [ $tower->longitude + 0,
+                                $tower->latitude + 0,
+                                ($tower->altitude || 0) + 0
+                              ];
+warn encode_json($tower_coord{$towernum});
+  my $bounds = $tower_bounds{$towernum}
+           ||= { 'north' => $tower->latitude + $default_bounds,
+                 'south' => $tower->latitude - $default_bounds,
+                 'east'  => $tower->longitude + $default_bounds,
+                 'west'  => $tower->longitude - $default_bounds,
+               };
   # add some padding for easier reading
   my $dx = 0.1 * ($bounds->{east} - $bounds->{west});
   my $dy = 0.1 * ($bounds->{north} - $bounds->{south});
@@ -135,7 +170,7 @@ foreach my $tower (values(%towers)) {
       style     => {
         icon => {
           path        => undef,
-          url         => $fsurl.'images/jcartier-antenna-square-21x51.png',
+          url         => $fsurl.'images/antenna-square-21x51.png',
           anchor      => { x => 10, y => 4 }
         },
       },
@@ -157,7 +192,6 @@ foreach my $sector (values %sectors) {
     push @overlays, $o;
   };
 };
-
 </%init>
 <%def .svc_broadband>
 % my $svc = shift;

commit fcba1f6878fcfba20e445889ef24856c90ef3f07
Author: Mark Wells <mark at freeside.biz>
Date:   Thu Dec 29 16:00:18 2016 -0800

    fix coverage map generation on 3.x, #73266

diff --git a/FS/FS/tower_sector.pm b/FS/FS/tower_sector.pm
index 2b0efa3..6ccfe55 100644
--- a/FS/FS/tower_sector.pm
+++ b/FS/FS/tower_sector.pm
@@ -1,14 +1,16 @@
 package FS::tower_sector;
 
-use Class::Load qw(load_class);
-use File::Path qw(make_path);
-use Data::Dumper;
-
 use strict;
 use base qw( FS::Record );
 use FS::Record qw( qsearch qsearchs );
 use FS::tower;
 use FS::svc_broadband;
+use Class::Load qw(load_class);
+use File::Path qw(make_path);
+use Data::Dumper;
+use Storable qw(thaw);
+use MIME::Base64 qw(decode_base64);
+
 
 =head1 NAME
 
@@ -271,6 +273,9 @@ PARAMS must include 'sectornum'.
 sub process_generate_coverage {
   my $job = shift;
   my $param = shift;
+  if (!ref($param)) {
+    $param = thaw(decode_base64($param));
+  }
   $job->update_statustext('0,generating map') if $job;
   my $sectornum = $param->{sectornum};
   my $sector = FS::tower_sector->by_key($sectornum)

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/tower_sector.pm                    |   13 +++++++---
 httemplate/search/elements/gmap.html     |   15 +++++++----
 httemplate/search/svc_broadband-map.html |   40 +++++++++++++++++++++++++++---
 3 files changed, 56 insertions(+), 12 deletions(-)




More information about the freeside-commits mailing list