Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ private Constants() {
public static final String PIPE = "|";
public static final String ESCAPE_PIPE = "\\|";
public static final String AMPERSAND = "&";
public static final String SEMICOLON = ";";

public static final String YMD_PATTERN = "yyyyMMdd";
public static final String HM_PATTERN = "HH_mm";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package com.chedaojunan.report.model;

import com.chedaojunan.report.utils.Pair;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.IOException;
import java.util.List;

/**
* 坐标转换请求参数实体类
*/

public class CoordinateConvertRequestParam {

public static final String KEY = "key";
public static final String LOCATIONS = "locations";
public static final String COORDSYS = "coordsys";

@NotNull
private String key; // 用户唯一标识

@NotNull
@Size(min = 1, max = 40)
private List<Pair<Double, Double>> locations; // 经纬度

@NotNull
private String coordsys; // 原坐标系

public CoordinateConvertRequestParam(String apiKey, List<Pair<Double, Double>> locations, String apiCoordsys) {
setKey(apiKey);
setLocations(locations);
setCoordsys(apiCoordsys);
}

public String getKey() {
return key;
}

public void setKey(String key) {
this.key = key;
}

public List<Pair<Double, Double>> getLocations() {
return locations;
}

public void setLocations(List<Pair<Double, Double>> locations) {
this.locations = locations;
}

public String getCoordsys() {
return coordsys;
}

public void setCoordsys(String coordsys) {
this.coordsys = coordsys;
}

@Override
public int hashCode() {
return new HashCodeBuilder()
.append(key)
.append(locations)
.append(coordsys).toHashCode();
}

@Override
public boolean equals(Object other) {
if (other == this) {
return true;
}
if ((other instanceof CoordinateConvertRequestParam) == false) {
return false;
}
CoordinateConvertRequestParam rhs = ((CoordinateConvertRequestParam) other);
return new EqualsBuilder()
.append(key, rhs.key)
.append(locations, rhs.locations)
.append(coordsys, rhs.coordsys).isEquals();
}

@Override
public String toString() {
ObjectMapper mapper = new ObjectMapper();
try {
return mapper.writeValueAsString(this);
} catch (IOException e) {
return null;
}
}
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.chedaojunan.report.model;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

import java.util.HashMap;
import java.util.Map;

public enum CoordsysParamEnum {
GPS("gps"),
MAPBAR("mapbar"),
BAIDU("baidu"),
AUTONAVI("autonavi"); // 不进行转换

private static Map<String, CoordsysParamEnum> constants = new HashMap<>();

static {
for (CoordsysParamEnum c : values()) {
constants.put(c.value, c);
}
}

private String value;

CoordsysParamEnum(String value) {
this.value = value;
}

@JsonCreator
public static CoordsysParamEnum fromValue(String value) {
CoordsysParamEnum constant = constants.get(value);
if (constant == null) {
throw new IllegalArgumentException(value);
} else {
return constant;
}
}

public static boolean isValid(String value) {
return constants.get(value) != null;
}

@JsonValue
@Override
public String toString() {
return this.value;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package com.chedaojunan.report.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.io.IOException;

public class DatahubDeviceData extends FixedFrequencyIntegrationData {

@JsonProperty("adCode")
private String adCode; // adcode
@JsonProperty("townCode")
private String townCode; //

public String getAdCode() {
return adCode;
}

public void setAdCode(String adCode) {
this.adCode = adCode;
}

public String getTownCode() {
return townCode;
}

public void setTownCode(String townCode) {
this.townCode = townCode;
}

public DatahubDeviceData(){}

public DatahubDeviceData(FixedFrequencyIntegrationData fixedFrequency, String adCode, String townCode) {
setDeviceId(fixedFrequency.getDeviceId());
setDeviceImei(fixedFrequency.getDeviceImei());
setLocalTime(fixedFrequency.getLocalTime());
setServerTime(fixedFrequency.getServerTime());
setTripId(fixedFrequency.getTripId());
setLatitude(fixedFrequency.getLatitude());
setLongitude(fixedFrequency.getLongitude());
setAltitude(fixedFrequency.getAltitude());
setGpsSpeed(fixedFrequency.getGpsSpeed());
setDirection(fixedFrequency.getDirection());
setYawRate(fixedFrequency.getYawRate());
setAccelerateZ(fixedFrequency.getAccelerateZ());
setRollRate(fixedFrequency.getRollRate());
setAccelerateX(fixedFrequency.getAccelerateX());
setPitchRate(fixedFrequency.getPitchRate());
setAccelerateY(fixedFrequency.getAccelerateY());
setSourceId(fixedFrequency.getSourceId());

setCorrectedLatitude(fixedFrequency.getCorrectedLatitude());
setCorrectedLongitude(fixedFrequency.getCorrectedLongitude());

setRoadApiStatus(fixedFrequency.getRoadApiStatus());
setCrosspoint(fixedFrequency.getCrosspoint());
setRoadName(fixedFrequency.getRoadName());
setRoadLevel(fixedFrequency.getRoadLevel());
setMaxSpeed(fixedFrequency.getMaxSpeed());
setIntersection(fixedFrequency.getIntersection());
setIntersectionDistance(fixedFrequency.getIntersectionDistance());
setTrafficRequestTimesamp(fixedFrequency.getTrafficRequestTimesamp());
setTrafficRequestId(fixedFrequency.getTrafficRequestId());
setTrafficApiStatus(fixedFrequency.getTrafficApiStatus());
setCongestionInfo(fixedFrequency.getCongestionInfo());

setAdCode(adCode);
setTownCode(townCode);

}

@Override
public String toString() {
ObjectMapper mapper = new ObjectMapper();
try {
return mapper.writeValueAsString(this);
} catch (IOException e) {
return null;
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package com.chedaojunan.report.model;

public class FixedFrequencyAccessGpsData extends FixedFrequencyAccessData {

private double correctedLatitude ; // 修正后纬度
private double correctedLongitude ; // 修正后经度

public FixedFrequencyAccessGpsData(){}

public FixedFrequencyAccessGpsData(FixedFrequencyAccessData accessData, double correctedLatitude, double correctedLongitude) {
setDeviceId(accessData.getDeviceId());
setDeviceImei(accessData.getDeviceImei());
setLocalTime(accessData.getLocalTime());
setServerTime(accessData.getServerTime());
setTripId(accessData.getTripId());
setLatitude(accessData.getLatitude());
setLongitude(accessData.getLongitude());
setAltitude(accessData.getAltitude());
setGpsSpeed(accessData.getGpsSpeed());
setDirection(accessData.getDirection());
setYawRate(accessData.getYawRate());
setAccelerateZ(accessData.getAccelerateZ());
setRollRate(accessData.getRollRate());
setAccelerateX(accessData.getAccelerateX());
setPitchRate(accessData.getPitchRate());
setAccelerateY(accessData.getAccelerateY());
setSourceId(accessData.getSourceId());

setCorrectedLatitude(correctedLatitude);
setCorrectedLongitude(correctedLongitude);

}

public FixedFrequencyAccessGpsData(FixedFrequencyAccessData accessData) {
setDeviceId(accessData.getDeviceId());
setDeviceImei(accessData.getDeviceImei());
setLocalTime(accessData.getLocalTime());
setServerTime(accessData.getServerTime());
setTripId(accessData.getTripId());
setLatitude(accessData.getLatitude());
setLongitude(accessData.getLongitude());
setAltitude(accessData.getAltitude());
setGpsSpeed(accessData.getGpsSpeed());
setDirection(accessData.getDirection());
setYawRate(accessData.getYawRate());
setAccelerateZ(accessData.getAccelerateZ());
setRollRate(accessData.getRollRate());
setAccelerateX(accessData.getAccelerateX());
setPitchRate(accessData.getPitchRate());
setAccelerateY(accessData.getAccelerateY());
setSourceId(accessData.getSourceId());
}

public double getCorrectedLatitude() {
return correctedLatitude;
}

public void setCorrectedLatitude(double correctedLatitude) {
this.correctedLatitude = correctedLatitude;
}

public double getCorrectedLongitude() {
return correctedLongitude;
}

public void setCorrectedLongitude(double correctedLongitude) {
this.correctedLongitude = correctedLongitude;
}

}
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package com.chedaojunan.report.model;

import java.io.IOException;
import java.util.regex.Pattern;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;

public class FixedFrequencyIntegrationData extends FixedFrequencyAccessData {
public class FixedFrequencyIntegrationData extends FixedFrequencyAccessGpsData {

@JsonProperty(value = "road_api_status")
private int roadApiStatus ; // 抓路接口返回结果状态:0表示请求失败;1表示请求成功',
Expand Down Expand Up @@ -41,9 +39,7 @@ public class FixedFrequencyIntegrationData extends FixedFrequencyAccessData {
@JsonProperty(value = "congestion_info")
private String congestionInfo ; // 交通态势,以json串的方式存储',

public FixedFrequencyIntegrationData(){}

public FixedFrequencyIntegrationData(FixedFrequencyAccessData accessData, GaoDeFusionReturn gaoDeFusionReturn) {
public FixedFrequencyIntegrationData(FixedFrequencyAccessGpsData accessData, GaoDeFusionReturn gaoDeFusionReturn) {
setDeviceId(accessData.getDeviceId());
setDeviceImei(accessData.getDeviceImei());
setLocalTime(accessData.getLocalTime());
Expand All @@ -62,6 +58,9 @@ public FixedFrequencyIntegrationData(FixedFrequencyAccessData accessData, GaoDeF
setAccelerateY(accessData.getAccelerateY());
setSourceId(accessData.getSourceId());

setCorrectedLatitude(accessData.getCorrectedLatitude());
setCorrectedLongitude(accessData.getCorrectedLongitude());

setRoadApiStatus(gaoDeFusionReturn.getRoad_api_status());
setCrosspoint(gaoDeFusionReturn.getCrosspoint());
setRoadName(gaoDeFusionReturn.getRoadname());
Expand All @@ -75,7 +74,7 @@ public FixedFrequencyIntegrationData(FixedFrequencyAccessData accessData, GaoDeF
setCongestionInfo(gaoDeFusionReturn.getCongestion_info());
}

public FixedFrequencyIntegrationData(FixedFrequencyAccessData accessData) {
public FixedFrequencyIntegrationData(FixedFrequencyAccessGpsData accessData) {
setDeviceId(accessData.getDeviceId());
setDeviceImei(accessData.getDeviceImei());
setLocalTime(accessData.getLocalTime());
Expand All @@ -93,6 +92,13 @@ public FixedFrequencyIntegrationData(FixedFrequencyAccessData accessData) {
setPitchRate(accessData.getPitchRate());
setAccelerateY(accessData.getAccelerateY());
setSourceId(accessData.getSourceId());

setCorrectedLatitude(accessData.getCorrectedLatitude());
setCorrectedLongitude(accessData.getCorrectedLongitude());

}

public FixedFrequencyIntegrationData() {
}

public int getRoadApiStatus() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.chedaojunan.report.utils;

import com.chedaojunan.report.common.Constants;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;

import java.util.List;
import java.util.stream.Collectors;

public class PrepareCoordinateConvertRequest {

public static String convertLocationsToRequestString(List<Pair<Double, Double>> locations) {
if(CollectionUtils.isNotEmpty(locations))
return StringUtils.join(locations.stream().map(Pair::toString).collect(Collectors.toList()), Constants.PIPE);
else
return null;
}
}
Loading