Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update cif_geodatagen.pl

added uniqueness to the IPs, avoids creating huge JSON files that take a long time to render. 
  • Loading branch information...
commit 2cbfd2a4cfc91d2c28618cfe97e94fafaf40dc39 1 parent 84269ec
@divious1 authored
Showing with 17 additions and 3 deletions.
  1. +17 −3 cif_geodatagen.pl
View
20 cif_geodatagen.pl
@@ -11,12 +11,14 @@
my $json;
+my @data;
my $convert_magnitude;
my $ip;
my $record;
my $lat;
my $lon;
+
#Generates first data series for the JSON (1 hour)
$json .= "[";
$convert_magnitude=.05;
@@ -32,12 +34,13 @@
$lat = $record->latitude;
$lon = $record->longitude;
#LONGITUDE LATITUDE HEIGHT OF SPIKE IN GLOBE COLOR CODE
- $json .= $lat . "," . $lon . "," . $convert_magnitude . "," . "7" . ",\n";
+ push (@data, "$lat,$lon,$convert_magnitude,7,\n");
}
}
}
+
$convert_magnitude=.02;
while (my $hourly_line = <DAILY>) {
@@ -50,13 +53,24 @@
if ( defined $record ) {
$lat = $record->latitude;
$lon = $record->longitude;
- $json .= $lat . "," . $lon . "," . $convert_magnitude . "," . "16" . ",\n";
+ push (@data, "$lat,$lon,$convert_magnitude,16,\n");
}
}
}
#closing caret for the json
+my @unique;
+my %seen;
+foreach (@data) {
+ push(@unique, $_) unless ($seen{$_}++);
+}
+
+foreach (@unique)
+ {
+ $json .= $_;
+ }
+
$json .= "]";
close HOURLY;
close DAILY;
@@ -68,4 +82,4 @@
open (FILE, '>/var/www/attack_data.json');
print FILE $json;
-close (FILE);
+close (FILE);
Please sign in to comment.
Something went wrong with that request. Please try again.