summaryrefslogtreecommitdiff
path: root/packaging
diff options
context:
space:
mode:
authorMichael R. Davis <mrdvt@cpan.org>2011-04-18 03:27:27 +0000
committerEric S. Raymond <esr@thyrsus.com>2011-04-22 02:29:37 -0400
commitf92306676b52c300a2a3da64fea273c0b6240df3 (patch)
tree4434f43ee7f51d4bd8cb91d46a669fbc73214db5 /packaging
parent279ddb6ebbb4c01a2ebf306bab227df09f12fb96 (diff)
downloadgpsd-f92306676b52c300a2a3da64fea273c0b6240df3.tar.gz
Close to getting RPM spec back in working order.
Signed-off-by: Eric S. Raymond <esr@thyrsus.com>
Diffstat (limited to 'packaging')
-rw-r--r--packaging/rpm/httpd/gpsd.conf8
-rwxr-xr-xpackaging/rpm/httpd/pgps.cgi114
-rwxr-xr-xpackaging/rpm/httpd/skyview.cgi55
3 files changed, 177 insertions, 0 deletions
diff --git a/packaging/rpm/httpd/gpsd.conf b/packaging/rpm/httpd/gpsd.conf
new file mode 100644
index 00000000..6af3a54d
--- /dev/null
+++ b/packaging/rpm/httpd/gpsd.conf
@@ -0,0 +1,8 @@
+<Directory "/var/www/html/gpsd">
+ DirectoryIndex index.cgi
+ AddHandler cgi-script .cgi
+ AllowOverride None
+ Order Allow,Deny
+ Allow from all
+ Options +ExecCGI
+</Directory>
diff --git a/packaging/rpm/httpd/pgps.cgi b/packaging/rpm/httpd/pgps.cgi
new file mode 100755
index 00000000..86106cbf
--- /dev/null
+++ b/packaging/rpm/httpd/pgps.cgi
@@ -0,0 +1,114 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use CGI qw{};
+use CGI::Carp qw(fatalsToBrowser);
+use Net::GPSD3 0.14;
+
+=head1 NAME
+
+pgps.cgi - Builds a Satellite List and displays GPS data from a POLL request to a GPSD server
+
+=head1 COPYRIGHT
+
+Copyright (c) 2011 - Michael R. Davis
+
+This program is free software licensed under The BSD License.
+
+=cut
+
+my $cgi=CGI->new;
+my $host=$cgi->param("host") || undef;
+my $port=$cgi->param("port") || undef;
+my $gpsd=Net::GPSD3->new(host=>$host, port=>$port);
+my $poll=$gpsd->poll;
+
+my @param=();
+push @param, "host=".$host if defined $host;
+push @param, "port=".$port if defined $port;
+my $img=join("?", "skyview.cgi", scalar(@param) ? join(";", @param) : ());
+
+my $content=join "",
+ $cgi->start_html(-title=>"Perl GPSD CGI"),
+ $cgi->table({border=>0, width=>"100%", style=>"BORDER-COLLAPSE: collapse"},
+ $cgi->Tr(
+ $cgi->td({width=>"30%", valign=>"top"},"Satellite List",
+ $cgi->table({border=>2, width=>"100%", style=>"BORDER-COLLAPSE: collapse"},
+ $cgi->Tr(
+ $cgi->td([qw{PRN Elev Azim SNR Used}]),
+ ),
+ map {
+ $cgi->Tr([
+ $cgi->td([$_->prn, $_->el, $_->az, $_->ss, $_->used ? "Y" : "N"])])
+ } sort {$b->used <=> $a->used or $b->ss <=> $a->ss} $poll->sky->Satellites
+ ),
+ ),
+ $cgi->td({valign=>"top"}, "Skyview",
+ $cgi->table({border=>2, style=>"BORDER-COLLAPSE: collapse"},
+ $cgi->Tr(
+ $cgi->td(
+ $cgi->img({-src=>$img}),
+ ),
+ ),
+ ),
+ ),
+ ),
+ $cgi->Tr(
+ $cgi->td({-colspan=>2, valign=>"top"}, "GPS data",
+ $cgi->table({border=>2, width=>"100%", style=>"BORDER-COLLAPSE: collapse"},
+ $cgi->Tr(
+ $cgi->td({align=>"right", width=>"25%"}, "Time:"),
+ $cgi->td({width=>"25%"}, $poll->tpv->timestamp),
+ $cgi->td({align=>"right", width=>"25%"}, "Status:"),
+ $cgi->td({width=>"25%"}, $poll->tpv->mode),
+ ),
+ $cgi->Tr(
+ $cgi->td({align=>"right"}, "Latitude:"),
+ $cgi->td($poll->tpv->lat),
+ $cgi->td({align=>"right"}, "EPX:"),
+ $cgi->td($poll->tpv->epx),
+ ),
+ $cgi->Tr(
+ $cgi->td({align=>"right"}, "Longitude:"),
+ $cgi->td($poll->tpv->lon),
+ $cgi->td({align=>"right"}, "EPY:"),
+ $cgi->td($poll->tpv->epy),
+ ),
+ $cgi->Tr(
+ $cgi->td({align=>"right"}, "Altitude:"),
+ $cgi->td($poll->tpv->alt),
+ $cgi->td({align=>"right"}, "EPV:"),
+ $cgi->td($poll->tpv->epv),
+ ),
+ $cgi->Tr(
+ $cgi->td({align=>"right"}, "Speed:"),
+ $cgi->td($poll->tpv->speed),
+ $cgi->td({align=>"right"}, "EPS:"),
+ $cgi->td($poll->tpv->eps),
+ ),
+ $cgi->Tr(
+ $cgi->td({align=>"right"}, "Climb:"),
+ $cgi->td($poll->tpv->climb),
+ $cgi->td({align=>"right"}, "EPC:"),
+ $cgi->td($poll->tpv->epc),
+ ),
+ $cgi->Tr(
+ $cgi->td({align=>"right"}, "Track:"),
+ $cgi->td($poll->tpv->track),
+ $cgi->td({align=>"right"}, "EPD:"),
+ $cgi->td($poll->tpv->epd),
+ ),
+ ),
+ ),
+ ),
+ ),
+ $cgi->p({align=>"center"}, "Copyright &copy; 2011 - Michael R. Davis, License: BSD"),
+ $cgi->end_html, "\n";
+
+print join "",
+ $cgi->header(
+ -content_length => length($content),
+ -expires => '+5m',
+ -Refresh => '30', #seconds
+ ),
+ $content;
diff --git a/packaging/rpm/httpd/skyview.cgi b/packaging/rpm/httpd/skyview.cgi
new file mode 100755
index 00000000..a3f64061
--- /dev/null
+++ b/packaging/rpm/httpd/skyview.cgi
@@ -0,0 +1,55 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use GD::Graph::Polar;
+use Net::GPSD3 0.14;
+use CGI;
+
+=head1 NAME
+
+skyview.cgi - Builds a Skyview PNG image from a POLL request to a GPSD server
+
+=head1 COPYRIGHT
+
+Copyright (c) 2011 - Michael R. Davis
+
+This program is free software licensed under The BSD License.
+
+=cut
+
+my $cgi=CGI->new;
+
+my $host=$cgi->param("host") || undef;
+my $port=$cgi->param("port") || undef;
+my $gpsd=Net::GPSD3->new(host=>$host, port=>$port);
+
+my $size=$cgi->param("size") || 380;
+my $gd=GD::Graph::Polar->new(size=>$size, radius=>90, border=>3, ticks=>9);
+
+my $poll;
+eval '$poll=$gpsd->poll';
+my $error=$@;
+if ($error) {
+ chomp $error;
+ $gd->color([248,8,8]); #red
+ $gd->addString(127=>134.5, $error);
+} else {
+ foreach my $sat ($poll->sky->Satellites) {
+ if ($sat->ss > 34) {
+ $gd->color([16,240,16]); #green
+ } elsif ($sat->ss >= 30) {
+ $gd->color([240,240,16]); #yellow
+ } elsif ($sat->ss >= 10) {
+ $gd->color([240,16,16]); #red
+ } else {
+ $gd->color([128,128,128]); #gray
+ }
+ $gd->addGeoPoint(90-$sat->el => $sat->az);
+ $gd->color([16,16,16]);
+ $gd->addGeoString(90-$sat->el => $sat->az, $sat->prn);
+ }
+}
+$gd->color([210,210,210]); #gray
+$gd->addGeoString(122 => 227.0, "Copyright (c) 2011 Michael R. Davis");
+
+print "Content-type: image/png\n\n", $gd->draw;