diff --git a/pom.xml b/pom.xml index e33d4d2..6f3a748 100644 --- a/pom.xml +++ b/pom.xml @@ -87,6 +87,12 @@ 1.18.22 provided + + + org.gavaghan + geodesy + 1.1.3 + org.springframework.boot diff --git a/src/main/java/com/peteralbus/controller/EstimateController.java b/src/main/java/com/peteralbus/controller/EstimateController.java index 7584416..bf659df 100644 --- a/src/main/java/com/peteralbus/controller/EstimateController.java +++ b/src/main/java/com/peteralbus/controller/EstimateController.java @@ -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 mapParameter = new HashMap(); + 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()