Java Code Examples for com.baidu.location.LocationClient#getBDLocationInCoorType()

The following examples show how to use com.baidu.location.LocationClient#getBDLocationInCoorType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocationAccessAdapter.java    From AssistantBySDK with Apache License 2.0 5 votes vote down vote up
public void setAddress(Address address) {
    if (address != null) {
        mAddress = address.clone();
        BDLocation bdLocation = new BDLocation();
        bdLocation.setLatitude(mAddress.getLatitude());
        bdLocation.setLongitude(mAddress.getLongitude());
        bdLocation = LocationClient.getBDLocationInCoorType(bdLocation, BDLocation.BDLOCATION_BD09LL_TO_GCJ02);
        mAddress.setLatitude(bdLocation.getLatitude());
        mAddress.setLongitude(bdLocation.getLongitude());
    }
    Log.i("LingJu", "LocationAccessAdapter setAddress() 最终位置:>> " + mAddress);
}
 
Example 2
Source File: BaiduAddress.java    From AssistantBySDK with Apache License 2.0 5 votes vote down vote up
/**
 * 将百度坐标转换成国测局坐标
 **/
public void setCGJ02() {
    BDLocation bl = new BDLocation();
    bl.setLatitude(this.latitude);
    bl.setLongitude(this.longitude);
    bl = LocationClient.getBDLocationInCoorType(bl, BDLocation.BDLOCATION_BD09LL_TO_GCJ02);
    this.latitude = bl.getLatitude();
    this.longitude = bl.getLongitude();
}
 
Example 3
Source File: BaiduAddress.java    From AssistantBySDK with Apache License 2.0 5 votes vote down vote up
public void setBD09LL() {
    BDLocation bl = new BDLocation();
    bl.setLatitude(this.latitude);
    bl.setLongitude(this.longitude);
    bl = LocationClient.getBDLocationInCoorType(bl, BDLocation.BDLOCATION_GCJ02_TO_BD09LL);
    this.latitude = bl.getLatitude();
    this.longitude = bl.getLongitude();
}
 
Example 4
Source File: NaviConfirmPointActivity.java    From AssistantBySDK with Apache License 2.0 4 votes vote down vote up
@OnClick({R.id.ancp_back_bt, R.id.ancp_map_locate_bt, R.id.ancp_zoom_in_bt, R.id.ancp_zoom_out_bt,
        R.id.ancp_poi_detial_pre_bt, R.id.ancp_poi_detial_next_bt, R.id.ancp_map_its_bt})
public void onClick(View view) {
    switch (view.getId()) {
        case R.id.ancp_back_bt:
            onBackPressed();
            break;
        case R.id.ancp_map_locate_bt:
            /* 封装定位信息 */
            BDLocation location = new BDLocation();
            location.setLatitude(address.getLatitude());
            location.setLongitude(address.getLongitude());
            location.setRadius(address.getRadius());
            location.setSpeed(address.getSpeed());
            location.setSatelliteNumber(address.getSatelliteNumber());
            location = LocationClient.getBDLocationInCoorType(location, BDLocation.BDLOCATION_GCJ02_TO_BD09LL);
            /* 开启定位图层 */
            baiduMap.setMyLocationEnabled(true);
            // 设置定位图层的配置(定位模式,是否允许方向信息,用户自定义定位图标)
            baiduMap.setMyLocationConfigeration(new MyLocationConfiguration(MyLocationConfiguration.LocationMode.FOLLOWING, true, null));
            /* 构造定位数据并设置 */
            baiduMap.setMyLocationData(new MyLocationData.Builder().latitude(location.getLatitude())
                    .longitude(location.getLongitude())
                    .accuracy(location.getRadius())
                    .direction(location.getDirection())
                    .satellitesNum(location.getSatelliteNumber())
                    .speed(location.getSpeed())
                    .build());
            break;
        case R.id.ancp_zoom_in_bt:
            baiduMap.setMapStatus(MapStatusUpdateFactory.zoomIn());
            break;
        case R.id.ancp_zoom_out_bt:
            baiduMap.setMapStatus(MapStatusUpdateFactory.zoomOut());
            break;
        case R.id.ancp_poi_detial_pre_bt:
            if (mAncpPoiDetailPager.getCurrentItem() > 0 && mAncpPoiDetailPager.getCurrentItem() < list.size()) {
                showPoiDetail(mAncpPoiDetailPager.getCurrentItem() - 1);
            }
            break;
        case R.id.ancp_poi_detial_next_bt:
            if (mAncpPoiDetailPager.getCurrentItem() >= 0 && mAncpPoiDetailPager.getCurrentItem() < list.size() - 1) {
                showPoiDetail(mAncpPoiDetailPager.getCurrentItem() + 1);
            }
            break;
        case R.id.ancp_map_its_bt:
            if (baiduMap.isTrafficEnabled()) {
                baiduMap.setTrafficEnabled(false);
                ((ImageButton) view).setImageResource(R.drawable.bnav_common_ic_map_its_off);
            } else {
                baiduMap.setTrafficEnabled(true);
                ((ImageButton) view).setImageResource(R.drawable.bnav_common_ic_map_its_on);
            }
            break;
    }
}
 
Example 5
Source File: NaviSetLinePresenter.java    From AssistantBySDK with Apache License 2.0 4 votes vote down vote up
@Override
public void setRouteModeDetail(int index) {
    calculateScheme = index;
    cancelCountDownTimer();
    /* 设置指定路线 */
    BNRoutePlanerProxy.getInstance().selectRoute(index);
    BNRoutePlanerProxy.getInstance().setCalculateScheme(index);
    RouteModel.setCalculateScheme(index);
    /* 获取指定算路偏好的指定路线 */
    RoutePlanModelProxy mRoutePlanModel = BNRoutePlanerProxy.getInstance().routePlans.get(calculatePreference).get(index);
    /* 绑定视图数据 */
    mSetLineView.updateRouteDetailList(mRoutePlanModel.getRouteNodeData());
    mSetLineView.setLineMsg(mRoutePlanModel);
    mSetLineView.setLineMsg(mRoutePlanModel);
    /* 设置导航路线图层 */
    BNMapControllerProxy.getInstance().setLayerMode(
            MapParams.LayerMode.MAP_LAYER_MODE_ROUTE_DETAIL_FOR_NAVI);
    BNMapControllerProxy.getInstance().updateLayer(MapParams.LayerType.MAP_LAYER_TYPE_ROUTE);
    //rLineDetailListBox.setVisibility(View.VISIBLE);

    for (int i = 0; i < 3; i++) {
        if (i == index) {   //选中路线
            mSetLineView.setRouteLineModeStyle(i, true);
        } else {            //其他导航路线
            mSetLineView.setRouteLineModeStyle(i, false);
        }
    }
    //上传导航引擎对象
    com.lingju.context.entity.Address startAddress = getAddress(routeInputs.get(0));
    com.lingju.context.entity.Address endAddress = getAddress(routeInputs.get(routeInputs.size() - 1));
    List<com.lingju.context.entity.Address> passPoints = new ArrayList<>();
    for (int i = 1; i < routeInputs.size() - 1; i++) {
        passPoints.add(getAddress(routeInputs.get(i)));
    }
    RouteModel routeModel = RouteModel.getCurrent();
    Route route = getRoute(mRoutePlanModel, startAddress, endAddress, passPoints, routeModel, calculateScheme);
    mNavigation.setRoute(route);
    mNavigation.setNaviplan(calculateScheme + 1);
    mNavigation.setIscongestion(NavigatorService.get().isCongestion() ? "ON" : "OFF");
    mNavigation.setStatus(RobotConstant.NaviStatus.PLAN.toString());
    uploadNavigation();
    keepNavigation();
    Log.i(TAG, "第一段路名:" + mRoutePlanModel.getFirstRoadName() + ",时间:" + mRoutePlanModel.getTotalTime() + ",花费:" + mRoutePlanModel.getTollFees() + ",routeNum:" + mRoutePlanModel.getNodeNum() + ",主要道路:" + mRoutePlanModel.getMainRoads());
    ArrayList<RoutePlanResultItemProxy> rList = mRoutePlanModel.getRouteNodeData();
    BDLocation tt = new BDLocation();
    for (RoutePlanResultItemProxy ri : rList) {
        tt.setLatitude(ri.getLatitude() / 1e5);
        tt.setLongitude(ri.getLongitude() / 1e5);
        tt = LocationClient.getBDLocationInCoorType(tt, BDLocation.BDLOCATION_GCJ02_TO_BD09LL);
        System.out.println(ri.getNextRoadName() + ",condition=" + ri.getRoadCondition() + ",coordinate=[" + tt.getLongitude() + "," + tt.getLatitude() + "]");
    }
}
 
Example 6
Source File: LocationUtil.java    From apollo-DuerOS with Apache License 2.0 2 votes vote down vote up
/**
 * transform to coordinate system
 *
 * @param bdLocation source coordinate:gcj02 coordinate system
 *
 * @return converted coordinate system:bd09ll coordinate system
 */
private BDLocation convertToBD09LL(BDLocation bdLocation) {
    return LocationClient.getBDLocationInCoorType(bdLocation, BDLocation.BDLOCATION_GCJ02_TO_BD09LL);
}
 
Example 7
Source File: LocationUtil.java    From apollo-DuerOS with Apache License 2.0 2 votes vote down vote up
/**
 * transform to coordinate system
 *
 * @param bdLocation source coordinate:gcj02 coordinate system
 *
 * @return converted coordinate system:bd09mc coordinate system
 */
private BDLocation convertToBD09MC(BDLocation bdLocation) {
    return LocationClient.getBDLocationInCoorType(bdLocation, BDLocation.BDLOCATION_GCJ02_TO_BD09);
}