How to use OutdoorPlugIn_ReadPredictionArea in Winprop API
Code:
double PredictionHeights[1] = { 1.5 };
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:4.26688e+06
Polygon DEBUG:0
Polygon DEBUG:-9.25596e+61
Polygon DEBUG:-9.25596e+61
Polygon DEBUG:-9.25596e+61
-
Based on my understanding, when
NumberCornersis set to 2,OutdoorPlugIn_ReadPredictionAreashould return two data sets of typeCOORDPOINT, each containing values for x, y, and z. Furthermore, these two sets ofCOORDPOINTdata should be stored at the address pointed to byPolygon. How should I initialize the address pointed to byPolygonto store the data that will be returned? -
Assuming I've completed the first step and obtained a pointer
Polygonpointing to two sets ofCOORDPOINT, how can I access the coordinate data stored in these two sets ofCOORDPOINTand then assign them to other variables? -
Based on my understanding, when
NumberCornersis set to 2,OutdoorPlugIn_ReadPredictionAreashould return two data sets of typeCOORDPOINT, each containing values for x, y, and z. Furthermore, these two sets ofCOORDPOINTdata should be stored at the address pointed to byPolygon. How should I initialize the address pointed to byPolygonto store the data that will be returned? -
Assuming I've completed the first step and obtained a pointer
Polygonpointing to two sets ofCOORDPOINT, how can I access the coordinate data stored in these two sets ofCOORDPOINTand then assign them to other variables?
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.
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 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
Polygonparameter and the return value ofOutdoorPlugIn_ReadPredictionArea.
I've tried various methods and also the code you sent me, but it seems that
Polygonconsistently 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
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
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);


Please use the following code which should work: