Cruising Area
この章ではCruising Areaの表示方法、制御方法について紹介します。
Cruising Areaとは
電力/燃料の消費量を推定し、推定した電力燃料消費率で到達可能なエリアを表示する機能です。
Cruising Area設定方法
大まかに以下の流れで設定します。
EnergyInfoの各パラメータを設定します。EnergyInfo.ExtendCruisingAreaで表示したい燃料または電力消費率を設定します。CruisingAreaRequestにEnergyInfoを設定し、Navi.getCruisingArea()を呼び出します。
日産リーフの後続可能領域を作成するサンプルは以下の通りです。
EnergyInfo energyInfo = new EnergyInfo();
energyInfo.setModel("ZAA-ZE1");
energyInfo.setEnergyType(EnergyInfo.EnergyType.ELECTRIC);
EnergyInfo.TypeElectric typeElectric = new EnergyInfo.TypeElectric();
typeElectric.setBattery(40F); // バッテリ容量[kWh]
energyInfo.setTypeElectric(typeElectric);
energyInfo.setEnergyInfoExtension(EnergyInfo.EnergyInfoExtension.CRUISINGAREA);
EnergyInfo.ExtendCruisingArea extendCruisingArea = new EnergyInfo.ExtendCruisingArea();
extendCruisingArea.setCruisingAreaRateList(new ArrayList<>(Arrays.asList(100, 50))); // 電力消費率100%, 50%で到達可能な領域
energyInfo.setExtendCruisingArea(extendCruisingArea);
CruisingAreaRequest request = new CruisingAreaRequest();
request.setEnergyInfo(energyInfo);
Navi.getInstance().getCruisingArea(request, new CruisingAreaListener() {
@Override
public void onCompleted(ErrorCode errorCode, CruisingAreaResult result) {
if (errorCode == ErrorCode.NONE) {
// 地図全体が画面に収まるように拡大率を調整
List<GeoCoordinate> pathPointList = new ArrayList<>();
pathPointList.add(result.getRange().getLeftBottom());
pathPointList.add(result.getRange().getRightTop());
GeoBoundingBox geoBoundingBox = GeoBoundingBox.getBoundingBoxContainingGeoCoordinates(pathPointList);
map.zoomTo(geoBoundingBox, 0, false);
}
else {
// 失敗
}
}
});
Note:
cruisingAreaRateに指定された値ごとに透過率が設定された領域が描画されます。
そのため、近くの領域は濃く、遠くの領域は薄くなります。
注意:
- 時間規制は考慮されません。
- フェリー航路は考慮されません。
- 住宅地図では利用できません。
Cruising Areaの条件調整
CruisingAreaRequest.Optionsによって、
- 探索基準
- 有料道路利用有無
- スマートIC利用有無
を切り替えられます。
距離優先
CruisingAreaRequest request = new CruisingAreaRequest();
CruisingAreaRequest.Options options = new CruisingAreaRequest.Options();
options.setPriority(CruisingAreaRequest.Options.Priority.DISTANCE);
request.setOptions(options);
幹線優先
CruisingAreaRequest request = new CruisingAreaRequest();
CruisingAreaRequest.Options options = new CruisingAreaRequest.Options();
options.setPriority(CruisingAreaRequest.Options.Priority.MAIN_ROAD);
request.setOptions(options);
推奨・有料道なし・スマートICなし
CruisingAreaRequest request = new CruisingAreaRequest();
CruisingAreaRequest.Options options = new CruisingAreaRequest.Options();
options.setPriority(CruisingAreaRequest.Options.Priority.RECOMMENDED);
options.setUseToll(false);
options.setUseSmartIC(false);
request.setOptions(options);
Cruising Areaのデザイン変更
CruisingAreaDesignを設定して表示方法をカスタマイズできます。
CruisingAreaDesign.Contour contour = new CruisingAreaDesign.Contour();
contour.setDayFillColor(0x33FF0000); // 塗りつぶし昼色
contour.setNightFillColor(0x66FF0000); // 塗りつぶし夜色
contour.setDayOutLineColor(0xFFFF0000); // 縁取り線昼色
contour.setNightOutLineColor(0xFF000000); // 縁取り線夜色
contour.setOutLineWidth(5f); // 縁取り線太さ
contour.setOutLine(true); // 縁取り線有り
List<CruisingAreaDesign.Contour> contourList = new ArrayList<>();
contourList.add(contour);
CruisingAreaDesign design = new CruisingAreaDesign();
design.setContourList(contourList);
Navi.getInstance().changeCruisingAreaDesign(design);
Cruising Areaの表示制御について
Cruising Areaの表示
表示、非表示を切り替えるにはMap.setCruisingAreaVisible()をtrue(表示する)、またはfalse(非表示にする)で呼び出してください。
Cruising Areaの消去
Cruising Areaを削除したい場合、Navi.eraseCruisingArea()を呼び出してください。