public static DecimalType CalculateDistance(DecimalType latitude1, DecimalType longitude1, DecimalType latitude2, DecimalType longitude2) { if (latitude1.IsValid && longitude1.IsValid && latitude2.IsValid && longitude2.IsValid) { return (new DecimalType( CalculateDistance(DecimalType.ToDouble(latitude1), DecimalType.ToDouble(longitude1), DecimalType.ToDouble(latitude2), DecimalType.ToDouble(longitude2)))); } else { return(-1); } }