<& /elements/header.html, 'Broadband Search Results' &> <& elements/gmap.html, features => \@features, overlays => \@overlays &> <& /elements/footer.html &> <%init> die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('List services'); my $conf = new FS::Conf; $m->comp('/elements/handle_uri_query'); my @features; # geoJSON structure # accept all the search logic from svc_broadband.cgi... my %search_hash; if ( $cgi->param('magic') eq 'unlinked' ) { %search_hash = ( 'unlinked' => 1 ); } else { foreach (qw( custnum agentnum svcpart cust_fields )) { $search_hash{$_} = $cgi->param($_) if $cgi->param($_); } foreach (qw(pkgpart routernum towernum sectornum)) { $search_hash{$_} = [ $cgi->param($_) ] if $cgi->param($_); } } if ( $cgi->param('sortby') =~ /^(\w+)$/ ) { $search_hash{'order_by'} = "ORDER BY $1"; } my $sql_query = FS::svc_broadband->search(\%search_hash); my %routerbyblock = (); my @rows = qsearch($sql_query); my %sectors; my %towers; my %tower_coord; my %tower_bounds; foreach my $svc_broadband (@rows) { # don't try to show it if coords aren't set next if !$svc_broadband->latitude || !$svc_broadband->longitude; # coerce coordinates to numbers my @coord = ( $svc_broadband->longitude + 0, $svc_broadband->latitude + 0, ); push @coord, $svc_broadband->altitude + 0 if length($svc_broadband->altitude); # it's optional my $svcnum = $svc_broadband->svcnum; my $color = $svc_broadband->addr_status_color; push @features, { id => 'svc_broadband/'.$svcnum, geometry => { type => 'Point', coordinates => \@coord, }, properties => { #content => include('.svc_broadband', $svc_broadband), url => $fsurl . 'view/svc_broadband-popup.html?' . $svcnum, style => { icon => { fillColor => $color, }, }, }, }; # look up tower location and draw connecting line next if !$svc_broadband->sectornum; my $sector = $sectors{$svc_broadband->sectornum} ||= $svc_broadband->tower_sector; my $towernum = $sector->towernum; my $tower = $towers{$towernum}; if (!$tower) { $tower = $towers{$towernum} = $sector->tower; $tower_coord{$towernum} = [ $tower->longitude + 0, $tower->latitude + 0, ($tower->altitude || 0) + 0, ]; } if ( $tower->latitude and $tower->longitude ) { push @features, { geometry => { type => 'LineString', coordinates => [ \@coord, $tower_coord{$towernum} ], }, properties => { style => { strokeColor => $color, strokeWeight => 1, }, }, }; # also extend tower's ROI to include this point # (this is experimental; might get better results using the centroid of # all connected services or something) my $bounds = $tower_bounds{$towernum} ||= { east => $tower->longitude, west => $tower->longitude, north => $tower->latitude, south => $tower->latitude, }; if ($coord[0] > $bounds->{east}) { $bounds->{east} = $coord[0]; } elsif ($coord[0] < $bounds->{west}) { $bounds->{west} = $coord[0]; } if ($coord[1] > $bounds->{north}) { $bounds->{north} = $coord[1] } elsif ($coord[1] < $bounds->{south}) { $bounds->{south} = $coord[1] } } # if tower has coords } # foreach $svc_broadband foreach my $tower (values(%towers)) { my $towernum = $tower->towernum; my $bounds = $tower_bounds{$towernum}; # add some padding for easier reading my $dx = 0.1 * ($bounds->{east} - $bounds->{west}); my $dy = 0.1 * ($bounds->{north} - $bounds->{south}); $bounds->{east} += $dx; $bounds->{west} -= $dx; $bounds->{north} += $dy; $bounds->{south} -= $dy; push @features, { id => 'tower/'.$towernum, geometry => { type => 'Point', coordinates => $tower_coord{$towernum}, }, properties => { style => { icon => { path => undef, url => $fsurl.'images/antenna-square-21x51.png', anchor => { x => 10, y => 4 } }, }, content => include('.tower', $tower), bounds => $tower_bounds{$towernum}, }, }; } my @overlays; foreach my $sector (values %sectors) { if ( length($sector->image) > 0 ) { my $o = { url => $fsurl.'view/sector_map-png.cgi?' . $sector->sectornum }; foreach (qw(south north west east)) { $o->{$_} = $sector->get($_) + 0; } push @overlays, $o; }; }; <%def .tower> % my $tower = shift; % my $can_edit = $FS::CurrentUser::CurrentUser->access_right('Configuration');

% if ( $can_edit ) { % } Tower #<% $tower->towernum %> | <% $tower->towername %> % if ( $can_edit ) { % }