Skip to content

Commit

Permalink
improved line weight calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
anti79 committed Jul 23, 2022
1 parent bd950c2 commit a9481de
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions GoogleMapsApi/StaticMaps/RouteMapsEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ private StaticMapRequest CreateStaticMapRequest(RouteMapRequest request, IEnumer
};
return staticMapRequest;
}
private int CalculateWeight(double km)
{
return (int)Math.Ceiling(Math.Log(km, 4));
}
public RouteMapGenerationResult GenerateRouteMapURLSnap(RouteMapRequest request)
{
GeocodingRequest grA = new GeocodingRequest()
Expand Down Expand Up @@ -98,8 +102,8 @@ public RouteMapGenerationResult GenerateRouteMapURLSnap(RouteMapRequest request)
}

int weight = 10;
weight = (int)Math.Ceiling((double)(km/10));
weight = CalculateWeight(km);

string url = new StaticMapsEngine().GenerateStaticMapURL(CreateStaticMapRequest(request, locs,weight));
return new RouteMapGenerationResult(url);
}
Expand Down Expand Up @@ -128,7 +132,8 @@ public RouteMapGenerationResult GenerateRouteMapURL(RouteMapRequest request)
request.Zoom = (int)Math.Log((int)(40000 / (km / 2)), (int)2)-2;
}
int weight = 10;
weight = (int)Math.Ceiling((double)(km / 10));
weight = CalculateWeight(km);


string url = new StaticMapsEngine().GenerateStaticMapURL(CreateStaticMapRequest(request, locs, weight));
return new RouteMapGenerationResult(url);
Expand Down

0 comments on commit a9481de

Please sign in to comment.