Ticket T1279772
Visible to All Users
Duplicate

v24.2.5 AzureRouteOptions set to computeBestOrder = false crashing

created 2 days ago

Hi.

Thank you very much for the new DevExpress 24.2.5 version as now we can get the Azure map service to create optimised routes.

However when don't want to optimize the route the application is crashing. Either setting computeBestOrder = false or not setting it at all, getting NullReferenceException. Even tried to set the computeBestOrder = false by also setting routetype = eco, just in case requires both of them even if the Microsoft documentation says that's not needed. (see attached image)

Here is a code sample for the logic statement. The language used is Oxygene (Objective Pascal)

if aSelectedOptimization <> 'None' then
begin
lAzureRouteOptions.CustomParameters.Add('routetype', aSelectedOptimization.ToLower);
lAzureRouteOptions.CustomParameters.Add('computeBestOrder', 'true');
end
else begin
//lAzureRouteOptions.CustomParameters.Add('routetype','eco');
lAzureRouteOptions.CustomParameters.Add('computeBestOrder', 'false');
end;

Not setting computeBestOrder didn't crash the application with 24.2.4 which is the previous version used when started development of the current map module. Previous version was just checking if the value is not "None" to parse the optional.

Here is the whole sub doing the work.

method D0746MapGenerator.LoadAzureMap(aInstanceId : Integer; aSiteName : String; aDepartAt : DateTime; aInstanceNode : TreeListNode; aSelectedOptimization : String := 'None');
var
lAzureRouteDataProvider : AzureRouteDataProvider := new AzureRouteDataProvider;
lAzureMapDataProviderImagery : AzureMapDataProvider := new AzureMapDataProvider;
lAzureMapDataProviderBaseHybridRoad : AzureMapDataProvider := new AzureMapDataProvider;
lRouteLocationslist : List<RouteWaypoint> := new List<RouteWaypoint>();
lRouteInfoLayer : InformationLayer := new InformationLayer();
lImageLayerImagery : ImageLayer := new ImageLayer();
lImageLayerBaseHybridRoad : ImageLayer := new ImageLayer();
lVectorItemsLayer : VectorItemsLayer;
lAzureRouteOptions : AzureRouteOptions := new AzureRouteOptions();

begin
//get the list
lRouteLocationslist := self.GetRouteLocationWaypoints(aInstanceId, aSiteName);
self.fProcessInstance := aInstanceNode; //store this for later on when handling the event to load the metadata
//clear everything
self.fMapControl.Layers.Clear;
//set the Route Data Provider
lAzureRouteDataProvider.AzureKey := ReflexAzureKey;
lAzureRouteDataProvider.RouteCalculated += AzureRouteDataProvider_OnRouteCalculated; //
lAzureRouteDataProvider.LayerItemsGenerating += AzureRouteDataProvider_LayerItemsGenerating;

lAzureMapDataProviderImagery.AzureKey := ReflexAzureKey;
lAzureMapDataProviderImagery.Tileset := AzureTileset.BaseRoad;

lAzureMapDataProviderBaseHybridRoad.AzureKey := ReflexAzureKey;
lAzureMapDataProviderBaseHybridRoad.Tileset := AzureTileset.BaseHybridRoad;

//set the information layer

lRouteInfoLayer.DataProvider := lAzureRouteDataProvider;
lRouteInfoLayer.Error += RouteInfoLayer_Error;

lImageLayerImagery.DataProvider := lAzureMapDataProviderImagery;
lImageLayerBaseHybridRoad.DataProvider := lAzureMapDataProviderBaseHybridRoad;

self.fMapControl.Layers.Add(lImageLayerImagery);
self.fMapControl.Layers.Add(lImageLayerBaseHybridRoad);
self.fMapControl.Layers.Add(lRouteInfoLayer);

lRouteInfoLayer.ItemStyle.StrokeWidth := 2;
lRouteInfoLayer.ItemStyle.Stroke := Color.DeepSkyBlue;

self.fMapControl.Zoom(8);
self.fMapControl.SetCenterPoint(new GeoPoint(self.fOriginLat, self.fOriginLon), false);
self.fMapControl.EnableRotation := false;

try

var newDepart: DateTime := new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, aDepartAt.Hour, aDepartAt.Minute, aDepartAt.Second);

lAzureRouteOptions.TravelMode := AzureTravelMode.Van;

lAzureRouteOptions.CustomParameters := new Dictionary<String,String>();

lAzureRouteOptions.CustomParameters.Add('departAt', newDepart.ToString('yyyy-MM-ddTHH:mm:ss.fffK'));

if aSelectedOptimization <> 'None' then
begin
lAzureRouteOptions.CustomParameters.Add('routetype', aSelectedOptimization.ToLower);
lAzureRouteOptions.CustomParameters.Add('computeBestOrder', 'true');
end
else begin
lAzureRouteOptions.CustomParameters.Add('routetype','eco');
lAzureRouteOptions.CustomParameters.Add('computeBestOrder', 'false');
end;

lAzureRouteDataProvider.CalculateRoute(lRouteLocationslist, lAzureRouteOptions);

except
on lError : Exception do
begin
// Handle the exception
MessageBox.Show(String.Format('An error occurred with Azure Map service {0} {1}', Environment.NewLine, lError.Message));

end;
end;

end;

Answers approved by DevExpress Support

created 18 hours ago

Hello Panos,

First of all, thank you for your kind words. We are happy to hear that DevExpress v24.2.5 meets your requirements.

Regarding your report - thank you for the detailed description. We successfully recreated the project in C# and reproduced the issue. I forwarded it to our developers for further research. We will update the following ticket once we have news: AzureRouteOptions v24.2.5 - Exception Occurs When Router Loads Vector Items with computeBestOrder Set to False. Thank you for bringing this issue to our attention.

Regards,
Steven

    Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

    Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.