Detailed Description
This is an example of how to use the WinProp API to preprocess an urban database for IRT. The full example is distributed with the installation.
#include <stdio.h>
#include <string>
#include <iostream>
#include "IRT_preprocess_urban.h"
#ifndef API_DATA_FOLDER
#define API_DATA_FOLDER "../../api/winprop/data/"
#endif // !API_DATA_FOLDER
int main(int argc, char** argv)
{
int Error = 0;
WinProp_PreProUrban PreproPara;
WinProp_Callback Callback;
WinProp_Structure_Init_Callback(&Callback);
WinProp_Structure_Init_PreProUrban(&PreproPara);
Callback.Percentage = CallbackProgress;
Callback.Message = CallbackMessage;
Callback.Error = CallbackError;
sprintf(PreproPara.FilenameBuildings, "%s", API_DATA_FOLDER "/outdoor/City");
sprintf(PreproPara.FilenameTopography, "%s", API_DATA_FOLDER "/outdoor/Topo.tdb");
PreproPara.Model = PREDMODEL_IRT;
PreproPara.Mode = PP_MODE_IRT_3D;
PreproPara.NrHeights = 1;
PreproPara.Heights = (double*)malloc(sizeof(double) * (PreproPara.NrHeights));
PreproPara.Heights[0] = 1.5;
PreproPara.HeightAbsolute = 0;
PreproPara.ConsiderIndoorPixels = 0;
PreproPara.AdaptiveResolution = 0;
PreproPara.Resolution = (double)10.;
PreproPara.SegmentHorizontal = (double)100.;
PreproPara.SegmentVertical = (double)100.;
PreproPara.TileHorizontal = (double)100.;
PreproPara.TileVertical = (double)100.;
PreproPara.ConsiderTopography = 1;
PreproPara.AbsoluteBuildingHeights = 0;
PreproPara.MultipleInteractions = 1;
PreproPara.SphericMode = PP_MODE_IRT_ZONE_OFF;
PreproPara.MultiThreading = 2;
PreproPara.CornersPolygon = (COORDPOINT*)malloc(sizeof(COORDPOINT) * 8);
if (PreproPara.CornersPolygon != nullptr)
{
PreproPara.NrCornersPolygon = 8;
PreproPara.CornersPolygon[0] = { 324.424, 2551.730, PreproPara.Heights[0] };
PreproPara.CornersPolygon[1] = { 803.687, 2971.085, PreproPara.Heights[0] };
PreproPara.CornersPolygon[2] = { 1660.829, 2961.869, PreproPara.Heights[0] };
PreproPara.CornersPolygon[3] = { 2084.793, 2445.740, PreproPara.Heights[0] };
PreproPara.CornersPolygon[4] = { 2084.793, 1501.039, PreproPara.Heights[0] };
PreproPara.CornersPolygon[5] = { 1582.488, 1127.767, PreproPara.Heights[0] };
PreproPara.CornersPolygon[6] = { 817.512, 1141.592, PreproPara.Heights[0] };
PreproPara.CornersPolygon[7] = { 333.641, 1514.864, PreproPara.Heights[0] };
}
Error = OutdoorPlugIn_ComputePrePro(
&PreproPara,
API_DATA_FOLDER "/outdoor/City_IRT_API",
nullptr,
nullptr,
&Callback,
nullptr
);
if (PreproPara.Heights != NULL)
free(PreproPara.Heights);
PreproPara.Heights = nullptr;
PreproPara.NrHeights = 0;
if (PreproPara.CornersPolygon != nullptr)
free(PreproPara.CornersPolygon);
return Error;
}
int _STD_CALL CallbackMessage(const char * Text)
{
if (Text == nullptr)
return 0;
std::cout << "\n" << Text;
return(0);
}
int _STD_CALL CallbackError(const char * Text, int Error)
{
if (Text == nullptr)
return 0;
std::cout << "\n";
#ifdef __LINUX
std::cout << "\033[31m" << "Error (" << Error << "): ";
#else
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, FOREGROUND_RED);
std::cout << "Error (" << Error << "): ";
#endif // __LINUX
std::cout << Text;
#ifdef __LINUX
std::cout << "\033[0m";
#else
SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN);
#endif // __LINUX
return 0;
}
int _STD_CALL CallbackProgress(int value, const char* text)
{
char Line[200];
sprintf(Line, "\n%d%% %s", value, text);
std::cout << Line;
return(0);
}