[2.13.0] bus乘客端算路bug处理
This commit is contained in:
@@ -414,6 +414,8 @@ public class BusPassengerModel {
|
||||
int nextRouteIndex = CoordinateCalculateRouteUtil.getArrivedPointIndexNew(currentRouteIndex
|
||||
,mRoutePoints
|
||||
,stationNext.getGcjLon(),stationNext.getGcjLat());
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "currentRouteIndex = " + currentRouteIndex
|
||||
+ ", nextRouteIndex = " + nextRouteIndex);
|
||||
if (currentRouteIndex < nextRouteIndex){ //如果找到的next在起点的轨迹前面,直接舍弃这个轨迹,不显示
|
||||
mTwoStationsRouts.addAll(mRoutePoints.subList(currentRouteIndex,nextRouteIndex));
|
||||
}
|
||||
@@ -486,17 +488,17 @@ public class BusPassengerModel {
|
||||
}
|
||||
|
||||
public void loopRouteAndWipe() {
|
||||
if (mRoutePoints != null && mRoutePoints.size() > 0 && mLocation != null){
|
||||
if (mTwoStationsRouts != null && mTwoStationsRouts.size() > 0 && mLocation != null){
|
||||
int haveArrivedIndex = CoordinateCalculateRouteUtil
|
||||
.getArrivedPointIndexNew(mPreRouteIndex,
|
||||
mRoutePoints,
|
||||
mTwoStationsRouts,
|
||||
mLocation.getLongitude(),
|
||||
mLocation.getLatitude());
|
||||
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "thread = "+ Thread.currentThread().getName()+" haveArrivedIndex== " + haveArrivedIndex);
|
||||
if (mAutopilotPlanningCallback != null){
|
||||
List<LatLng> routePoints = CoordinateCalculateRouteUtil
|
||||
.coordinateConverterLocationToLatLng(mContext,mRoutePoints);
|
||||
.coordinateConverterLocationToLatLng(mContext,mTwoStationsRouts);
|
||||
mAutopilotPlanningCallback.routeResult(routePoints,haveArrivedIndex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,9 +56,8 @@ public class BusPassengerMapDirectionView
|
||||
|
||||
private int mCurrentIndex = -1;
|
||||
|
||||
private int zoomLevel = 13;
|
||||
private List<LatLng> mCoordinatesLatLng = new ArrayList<>(); //站点坐标数据
|
||||
private List<LatLng> mLinePointsLatLng = new ArrayList<>(); //轨迹坐标数据
|
||||
private List<LatLng> mCoordinatesLatLng = new ArrayList<>(); //轨迹坐标数据
|
||||
private List<LatLng> mLineStationLatLng = new ArrayList<>();//站点坐标数据
|
||||
private Polyline mPolyline;
|
||||
private CameraUpdate mCameraUpdate;
|
||||
private Context mContext;
|
||||
@@ -200,24 +199,23 @@ public class BusPassengerMapDirectionView
|
||||
//圈定地图显示范围
|
||||
LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder();
|
||||
|
||||
if (mLinePointsLatLng.size() > 0){
|
||||
if (mLineStationLatLng.size() > 0){
|
||||
//存放经纬度
|
||||
for (int i = 0; i < mLinePointsLatLng.size(); i++) {
|
||||
boundsBuilder.include(mLinePointsLatLng.get(i));
|
||||
for (int i = 0; i < mLineStationLatLng.size(); i++) {
|
||||
boundsBuilder.include(mLineStationLatLng.get(i));
|
||||
}
|
||||
boundsBuilder.include(currentLatLng);
|
||||
//第二个参数为四周留空宽度
|
||||
mAMap.moveCamera(CameraUpdateFactory.newLatLngBoundsRect(boundsBuilder.build(),100,100,100,100));
|
||||
|
||||
} else {
|
||||
boundsBuilder.include(currentLatLng);
|
||||
}
|
||||
// else {
|
||||
//第二个参数为四周留空宽度
|
||||
mAMap.moveCamera(CameraUpdateFactory.newLatLngBoundsRect(boundsBuilder.build(),100,100,100,100));
|
||||
//设置希望展示的地图缩放级别
|
||||
// CameraPosition cameraPosition = new CameraPosition.Builder()
|
||||
// .target(mCarMarker.getPosition()).tilt(0).bearing(location.getBearing()).zoom(zoomLevel).build();
|
||||
// mAMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
|
||||
}
|
||||
// }
|
||||
boundsBuilder.include(currentLatLng);
|
||||
mAMap.moveCamera(CameraUpdateFactory.newLatLngBoundsRect(boundsBuilder.build(),100,100,100,100));
|
||||
}
|
||||
|
||||
|
||||
@@ -230,9 +228,9 @@ public class BusPassengerMapDirectionView
|
||||
if (mAMap != null) {
|
||||
|
||||
addRouteColorList();
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "mLinePointsLatLng.size() = " +mLinePointsLatLng.size());
|
||||
if (mLinePointsLatLng.size() >= 2 && mCoordinatesLatLng.size() > 2) {
|
||||
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "mLinePointsLatLng.size() = " +mLineStationLatLng.size()
|
||||
+" mCoordinatesLatLng.size()= " + mCoordinatesLatLng.size());
|
||||
if (mLineStationLatLng.size() >= 2 && mCoordinatesLatLng.size() > 2) {
|
||||
//设置线段纹理
|
||||
PolylineOptions polylineOptions = new PolylineOptions();
|
||||
polylineOptions.addAll(mCoordinatesLatLng);
|
||||
@@ -305,7 +303,7 @@ public class BusPassengerMapDirectionView
|
||||
textureList.clear();
|
||||
texIndexList.clear();
|
||||
mCoordinatesLatLng.clear();
|
||||
mLinePointsLatLng.clear();
|
||||
mLineStationLatLng.clear();
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, " mCoordinatesLatLng.clear " );
|
||||
}
|
||||
|
||||
@@ -353,16 +351,16 @@ public class BusPassengerMapDirectionView
|
||||
mLineMarkers.clear();
|
||||
}
|
||||
|
||||
public void setLineMarkersAndDraw(List<LatLng> lineineLatLngs){
|
||||
public void setLineMarkersAndDraw(List<LatLng> stationLatLngs){
|
||||
clearLineMarkers();
|
||||
for (int i = 0; i < lineineLatLngs.size(); i++) {
|
||||
for (int i = 0; i < stationLatLngs.size(); i++) {
|
||||
Marker mWayPointMarker = mAMap.addMarker(new MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_view_dir_way_point)));
|
||||
mLineMarkers.add(mWayPointMarker);
|
||||
}
|
||||
if (mCoordinatesLatLng.size() == 0) {
|
||||
for (int i = 0; i < mLineMarkers.size(); i++) {
|
||||
mLineMarkers.get(i).setPosition(lineineLatLngs.get(i));
|
||||
mLineMarkers.get(i).setPosition(stationLatLngs.get(i));
|
||||
mLineMarkers.get(i).setVisible(true);
|
||||
}
|
||||
mCurrentIndex = -1;
|
||||
@@ -370,15 +368,15 @@ public class BusPassengerMapDirectionView
|
||||
}
|
||||
|
||||
public void setLinePointMarkerAndDraw(List<LatLng> routeLineLatLngs, int currentIndex) {
|
||||
mLinePointsLatLng.clear();
|
||||
mLinePointsLatLng.addAll(routeLineLatLngs);
|
||||
mLineStationLatLng.clear();
|
||||
mLineStationLatLng.addAll(routeLineLatLngs);
|
||||
|
||||
if (mLinePointsLatLng.size() > 0 && mCurrentIndex != currentIndex) {
|
||||
if (mLineStationLatLng.size() > 0 && mCurrentIndex != currentIndex) {
|
||||
if (mAMap != null && mLineMarkers.size() > 0) {
|
||||
mCurrentIndex = currentIndex;
|
||||
for (int i = 0; i < mLineMarkers.size(); i++) {
|
||||
if (i != currentIndex && i + 1 != currentIndex) {
|
||||
mLineMarkers.get(i).setPosition(mLinePointsLatLng.get(i));
|
||||
mLineMarkers.get(i).setPosition(mLineStationLatLng.get(i));
|
||||
mLineMarkers.get(i).setVisible(true);
|
||||
} else {
|
||||
mLineMarkers.get(i).setVisible(false);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.mogo.och.bus.passenger.ui;
|
||||
|
||||
import android.location.Location;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.animation.Animation;
|
||||
@@ -47,7 +46,7 @@ public class BusPassengerRouteFragment extends
|
||||
|
||||
private BusPassengerTrafficLightView mTrafficLightView;
|
||||
private List<BusPassengerStation> mStationsList = new ArrayList<>();
|
||||
private List<LatLng> mLinePointsList = new ArrayList<>();
|
||||
private List<LatLng> mLineStationsList = new ArrayList<>();
|
||||
|
||||
private TextView mSpeedTv;
|
||||
private ConstraintLayout mNoLineInfoView;
|
||||
@@ -299,19 +298,19 @@ public class BusPassengerRouteFragment extends
|
||||
}
|
||||
|
||||
private void updateWayPointList(List<BusPassengerStation> stations,int currentStationIndex) {
|
||||
mLinePointsList.clear();
|
||||
mLineStationsList.clear();
|
||||
for (int i = 0; i< stations.size(); i++) {//站点集合
|
||||
LatLng latLng = CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(getContext()
|
||||
,stations.get(i).getLon(),stations.get(i).getLat());// lat,lon
|
||||
mLinePointsList.add(latLng);
|
||||
mLineStationsList.add(latLng);
|
||||
}
|
||||
setLineMarkers(mLinePointsList);
|
||||
setLineMarkers(mLineStationsList);
|
||||
|
||||
if (mMapDirectionView != null) {
|
||||
UiThreadHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mMapDirectionView.setLinePointMarkerAndDraw(mLinePointsList,currentStationIndex);
|
||||
mMapDirectionView.setLinePointMarkerAndDraw(mLineStationsList,currentStationIndex);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -245,7 +245,8 @@ public class CoordinateCalculateRouteUtil {
|
||||
for (int i= preIndex; i < mRoutePoints.size(); i++){
|
||||
MogoLocation latLng = mRoutePoints.get(i);
|
||||
//todo 先看index对应点的方向和realLocation方向是否一致, 方向角度不能过90度
|
||||
if (Math.abs(realLocation.getBearing() - latLng.getBearing()) <= 90){
|
||||
if (latLng.getBearing() == realLocation.getBearing() - latLng.getBearing() ||
|
||||
Math.abs(realLocation.getBearing() - latLng.getBearing()) <= 90){
|
||||
float diff = CoordinateUtils.calculateLineDistance(realLocation.getLongitude(),
|
||||
realLocation.getLatitude(),
|
||||
latLng.getLongitude(),latLng.getLatitude());
|
||||
|
||||
Reference in New Issue
Block a user