add a api that provides a point's intensity of an earthquake

main
PeterAlbus 3 years ago
parent 2b6951e386
commit e171e177ca

@ -87,6 +87,12 @@
<version>1.18.22</version>
<scope>provided</scope>
</dependency>
<!--geo-->
<dependency>
<groupId>org.gavaghan</groupId>
<artifactId>geodesy</artifactId>
<version>1.1.3</version>
</dependency>
<!--test-->
<dependency>
<groupId>org.springframework.boot</groupId>

@ -5,6 +5,10 @@ import com.peteralbus.entity.EarthquakeInfo;
import com.peteralbus.service.EstimateService;
import com.peteralbus.service.EarthquakeInfoService;
import com.peteralbus.util.EstimateUtil;
import org.gavaghan.geodesy.Ellipsoid;
import org.gavaghan.geodesy.GeodeticCalculator;
import org.gavaghan.geodesy.GeodeticCurve;
import org.gavaghan.geodesy.GlobalCoordinates;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
@ -14,10 +18,12 @@ import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* The type Estimate controller.
*
* @author PeterAlbus
*/
@CrossOrigin
@ -77,7 +83,7 @@ public class EstimateController {
* @return the estimate result
*/
@GetMapping("/getAnalyzeResult")
public Estimate getPredictResult(long earthquakeId){
public Estimate getPredictResult(Long earthquakeId){
System.out.println(earthquakeId);
int count = estimateService.queryAnalyze(earthquakeId);
Estimate estimate = new Estimate();
@ -115,4 +121,35 @@ public class EstimateController {
}
return estimate;
}
/**
* Gets Point intensity.
*
* @param earthquakeId the earthquake id
* @param longitude the longitude
* @param latitude the latitude
* @return the intensity
*/
@GetMapping("/getPointIntensity")
public Double getPointIntensity(Long earthquakeId,Double longitude,Double latitude)
{
Double intensity= (double) 0;
Map<String, Object> mapParameter = new HashMap<String, Object>();
mapParameter.put("earthquakeId",earthquakeId);
EarthquakeInfo earthquakeInfo = earthquakeInfoService.queryInfoWithLine(mapParameter).get(0);
GlobalCoordinates source = new GlobalCoordinates(latitude, longitude);
GlobalCoordinates target = new GlobalCoordinates(earthquakeInfo.getLatitude(), earthquakeInfo.getLongitude());
GeodeticCurve geoCurve = new GeodeticCalculator().calculateGeodeticCurve(Ellipsoid.WGS84, source, target);
Double meter = geoCurve.getEllipsoidalDistance();
Double dividingLine=105.1;
if(earthquakeInfo.getLongitude()<dividingLine)
{
intensity=earthquakeInfo.getIntensityByDistance(5.253,1.398,4.164,26,0,2.019,1.398,2.943,8,0,meter);
}
else
{
intensity=earthquakeInfo.getIntensityByDistance(5.019,1.446,4.136,24,0,2.240,1.446,3.070,9,0,meter);
}
return intensity;
}
}

@ -78,6 +78,28 @@ public class EarthquakeInfo implements Serializable
}
}
/**
* Gets intensity by distance.
*
* @param x1 the x 1
* @param y1 the y 1
* @param z1 the z 1
* @param b1 the b 1
* @param e1 the e 1
* @param x2 the x 2
* @param y2 the y 2
* @param z2 the z 2
* @param b2 the b 2
* @param e2 the e 2
* @param meter the meter
* @return the intensity by distance
*/
public Double getIntensityByDistance(double x1,double y1,double z1,double b1,double e1,double x2,double y2,double z2,double b2,double e2,Double meter)
{
double kilometer=meter/1000;
return x1+y1*magnitude-z1*Math.log10(kilometer+b1)+e1;
}
/**
* Gets intensity , use ln.
*

Loading…
Cancel
Save