rock rock - 6 months ago 27
PowerShell Question

How to calculate the distance between different cities by PowerShell?

I am doing a project which needs to calculate the distance between different cities in the world. I think there is a way with google maps, but I do not know how to use it within PowerShell.

I found something new from Get location (lat/long) from googlemap with address - Using powershell.

The answer to that question is quite useful, but the coordinates I got can't be directly used to calculate the distance.
I've tried to use

to change the data type. But it gave me the error
Cannot convert the "System.Decimal" value of type "System.RuntimeType" to type "System.Double".

Any method can convert the data type?


To answer the conversion part of this question (using the example from the other question you referenced), the following will give you a decimal variable:

$lat = $

This will convert it to a double (for example):

$lat = [double]$