How to use OutdoorPlugIn_ReadPredictionArea in Winprop API

Tianhang Yu_20657
Tianhang Yu_20657 Altair Community Member
edited August 2023 in Community Q&A
Hi,
 
I attempted to utilize OutdoorPlugIn_ReadPredictionArea in order to obtain the lower left and upper right corners of the prediction area within an odb file. I set NumberCorners to 2 but only received one corner. Below are both my code and the result. Would you be able to assist me in identifying which parameter is causing the issue?
 
Thank you,
Tianhang Yu

Code:

// Prediction heights
int              NrPredictionHeights = 1;
double           PredictionHeights[1] = { 1.5 };
const char* my_odb_database = API_DATA_FOLDER "odbdata/map1";
 
// Size of matrix with results.
GeneralParameters.Resolution = 5.0;                        // Resolution in meter
GeneralParameters.NrLayers = NrPredictionHeights;          // Number of prediction heights
GeneralParameters.PredictionHeights = PredictionHeights;   // Prediction height in meter
 
//// Get prediction area.
 
int *NumberCorners = new int(2);
int DatabaseFileType = DATABASE_TYPE_WINPROP_ODB;
struct COORDPOINT point1;
struct COORDPOINT point2;
struct COORDPOINT * coord[2] = { &point1, &point2 };
struct COORDPOINT** Polygon = coord;
double* Resolution = &GeneralParameters.Resolution;
int* NumberHeights = &GeneralParameters.NrLayers;
double** Heights = &GeneralParameters.PredictionHeights;
int* PolygonUsed = new int(1);
 
OutdoorPlugIn_ReadPredictionArea(my_odb_database, NumberCorners, Polygon, DatabaseFileType, Resolution, NumberHeights, Heights, PolygonUsed);
 
std::cout << "Polygon DEBUG:" << Polygon[0]->x << std::endl;
std::cout << "Polygon DEBUG:" << Polygon[0]->y << std::endl;
std::cout << "Polygon DEBUG:" << Polygon[0]->z << std::endl;

std::cout << "Polygon DEBUG:" << Polygon[1]->x << std::endl;
std::cout << "Polygon DEBUG:" << Polygon[1]->y << std::endl;
std::cout << "Polygon DEBUG:" << Polygon[1]->z << std::endl;
 

Result:

Polygon DEBUG:610532
Polygon DEBUG:4.26688e+06
Polygon DEBUG:0

Polygon DEBUG:-9.25596e+61
Polygon DEBUG:-9.25596e+61
Polygon DEBUG:-9.25596e+61

Best Answer

  • reinerh
    reinerh
    Altair Employee
    edited August 2023 Answer ✓

    Please use the following code which should work:


        int NumberCorners;
        int DatabaseFileType = DATABASE_TYPE_WINPROP_ODB;
        struct COORDPOINT* Polygon;
        double* Resolution = &GeneralParameters.Resolution;
        int NumberHeights = 0;
        int PolygonUsed = 0;

      OutdoorPlugIn_ReadPredictionArea(my_odb_database, &NumberCorners, &Polygon, DatabaseFileType, Resolution, &NumberHeights, nullptr, &PolygonUsed);

Answers

  • reinerh
    reinerh
    Altair Employee
    edited August 2023 Answer ✓

    Please use the following code which should work:


        int NumberCorners;
        int DatabaseFileType = DATABASE_TYPE_WINPROP_ODB;
        struct COORDPOINT* Polygon;
        double* Resolution = &GeneralParameters.Resolution;
        int NumberHeights = 0;
        int PolygonUsed = 0;

      OutdoorPlugIn_ReadPredictionArea(my_odb_database, &NumberCorners, &Polygon, DatabaseFileType, Resolution, &NumberHeights, nullptr, &PolygonUsed);
  • Tianhang Yu_20657
    Tianhang Yu_20657 Altair Community Member
    edited August 2023
    reinerh said:

    Please use the following code which should work:


        int NumberCorners;
        int DatabaseFileType = DATABASE_TYPE_WINPROP_ODB;
        struct COORDPOINT* Polygon;
        double* Resolution = &GeneralParameters.Resolution;
        int NumberHeights = 0;
        int PolygonUsed = 0;

      OutdoorPlugIn_ReadPredictionArea(my_odb_database, &NumberCorners, &Polygon, DatabaseFileType, Resolution, &NumberHeights, nullptr, &PolygonUsed);

    Hi Reinerh,

    Thank you for your assistance. Sorry that I'm not often working with C++, so I'm not very familiar with writing this code. I still have some confusion regarding the initialization of the Polygon parameter and the return value of OutdoorPlugIn_ReadPredictionArea.

    1. Based on my understanding, when NumberCorners is set to 2, OutdoorPlugIn_ReadPredictionArea should return two data sets of type COORDPOINT, each containing values for x, y, and z. Furthermore, these two sets of COORDPOINT data should be stored at the address pointed to by Polygon. How should I initialize the address pointed to by Polygon to store the data that will be returned?

    2. Assuming I've completed the first step and obtained a pointer Polygon pointing to two sets of COORDPOINT, how can I access the coordinate data stored in these two sets of COORDPOINT and then assign them to other variables?

    I've tried various methods and also the code you sent me, but it seems that Polygon consistently only provides me with the x, y, and z values of only one set of coordinates. I would greatly appreciate it if you could help me resolve this issue.

    Thank you,

    Tianhang Yu

  • reinerh
    reinerh
    Altair Employee
    edited August 2023

    Hi Reinerh,

    Thank you for your assistance. Sorry that I'm not often working with C++, so I'm not very familiar with writing this code. I still have some confusion regarding the initialization of the Polygon parameter and the return value of OutdoorPlugIn_ReadPredictionArea.

    1. Based on my understanding, when NumberCorners is set to 2, OutdoorPlugIn_ReadPredictionArea should return two data sets of type COORDPOINT, each containing values for x, y, and z. Furthermore, these two sets of COORDPOINT data should be stored at the address pointed to by Polygon. How should I initialize the address pointed to by Polygon to store the data that will be returned?

    2. Assuming I've completed the first step and obtained a pointer Polygon pointing to two sets of COORDPOINT, how can I access the coordinate data stored in these two sets of COORDPOINT and then assign them to other variables?

    I've tried various methods and also the code you sent me, but it seems that Polygon consistently only provides me with the x, y, and z values of only one set of coordinates. I would greatly appreciate it if you could help me resolve this issue.

    Thank you,

    Tianhang Yu

    Hi Tianhang Yu,

    please note NumberCorners and Polygon are set inside the function, no need to allocate memory before, which is also done inside the function.

    For an .odb database the NumberCorners will be set to 4 and the Polygon[0], Polygon[1], Polygon[2], Polygon[3] will be set to the LL, LR, UR, UL corners.

    I tested this yesterday on my side and it worked with the mentioned code as expected.

    Best regards,
    Reiner

  • Tianhang Yu_20657
    Tianhang Yu_20657 Altair Community Member
    edited August 2023
    reinerh said:

    Hi Tianhang Yu,

    please note NumberCorners and Polygon are set inside the function, no need to allocate memory before, which is also done inside the function.

    For an .odb database the NumberCorners will be set to 4 and the Polygon[0], Polygon[1], Polygon[2], Polygon[3] will be set to the LL, LR, UR, UL corners.

    I tested this yesterday on my side and it worked with the mentioned code as expected.

    Best regards,
    Reiner

    Hi Reinerh,

    You're correct. It's working perfectly! You've really helped me out, thank you so much.

    Best regards,

    Tianhang Yu