@@ -7,6 +7,8 @@ import 'package:dpip/utils/extensions/latlng.dart';
77import 'package:dpip/utils/extensions/iterable.dart' ;
88import 'package:maplibre_gl/maplibre_gl.dart' ;
99
10+ const double ln10 = 2.302585092994046 ; // Math.log(10)
11+
1012({double p, double s, double sT}) calcWaveRadius (
1113 double depth,
1214 int time,
@@ -55,6 +57,13 @@ import 'package:maplibre_gl/maplibre_gl.dart';
5557 prevTable = table;
5658 }
5759
60+ if (pDist < 0 ) {
61+ pDist = 0 ;
62+ }
63+ if (sDist < 0 ) {
64+ sDist = 0 ;
65+ }
66+
5867 return (p: pDist, s: sDist, sT: sT);
5968}
6069
@@ -75,7 +84,7 @@ Map<String, dynamic> eewAreaPga(
7584 double eewMaxI = 0.0 ;
7685
7786 region.forEach ((String key, Location info) {
78- final double distSurface = LatLng (lat, lon).to (LatLng (info.lat, info.lng));
87+ final double distSurface = LatLng (lat, lon).to (LatLng (info.lat, info.lng)) / 1000 ;
7988 final double dist = sqrt (pow (distSurface, 2 ) + pow (depth, 2 ));
8089 final double pga = 1.657 * exp (1.533 * mag) * pow (dist, - 1.607 );
8190 double i = pgaToFloat (pga);
@@ -99,9 +108,11 @@ double eewAreaPgv(
99108 double magW,
100109) {
101110 final double long = pow (10 , 0.5 * magW - 1.85 ).toDouble () / 2 ;
102- final double epicenterDistance = epicenterLocation.asLatLng.to (
103- pointLocation.asLatLng,
104- ) / 1000 ;
111+ final double epicenterDistance =
112+ epicenterLocation.asLatLng.to (
113+ pointLocation.asLatLng,
114+ ) /
115+ 1000 ;
105116 final double hypocenterDistance =
106117 sqrt (pow (depth, 2 ) + pow (epicenterDistance, 2 )) - long;
107118 final double x = max (hypocenterDistance, 3 );
@@ -271,7 +282,7 @@ WaveTime calculateWaveTime(double depth, double distance) {
271282 final dist = sqrt (pow (distSurface, 2 ) + pow (depth, 2 ));
272283 final pga = 1.657 * exp (1.533 * mag) * pow (dist, - 1.607 );
273284 var intensity = pgaToFloat (pga);
274- if (intensity > 4.5 ) {
285+ if (intensity >= 4.5 ) {
275286 intensity = eewAreaPgv ([eqLat, eqLng], [userLat, userLon], depth, mag);
276287 }
277288 return (dist: dist, i: intensity);
0 commit comments