Commit bfde63a4 authored by yangshuxing's avatar yangshuxing

Merge remote-tracking branch 'origin/master'

parents af108c86 7c38ca7c
......@@ -4,18 +4,10 @@ package com.dlbridge.jadp.plugins.cmpt.utils.gps;
import java.util.List;
/**
* Gps坐标转换为百度坐标
* WGS84坐标系:即地球坐标系,国际上通用的坐标系。设备一般包含GPS芯片或者北斗芯片获取的经纬度为WGS84地理坐标系,谷歌地图采用的是WGS84地理坐标系(中国范围除外);
*
*/
public class Gps2Baidu {
public static Point gpsToBD(double gps_lat, double gps_lon) {
Point bdPoint = new Point();
Point marPoint = new Point();
EvilTransform.gpsToMars(gps_lat, gps_lon, marPoint);
EvilTransform.marsToBD(marPoint.getLat(), marPoint.getLon(), bdPoint);
return bdPoint;
}
public class GpsTransform {
/**
* 路标点转成百度坐标
*/
......@@ -40,17 +32,75 @@ public class Gps2Baidu {
return tracePointList;
}
/**
* 路标点转成火星坐标系
*/
public static List<PlaceMark> placeMarker2Mar(List<PlaceMark> placeMarkList) {
for (PlaceMark pm : placeMarkList) {
Point marPoint = gpsToMar(pm.getLatitude(), pm.getLongitude());
pm.setMarLat(marPoint.getLat());
pm.setMarLng(marPoint.getLon());
}
return placeMarkList;
}
/**
* 轨迹点转成火星坐标系
*/
public static List<TracePoint> tracePoint2Mar(List<TracePoint> tracePointList) {
for (TracePoint tp : tracePointList) {
Point marPoint = gpsToMar(tp.getLatitude(), tp.getLongitude());
tp.setMarLat(marPoint.getLat());
tp.setMarLng(marPoint.getLon());
}
return tracePointList;
}
/**
* 原始坐标系转为为百度坐标系
* @param gps_lat
* @param gps_lon
* @return
*/
public static Point gpsToBD(double gps_lat, double gps_lon) {
Point bdPoint = new Point();
Point marPoint = new Point();
EvilTransform.gpsToMars(gps_lat, gps_lon, marPoint);
EvilTransform.marsToBD(marPoint.getLat(), marPoint.getLon(), bdPoint);
return bdPoint;
}
/**
* 地球坐标系转为火星坐标系
* @param gps_lat
* @param gps_lon
* @return
*/
public static Point gpsToMar(double gps_lat,double gps_lon){
Point marPoint = new Point();
EvilTransform.gpsToMars(gps_lat, gps_lon, marPoint);
return marPoint;
}
/**
* 转化经纬度坐标的内部类
*/
static class EvilTransform {
static double pi = 3.14159265358979324;
// Krasovsky 1940
// a = 6378245.0, 1/f = 298.3
// b = a * (1 - f)
// ee = (a^2 - b^2) / a^2;
static double a = 6378245.0;
static double ee = 0.00669342162296594323;
// World Geodetic System ==> Mars Geodetic System
/**
* 地球坐标系转为火星坐标系
* World Geodetic System ==> Mars Geodetic System
* @param wgLat
* @param wgLon
* @param marPoint
*/
public static void gpsToMars(double wgLat, double wgLon, Point marPoint) {
if (outOfChina(wgLat, wgLon)) {
marPoint.setLat(wgLat);
......@@ -68,8 +118,13 @@ public class Gps2Baidu {
marPoint.setLat(wgLat + dLat);
marPoint.setLon(wgLon + dLon);
}
// Mars Geodetic System ==> baidu Geodetic System
/**
* 火星坐标系转为百度坐标系
* Mars Geodetic System ==> baidu Geodetic System
* @param mar_lat
* @param mar_lon
* @param bdpoint
*/
static void marsToBD(double mar_lat, double mar_lon, Point bdpoint) {
double x_pi = 3.14159265358979324 * 3000.0 / 180.0;
double x = mar_lon, y = mar_lat;
......@@ -78,7 +133,12 @@ public class Gps2Baidu {
bdpoint.setLon(z * Math.cos(theta) + 0.0065);
bdpoint.setLat(z * Math.sin(theta) + 0.006);
}
/**
* 判断是不是不在中国,不在中国直接设置,国内要做偏移算法
* @param lat
* @param lon
* @return
*/
static boolean outOfChina(double lat, double lon) {
if (lon < 72.004 || lon > 137.8347)
return true;
......@@ -86,7 +146,12 @@ public class Gps2Baidu {
return true;
return false;
}
/**
* 转化纬度的方法
* @param x
* @param y
* @return
*/
static double transformLat(double x, double y) {
double ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y
+ 0.2 * Math.sqrt(Math.abs(x));
......@@ -97,7 +162,12 @@ public class Gps2Baidu {
/ 30.0)) * 2.0 / 3.0;
return ret;
}
/**
* 转化经度的方法
* @param x
* @param y
* @return
*/
static double transformLon(double x, double y) {
double ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1
* Math.sqrt(Math.abs(x));
......@@ -108,7 +178,5 @@ public class Gps2Baidu {
* pi)) * 2.0 / 3.0;
return ret;
}
}
}
......@@ -78,10 +78,10 @@ public class GpxParserUtil {
place.setAltitude(Float.parseFloat(altitude));
route.getPlaceMark().add(place);
}
// 轨迹点转换百度坐标系
route.setTracePoint(Gps2Baidu.tracePoint2Baidu(route.getTracePoint()));
// 路标转百度坐标
route.setPlaceMark(Gps2Baidu.placeMarker2Baidu(route.getPlaceMark()));
// 轨迹点转换火星坐标系,本系统小程序使用的火星坐标系
route.setTracePoint(GpsTransform.tracePoint2Mar(route.getTracePoint()));
// 路标转化为火星坐标系,本系统小程序使用的火星坐标系
route.setPlaceMark(GpsTransform.placeMarker2Mar(route.getPlaceMark()));
} catch (Exception e) {
logger.info("parseGpx --" + e.getMessage());
}
......
......@@ -104,9 +104,9 @@ public class KmlParserUtil {
// 轨迹点转换百度坐标系
route.setTracePoint(Gps2Baidu.tracePoint2Baidu(route.getTracePoint()));
route.setTracePoint(GpsTransform.tracePoint2Baidu(route.getTracePoint()));
// 路标转百度坐标
route.setPlaceMark(Gps2Baidu.placeMarker2Baidu(route.getPlaceMark()));
route.setPlaceMark(GpsTransform.placeMarker2Baidu(route.getPlaceMark()));
} catch (Exception e) {
......
......@@ -22,6 +22,12 @@ public class PlaceMark {
// 百度坐标系纬度
private double baiduLng;
//火星坐标系的经度
private double marLat;
//火星坐标系的维度
private double marLng;
// 海拔
private double altitude;
......@@ -84,4 +90,19 @@ public class PlaceMark {
this.type = type;
}
public double getMarLat() {
return marLat;
}
public void setMarLat(double marLat) {
this.marLat = marLat;
}
public double getMarLng() {
return marLng;
}
public void setMarLng(double marLng) {
this.marLng = marLng;
}
}
......@@ -10,6 +10,11 @@ public class TracePoint {
private double baiduLat;
// 百度坐标系纬度
private double baiduLng;
// 火星坐标系经度
private double marLat;
// 火星坐标系纬度
private double marLng;
//海拔
private float altitude;
// 时间戳
......@@ -74,4 +79,19 @@ public class TracePoint {
this.altitude = altitude;
}
public double getMarLat() {
return marLat;
}
public void setMarLat(double marLat) {
this.marLat = marLat;
}
public double getMarLng() {
return marLng;
}
public void setMarLng(double marLng) {
this.marLng = marLng;
}
}
spring.profiles.active=dev
spring.profiles.active=test
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment