[Update]Map按照新架构重构
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
package com.mogo.map;
|
||||
|
||||
import com.zhidaoauto.map.sdk.open.query.LonLatPoint;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 道路数据缓存
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class RoadCacheWrapper {
|
||||
private List<LonLatPoint> road;
|
||||
private double lastDistanceDiff;
|
||||
private int roadLength = -1;
|
||||
|
||||
private float laneWidth = -1;
|
||||
|
||||
public RoadCacheWrapper(List<LonLatPoint> road) {
|
||||
setRoad(road);
|
||||
}
|
||||
|
||||
public List<LonLatPoint> getRoad() {
|
||||
return road;
|
||||
}
|
||||
|
||||
public void setRoad(List<LonLatPoint> road) {
|
||||
this.road = road;
|
||||
if(road!=null) {
|
||||
roadLength = road.size();
|
||||
}
|
||||
}
|
||||
|
||||
public double getLastDistanceDiff() {
|
||||
return lastDistanceDiff;
|
||||
}
|
||||
|
||||
public void setLastDistanceDiff(double lastDistanceDiff) {
|
||||
this.lastDistanceDiff = lastDistanceDiff;
|
||||
}
|
||||
|
||||
public double getLastLat(){
|
||||
if (roadLength != -1) {
|
||||
return road.get(roadLength - 1).getLatitude();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public double getLastLon(){
|
||||
if (roadLength != -1) {
|
||||
return road.get(roadLength - 1).getLongitude();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public float getLaneWidth() {
|
||||
return laneWidth;
|
||||
}
|
||||
|
||||
public void setLaneWidth(float laneWidth) {
|
||||
this.laneWidth = laneWidth;
|
||||
}
|
||||
|
||||
public boolean inCache(double lon, double lat) {
|
||||
if (roadLength > 0) {
|
||||
LonLatPoint start = road.get(0);
|
||||
LonLatPoint end = road.get(roadLength - 1);
|
||||
boolean latInRoad = false;
|
||||
boolean lonInRoad = false;
|
||||
if (start.getLatitude() > end.getLatitude()) {
|
||||
latInRoad = lat <= start.getLatitude() && lat >= end.getLatitude();
|
||||
}else{
|
||||
latInRoad = lat >= start.getLatitude() && lat <= end.getLatitude();
|
||||
}
|
||||
|
||||
if (start.getLongitude() > end.getLongitude()) {
|
||||
lonInRoad = lon <= start.getLongitude() && lon >= end.getLongitude();
|
||||
}else{
|
||||
lonInRoad = lon >= start.getLongitude() && lon <= end.getLongitude();
|
||||
}
|
||||
|
||||
return latInRoad && lonInRoad;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user