Calculate Total Miles per State

Hello Guys,

I just learned about this Website through Microsoft Powerapps.

I´m building a Logistics App I need to break down the total miles drove per State for Tax Purposes.

I need something similar to this website: https://ifta-calculator.com/

image

Total miles: 2187 mi

Jurisdiction Total miles
AL 164
AR 60
LA 161
MD 13
MS 234
NJ 29
PA 167
TN 368
TX 571
VA 290
WV 130

Thank you very much for the help!!!

Cheers,

Yeriel.

Hmmm… When you use Routing API with instructions then in the response you can find state code of the points where you should make a turn/change direction. But I need to find something more precise.

I have been searching in other forums like StackFlow (Google), PowerApps, and others but I don’t see any good solution for it.

There´s one guy who used Google Maps API and Excel to get this answer but I need to pay 100 $ to see the solution in excel.

If someone can help me with this inquiry would be awesome.

Let’s assume you have:

  • route defined (points from A to B)
  • polygons of all states

With for example Turf.js you can define which route points are located inside particular state.
Then in another Routing API call you can query for this route to get its length.

That should be quite precise.

Hi @maloleps, thanks for stepping in.

Okay, let´s assume I have the information as follow:

I have never done something like this, if you could guide me in the right direction I would truly appreciate it.

Cheers,

Yeriel Mangin

Now you can use starting and ending point to calculate route with Calculate Route endpoint.
It returns points of this route.
Then with pointsWithinPolygon from Turf.js you can check them against each predefined polygons.
In the result it returns points, that can be used to reconstruct a route with Calculate Route endpoint. In the response you should see a distance within one state.

That is what I would try to do.

Thanks for the information @maloleps,

Could you please show me how would you add these into a JSON request content?

Thanks for the help! :pray:

Didn’t test this, but something like this:

var supportingPoints = []
for (var feature in ptsWithin.features) {
  supportingPoints.add({"latitude": feature.geometry.coordinates[0], "longitude": feature.geometry.coordinates[1]})
}