| | |
| | | package com.ruoyi.web.util; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.google.gson.JsonObject; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | public class MainApp { |
| | | public static void main(String[] args) { |
| | | double startLat = 39.9042; |
| | | double startLon = 116.4074; |
| | | double startLon = 118.4074; |
| | | double endLat = 39.9042; |
| | | double endLon = 116.4074; |
| | | double endLon = 119.4074; |
| | | |
| | | double userLat = 39.9042; |
| | | double userLon = 116.4074; |
| | |
| | | int segments = 4; // 四段,共 5 个点 |
| | | try { |
| | | String routeJson = AmapApiClient.getDrivingRoute(startLat, startLon, endLat, endLon); |
| | | // 转化为json对象 |
| | | JSONObject jsonObject = JSONObject.parseObject(routeJson); |
| | | JSONObject route = jsonObject.getJSONObject("route"); |
| | | JSONArray paths = route.getJSONArray("paths"); |
| | | JSONObject o = (JSONObject)paths.get(0); |
| | | BigDecimal distance = o.getBigDecimal("distance"); |
| | | System.err.println( paths); |
| | | |
| | | List<double[]> fivePoints = PathParser.parseAndInterpolate(routeJson, segments,startLat, startLon, endLat, endLon); |
| | | |
| | | if (GeoChecker.isInAnyCircle(userLat, userLon, fivePoints, radius)) { |