From ccd822eb8751deae96b57df4ce6abc56a195b9c4 Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Wed, 13 Apr 2016 19:18:34 -0700 Subject: tower location CSV download, #39776 --- httemplate/misc/tower-export.html | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 httemplate/misc/tower-export.html (limited to 'httemplate/misc/tower-export.html') diff --git a/httemplate/misc/tower-export.html b/httemplate/misc/tower-export.html new file mode 100644 index 000000000..d359a97a5 --- /dev/null +++ b/httemplate/misc/tower-export.html @@ -0,0 +1,36 @@ +<%init> +# currently, browse/tower just shows all towers, so do the same here +my @towers = qsearch({ table => 'tower' }); +http_header('Content-Type' => 'text/csv'); +http_header('Content-Disposition' => 'attachment;filename=towers.csv'); +if ( $cgi->param('format') eq 'tc' ) { + # towercoverage.com format: not a true CSV, no quoting (so no way to include + # commas in any field, so we strip them) + + # lat/long are signed decimals, northeast positive + # height is in meters + # Description/Group are not necessary + # sector/antenna information (orientation, beamwidth, gain, frequency, + # etc.) is in what TC calls a "Coverage", which can't be edited this way. + my $text = "SiteName,Latitude,Longitude,Description,Group,Height\n"; + + foreach my $tower (@towers) { + next if ( !$tower->latitude or !$tower->longitude ); + + my $name = $tower->towername; + my $height = ( ($tower->altitude || 0 ) + ($tower->height || 0) ) / 3.28; + $name =~ s(,)( )g; + $text .= join(',', + $name, + $tower->latitude, + $tower->longitude, + '', + '', + $height, + ) . "\n"; + } + $m->print($text); +} else { + die('unknown format '.$cgi->param('format')); +} + -- cgit v1.2.1 From 1820be6ab6ebe7efa911b4dc80810b07c233980f Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Thu, 14 Apr 2016 12:16:28 -0700 Subject: fix tower height, #39776 --- httemplate/misc/tower-export.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/misc/tower-export.html') diff --git a/httemplate/misc/tower-export.html b/httemplate/misc/tower-export.html index d359a97a5..9d63640f0 100644 --- a/httemplate/misc/tower-export.html +++ b/httemplate/misc/tower-export.html @@ -18,7 +18,7 @@ if ( $cgi->param('format') eq 'tc' ) { next if ( !$tower->latitude or !$tower->longitude ); my $name = $tower->towername; - my $height = ( ($tower->altitude || 0 ) + ($tower->height || 0) ) / 3.28; + my $height = ($tower->height || 0) / 3.28; $name =~ s(,)( )g; $text .= join(',', $name, -- cgit v1.2.1