简体   繁体   中英

SSIS · Trigonometric functions

I'm trying to calculate SIN and COS in SSIS expression (as new column), but I cannot find any expression.

For example:

SIN(lat_org_rad) COS(long_org_rad) ACOS(long_org_rad)

Could anybody help me?

Thanks

TLDR: COS() , SIN() , ACOS() cannot be achieved using SSIS expression you have to write a script component to achieve that using System.Math assembly which is apart of the .NET framework.


Detailed answer

I am writing this answer as additional information for the answer written by the OP:

The SSIS expression language includes a set of functions for use in expressions, and they can be categorized into the following groups:

  • Mathematical functions
  • String functions
  • Date and time functions
  • System functions

The following table (official documentation) contains the mathematical functions supported in the SSIS expression language:

在此输入图像描述

Based on that, there is no COS() , SIN() and ACOS() function provided by the SSIS expression language.

Script Component

On the other hand you can benefit from the Script Component transformation for more advanced mathematical functions using System.Math assembly which contains advanced methods that are listed in the following documentation:


References

I was able to solve the issue using a Script component:

public override void Entrada0_ProcessInputRow(Entrada0Buffer Row)
{
    if (Row.latdestrad == 0)
    {
        Row.kms = 0;
    }
    else
    {
        Row.kms = Math.Acos(
            (Math.Sin(Row.latorgrad) * (Math.Sin(Row.latdestrad))) +
            (Math.Cos(Row.latorgrad) * (Math.Cos(Row.latdestrad)) * Math.Cos(Row.londestrad - Row.lonorgrad)))
            * 57.29577951 * 111.302;
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM