1 files added
9 files modified
| | |
| | | if (!params.containsKey("mac") || !params.containsKey("time1")|| !params.containsKey("time2")) { |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | } |
| | | List<CruiserDTO> data = historySecondCruiserService.getCruiserInFo(params); |
| | | Map<String, Object> cruiserInFo = historySecondCruiserService.getCruiserInFo(params); |
| | | |
| | | return ObjectUtils.isEmpty(data)? ResultMessage.ok() : ResultMessage.ok(data); |
| | | return ObjectUtils.isEmpty(cruiserInFo)? ResultMessage.ok() : ResultMessage.ok(cruiserInFo); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.Map; |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.moral.api.entity.ManageCoordinateDetail; |
| | |
| | | * @return |
| | | */ |
| | | @PostMapping("batch") |
| | | public ResultMessage getInserts(){ |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"), |
| | | @ApiImplicitParam(name = "coordinateId", value = "路段id", required = true, paramType = "query", dataType = "String"), |
| | | @ApiImplicitParam(name = "time1", value = "时间,2021-08-18", required = true, paramType = "query", dataType = "String"), |
| | | @ApiImplicitParam(name = "time2", value = "时间,2021-08-18", required = true, paramType = "query", dataType = "String") |
| | | }) |
| | | public ResultMessage getInserts(@RequestBody Map<String,Object> params){ |
| | | if (!params.containsKey("coordinateId") || !params.containsKey("time1")|| !params.containsKey("time2")) { |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | } |
| | | |
| | | |
| | | return null; |
| | | } |
| | | |
| | |
| | | * @return |
| | | */ |
| | | @GetMapping("select") |
| | | public ResultMessage selectAll(){ |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"), |
| | | @ApiImplicitParam(name = "coordinateId", value = "路段id", required = true, paramType = "query", dataType = "String"), |
| | | @ApiImplicitParam(name = "time1", value = "时间,2021-08-18", required = true, paramType = "query", dataType = "String"), |
| | | @ApiImplicitParam(name = "time2", value = "时间,2021-08-18", required = true, paramType = "query", dataType = "String") |
| | | }) |
| | | public ResultMessage selectAll(@RequestBody Map<String,Object> params){ |
| | | if (!params.containsKey("coordinateId") || !params.containsKey("time1")|| !params.containsKey("time2")) { |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | } |
| | | Map<String, Object> map = manageCoordinateDetailService.selectCoordinate(params); |
| | | return null; |
| | | } |
| | | } |
| | |
| | | import com.moral.api.entity.Test; |
| | | import com.moral.api.entity.UnitConversion; |
| | | import com.moral.api.mapper.SysDictDataMapper; |
| | | import com.moral.api.pojo.dto.account.AccountDTO; |
| | | import com.moral.api.pojo.dto.accountRole.AccountRoleDTO; |
| | | import com.moral.api.pojo.dto.adjust.AdjustDTO; |
| | | import com.moral.api.service.DeviceService; |
| | | import com.moral.api.service.SensorService; |
| | | import com.moral.api.service.SysDictDataService; |
| | | import com.moral.api.service.TestService; |
| | |
| | | @Autowired |
| | | SysDictDataMapper sysDictDataMapper; |
| | | |
| | | @Autowired |
| | | private DeviceService deviceService; |
| | | |
| | | @ApiOperation(value = "因子测试", notes = "因子测试") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String") |
| | | }) |
| | | @RequestMapping(value = "getSensor", method = RequestMethod.GET) |
| | | public void getSensor() { |
| | | QueryWrapper<Sensor> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.select("code").eq("is_delete", Constants.NOT_DELETE); |
| | | List<Object> list = sensorService.listObjs(queryWrapper); |
| | | for (Object o : list) { |
| | | System.out.println(o); |
| | | } |
| | | HashMap<String, Object> deviceData = new HashMap<>(); |
| | | deviceData.put("time","1691996716839"); |
| | | deviceData.put("DataTime","20230814150000"); |
| | | deviceData.put("mac","p5dnd7a0245362"); |
| | | deviceData.put("a00e12","11479.2"); |
| | | deviceData.put("a00e13","44.0"); |
| | | deviceData.put("a21005","0.0264"); |
| | | deviceData.put("a21004","20.0"); |
| | | deviceData.put("a21026","30.5"); |
| | | deviceData.put("a01001","38.1"); |
| | | deviceData.put("a05024","279.6"); |
| | | deviceData.put("a01002","54.2"); |
| | | deviceData.put("a01007","2.45"); |
| | | deviceData.put("a01006","805.834"); |
| | | deviceData.put("a01008","102.0"); |
| | | deviceData.put("a34002","4.9"); |
| | | deviceData.put("a34004","4.9"); |
| | | deviceData.put("a00e03","798.5"); |
| | | deviceData.put("a00e04","2.9"); |
| | | deviceData.put("a99054","0.0348"); |
| | | deviceData.put("a31001","0.1"); |
| | | Map<String, Object> map = deviceService.adjustDeviceData(deviceData, "2"); |
| | | // QueryWrapper<Sensor> queryWrapper = new QueryWrapper<>(); |
| | | // queryWrapper.select("code").eq("is_delete", Constants.NOT_DELETE); |
| | | // List<Object> list = sensorService.listObjs(queryWrapper); |
| | | // for (Object o : list) { |
| | | // System.out.println(o); |
| | | // } |
| | | } |
| | | |
| | | } |
| | |
| | | import java.util.Date; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.extension.activerecord.Model; |
| | | |
| | |
| | | private String updayeUserName; |
| | | |
| | | |
| | | @TableField(exist = false) |
| | | private String code; |
| | | |
| | | |
| | | } |
| | |
| | | private Double flyLon; |
| | | |
| | | |
| | | private String data; |
| | | |
| | | |
| | | |
| | | @Override |
| | | public boolean equals(Object o) { |
| | |
| | | List<SpecialDevice> selectCruisers(); |
| | | |
| | | //查询走航车轨迹 |
| | | List<CruiserDTO> getCruiserInFo(Map<String, Object> params); |
| | | Map<String,Object> getCruiserInFo(Map<String, Object> params); |
| | | } |
| | |
| | | package com.moral.api.service; |
| | | |
| | | import java.util.Map; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.moral.api.entity.ManageCoordinateDetail; |
| | | |
| | |
| | | |
| | | |
| | | void deleteCoordinate(Integer id); |
| | | |
| | | |
| | | |
| | | Map<String,Object> selectCoordinate(Map<String,Object> params); |
| | | |
| | | |
| | | Integer batchAll(Map<String,Object> params); |
| | | |
| | | } |
| | |
| | | import com.moral.api.service.HistorySecondCruiserService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.api.service.SpecialDeviceService; |
| | | import com.moral.api.util.RoadUtils; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.RedisConstants; |
| | | import com.moral.util.DateUtils; |
| | |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import java.sql.Wrapper; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public List<SpecialDevice> selectCruisers() { |
| | | QueryWrapper<SpecialDevice> wrapper = new QueryWrapper<>(); |
| | | wrapper.select("name","mac"); |
| | | wrapper.eq("is_delete",Constants.NOT_DELETE); |
| | | List<SpecialDevice> specialDevices = specialDeviceMapper.selectList(wrapper); |
| | | return specialDevices; |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<CruiserDTO> getCruiserInFo(Map<String, Object> params) { |
| | | public Map<String,Object> getCruiserInFo(Map<String, Object> params) { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | params.put("dateFormat", "%Y-%m-%d %H:%i:%s"); |
| | | List<CruiserDTO> data = historySecondCruiserMapper.getCruiserInfo(params); |
| | | List<CruiserDTO> rsCruiser = data.stream().distinct().collect(Collectors.toList()); |
| | |
| | | } |
| | | double lon = o.getFlyLon(); |
| | | double lat = o.getFlyLat(); |
| | | double[] doubles = RoadUtils.transformWGS84ToBD09(lon, lat); |
| | | Matcher matcher = Pattern.compile("\\d*\\.\\d{8}").matcher(""+doubles[0]); |
| | | matcher.find(); |
| | | String s = matcher.group(); |
| | | Matcher matcher1 = Pattern.compile("\\d*\\.\\d{8}").matcher(""+doubles[1]); |
| | | matcher1.find(); |
| | | String s1 = matcher1.group(); |
| | | o.setFlyLon(Double.parseDouble(s)); |
| | | o.setFlyLat(Double.parseDouble(s1)); |
| | | o.setData(lon+"_"+lat); |
| | | // o.setFlyLon(doubles[0]); |
| | | // o.setFlyLat(doubles[1]); |
| | | if (lon < 70 || lon > 150 || lat < 20 || lat > 60) { |
| | | return true; |
| | | } |
| | |
| | | if(CollectionUtils.isEmpty(data)){ |
| | | return null; |
| | | } |
| | | map.put("rsData",rsCruiser); |
| | | log.info(data.size()+""); |
| | | log.info(rsCruiser.size()+""); |
| | | return rsCruiser; |
| | | return map; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | package com.moral.api.service.impl; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.api.entity.ManageCoordinateDetail; |
| | | import com.moral.api.mapper.HistorySecondCruiserMapper; |
| | | import com.moral.api.mapper.ManageCoordinateDetailMapper; |
| | | import com.moral.api.pojo.dto.cruiser.CruiserDTO; |
| | | import com.moral.api.service.ManageCoordinateDetailService; |
| | | import com.moral.api.util.RoadUtils; |
| | | |
| | | |
| | | @Service |
| | | @Slf4j |
| | | public class ManageCoordinateDetailServiceImpl extends ServiceImpl<ManageCoordinateDetailMapper, ManageCoordinateDetail> implements ManageCoordinateDetailService { |
| | | |
| | | |
| | | @Autowired |
| | | private ManageCoordinateDetailMapper manageCoordinateDetailMapper; |
| | | |
| | | @Autowired |
| | | private HistorySecondCruiserMapper historySecondCruiserMapper; |
| | | /** |
| | | * 新增经纬度 |
| | | * @param manageCoordinateDetail |
| | |
| | | */ |
| | | @Override |
| | | public Integer insertCoordinate(ManageCoordinateDetail manageCoordinateDetail) { |
| | | double[] doubles = RoadUtils.transformBD09ToWGS84(manageCoordinateDetail.getLongitude(), manageCoordinateDetail.getLatitude()); |
| | | log.info(doubles[0]+"_"+doubles[1]); |
| | | QueryWrapper<ManageCoordinateDetail> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("coordinate_id",manageCoordinateDetail.getCoordinateId()); |
| | | queryWrapper.eq("longitude",manageCoordinateDetail.getLongitude()); |
| | | queryWrapper.eq("latitude",manageCoordinateDetail.getLatitude()); |
| | | queryWrapper.eq("longitude",doubles[0]); |
| | | queryWrapper.eq("latitude",doubles[1]); |
| | | Integer integer = manageCoordinateDetailMapper.selectCount(queryWrapper); |
| | | if (integer<1){ |
| | | manageCoordinateDetail.setCreateTime(new Date()); |
| | | manageCoordinateDetail.setUpdateTime(new Date()); |
| | | manageCoordinateDetail.setLongitude(doubles[0]); |
| | | manageCoordinateDetail.setLatitude(doubles[1]); |
| | | int insert = manageCoordinateDetailMapper.insert(manageCoordinateDetail); |
| | | return insert; |
| | | } |
| | |
| | | public void deleteCoordinate(Integer id) { |
| | | manageCoordinateDetailMapper.deleteById(id); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询坐标点 |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Map<String, Object> selectCoordinate(Map<String, Object> params) { |
| | | params.put("dateFormat", "%Y-%m-%d %H:%i:%s"); |
| | | String coordinateId = params.get("coordinateId").toString(); |
| | | QueryWrapper<ManageCoordinateDetail> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("coordinate_id",coordinateId); |
| | | List<ManageCoordinateDetail> manageCoordinateDetails = manageCoordinateDetailMapper.selectList(queryWrapper); |
| | | ArrayList<String> list1 = new ArrayList<>(); |
| | | ArrayList<String> list2 = new ArrayList<>(); |
| | | for (ManageCoordinateDetail manageCoordinateDetail : manageCoordinateDetails) { |
| | | Double latitude = manageCoordinateDetail.getLatitude(); |
| | | Double longitude = manageCoordinateDetail.getLongitude(); |
| | | String s = longitude + "_" + latitude; |
| | | list1.add(s); |
| | | } |
| | | List<CruiserDTO> cruiserInfo = historySecondCruiserMapper.getCruiserInfo(params); |
| | | for (CruiserDTO cruiserDTO : cruiserInfo) { |
| | | String s = cruiserDTO.getFlyLat().toString(); |
| | | String s1 = cruiserDTO.getFlyLon().toString(); |
| | | String rs = s1 + "_" + s; |
| | | list2.add(rs); |
| | | } |
| | | //取交集 |
| | | list1.retainAll(list2); |
| | | //取差集 |
| | | list2.removeAll(list1); |
| | | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 批量添加 |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public Integer batchAll(Map<String, Object> params) { |
| | | params.put("dateFormat", "%Y-%m-%d %H:%i:%s"); |
| | | String coordinateId = params.get("coordinateId").toString(); |
| | | QueryWrapper<ManageCoordinateDetail> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("coordinate_id",coordinateId); |
| | | List<ManageCoordinateDetail> manageCoordinateDetails = manageCoordinateDetailMapper.selectList(queryWrapper); |
| | | ArrayList<String> list1 = new ArrayList<>(); |
| | | ArrayList<String> list2 = new ArrayList<>(); |
| | | for (ManageCoordinateDetail manageCoordinateDetail : manageCoordinateDetails) { |
| | | Double latitude = manageCoordinateDetail.getLatitude(); |
| | | Double longitude = manageCoordinateDetail.getLongitude(); |
| | | String s = longitude + "_" + latitude; |
| | | list1.add(s); |
| | | } |
| | | List<CruiserDTO> cruiserInfo = historySecondCruiserMapper.getCruiserInfo(params); |
| | | for (CruiserDTO cruiserDTO : cruiserInfo) { |
| | | String s = cruiserDTO.getFlyLat().toString(); |
| | | String s1 = cruiserDTO.getFlyLon().toString(); |
| | | String rs = s1 + "_" + s; |
| | | list2.add(rs); |
| | | } |
| | | //取差集 |
| | | list2.removeAll(list1); |
| | | |
| | | return null; |
| | | } |
| | | } |
New file |
| | |
| | | package com.moral.api.util; |
| | | |
| | | |
| | | /** |
| | | * 经纬度转换 |
| | | */ |
| | | |
| | | public class RoadUtils { |
| | | |
| | | private static final double x_PI = 3.14159265358979324 * 3000.0 / 180.0; |
| | | private static final double PI = 3.1415926535897932384626; |
| | | private static final double a = 6378245.0; |
| | | private static final double ee = 0.00669342162296594323; |
| | | /** |
| | | * WGS84 坐标 转 GCJ02 |
| | | * |
| | | * @param lng 经度 |
| | | * @param lat 纬度 |
| | | * @return GCJ02 坐标:[经度,纬度] |
| | | */ |
| | | public static double[] transformWGS84ToGCJ02(double lng, double lat) { |
| | | if (outOfChina(lng, lat)) { |
| | | return new double[]{lng, lat}; |
| | | } else { |
| | | double dLat = transformLat(lng - 105.0, lat - 35.0); |
| | | double dLng = transformLng(lng - 105.0, lat - 35.0); |
| | | double redLat = lat / 180.0 * PI; |
| | | double magic = Math.sin(redLat); |
| | | magic = 1 - ee * magic * magic; |
| | | double sqrtMagic = Math.sqrt(magic); |
| | | dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * PI); |
| | | dLng = (dLng * 180.0) / (a / sqrtMagic * Math.cos(redLat) * PI); |
| | | double mgLat = lat + dLat; |
| | | double mgLng = lng + dLng; |
| | | return new double[]{mgLng, mgLat}; |
| | | } |
| | | } |
| | | |
| | | private static double transformLat(double lng, double lat) { |
| | | double ret = -100.0 + 2.0 * lng + 3.0 * lat + 0.2 * lat * lat + 0.1 * lng * lat + 0.2 * Math.sqrt(Math.abs(lng)); |
| | | ret += (20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) * 2.0 / 3.0; |
| | | ret += (20.0 * Math.sin(lat * PI) + 40.0 * Math.sin(lat / 3.0 * PI)) * 2.0 / 3.0; |
| | | ret += (160.0 * Math.sin(lat / 12.0 * PI) + 320 * Math.sin(lat * PI / 30.0)) * 2.0 / 3.0; |
| | | return ret; |
| | | } |
| | | |
| | | private static double transformLng(double lng, double lat) { |
| | | double ret = 300.0 + lng + 2.0 * lat + 0.1 * lng * lng + 0.1 * lng * lat + 0.1 * Math.sqrt(Math.abs(lng)); |
| | | ret += (20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) * 2.0 / 3.0; |
| | | ret += (20.0 * Math.sin(lng * PI) + 40.0 * Math.sin(lng / 3.0 * PI)) * 2.0 / 3.0; |
| | | ret += (150.0 * Math.sin(lng / 12.0 * PI) + 300.0 * Math.sin(lng / 30.0 * PI)) * 2.0 / 3.0; |
| | | return ret; |
| | | } |
| | | /** |
| | | * 判断坐标是否不在国内 |
| | | * |
| | | * @param lng 经度 |
| | | * @param lat 纬度 |
| | | * @return 坐标是否在国内 |
| | | */ |
| | | public static boolean outOfChina(double lng, double lat) { |
| | | return (lng < 72.004 || lng > 137.8347) || (lat < 0.8293 || lat > 55.8271); |
| | | } |
| | | |
| | | /** |
| | | * GCJ02 转百度坐标 |
| | | * |
| | | * @param lng GCJ02 经度 |
| | | * @param lat GCJ02 纬度 |
| | | * @return 百度坐标:[经度,纬度] |
| | | */ |
| | | public static double[] transformGCJ02ToBD09(double lng, double lat) { |
| | | double z = Math.sqrt(lng * lng + lat * lat) + 0.00002 * Math.sin(lat * x_PI); |
| | | double theta = Math.atan2(lat, lng) + 0.000003 * Math.cos(lng * x_PI); |
| | | double bd_lng = z * Math.cos(theta) + 0.0065; |
| | | double bd_lat = z * Math.sin(theta) + 0.006; |
| | | return new double[]{bd_lng, bd_lat}; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * WGS84 转 百度坐标BD09 |
| | | * |
| | | * @param lng 经度 |
| | | * @param lat 纬度 |
| | | * @return BD09 坐标:[经度,纬度] |
| | | */ |
| | | public static double[] transformWGS84ToBD09(double lng, double lat) { |
| | | double[] lngLat = transformWGS84ToGCJ02(lng, lat); |
| | | |
| | | return transformGCJ02ToBD09(lngLat[0], lngLat[1]); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 百度坐标(BD09)转 GCJ02 |
| | | * |
| | | * @param lng 百度经度 |
| | | * @param lat 百度纬度 |
| | | * @return GCJ02 坐标:[经度,纬度] |
| | | */ |
| | | public static double[] transformBD09ToGCJ02(double lng, double lat) { |
| | | double x = lng - 0.0065; |
| | | double y = lat - 0.006; |
| | | double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_PI); |
| | | double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_PI); |
| | | double gcj_lng = z * Math.cos(theta); |
| | | double gcj_lat = z * Math.sin(theta); |
| | | return new double[]{gcj_lng, gcj_lat}; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 百度坐标BD09 转 WGS84 |
| | | * |
| | | * @param lng 经度 |
| | | * @param lat 纬度 |
| | | * @return WGS84 坐标:[经度,纬度] |
| | | */ |
| | | public static double[] transformBD09ToWGS84(double lng, double lat) { |
| | | double[] lngLat = transformBD09ToGCJ02(lng, lat); |
| | | |
| | | return transformGCJ02ToWGS84(lngLat[0], lngLat[1]); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * GCJ02 转 WGS84 |
| | | * |
| | | * @param lng 经度 |
| | | * @param lat 纬度 |
| | | * @return WGS84坐标:[经度,纬度] |
| | | */ |
| | | public static double[] transformGCJ02ToWGS84(double lng, double lat) { |
| | | if (outOfChina(lng, lat)) { |
| | | return new double[]{lng, lat}; |
| | | } else { |
| | | double dLat = transformLat(lng - 105.0, lat - 35.0); |
| | | double dLng = transformLng(lng - 105.0, lat - 35.0); |
| | | double radLat = lat / 180.0 * PI; |
| | | double magic = Math.sin(radLat); |
| | | magic = 1 - ee * magic * magic; |
| | | double sqrtMagic = Math.sqrt(magic); |
| | | dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * PI); |
| | | dLng = (dLng * 180.0) / (a / sqrtMagic * Math.cos(radLat) * PI); |
| | | double mgLat = lat + dLat; |
| | | double mgLng = lng + dLng; |
| | | return new double[]{lng * 2 - mgLng, lat * 2 - mgLat}; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |