WSF
HorizontalMapFunction.hpp
Go to the documentation of this file.
1// ****************************************************************************
2// CUI
3//
4// The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
5//
6// Copyright 2003-2015 The Boeing Company. All rights reserved.
7//
8// The use, dissemination or disclosure of data in this file is subject to
9// limitation or restriction. See accompanying README and LICENSE for details.
10// ****************************************************************************
11
12#ifndef HORIZONTALMAPFUNCTION_HPP
13#define HORIZONTALMAPFUNCTION_HPP
14
15#include <string>
16#include <vector>
17
18#include "ContourFilter2D.hpp"
19#include "MapPlotFunction.hpp"
20#include "SupTMProjection.hpp"
21#include "Target.hpp"
22#include "UtColor.hpp"
23class WsfPlatform;
24class WsfSensor;
25
27{
28public:
30 using Point = std::vector<double>;
31
32 static const double cUNDEFINED;
33
34 explicit HorizontalMapFunction(const WsfScenario& aScenario);
35
36 bool Execute(WsfSimulation& aSimulation) override;
37 bool ProcessInput(UtInput& aInput) override;
38
39protected:
42 {
43 explicit PointCompare(size_t aVarIndex)
44 : mVarIndex(aVarIndex)
45 {
46 }
47
48 bool operator()(const Point& p1, const Point& p2) { return (p1[mVarIndex] < p2[mVarIndex]); }
49
50 private:
51 size_t mVarIndex;
52 };
53
56 {
57 double mLevel{0.5};
58 UtColor mLineColor{1.0F, 0.5F, 0.0F};
59 int mLineWidth{3};
60 int mLineStyle{0};
61 };
62
65 {
66 public:
67 ContourFunction(const std::vector<double>& aRowValues,
68 const std::vector<double>& aColValues,
69 const std::vector<Point>& aDataValues,
70 size_t aVarIndex)
71 : mRowValues(aRowValues)
72 , mColValues(aColValues)
73 , mDataValues(aDataValues)
74 , mVarIndex(aVarIndex)
75 {
76 }
77
78 double GetX(size_t aRowIndex, size_t aColIndex) override { return mRowValues[aRowIndex]; }
79 double GetY(size_t aRowIndex, size_t aColIndex) override { return mColValues[aColIndex]; }
80 double GetValue(size_t aRowIndex, size_t aColIndex) override
81 {
82 size_t gridIndex = (aRowIndex * mColValues.size()) + aColIndex;
83 return mDataValues[gridIndex][mVarIndex];
84 }
85
86 private:
87 const std::vector<double>& mRowValues;
88 const std::vector<double>& mColValues;
89 const std::vector<Point>& mDataValues;
90 size_t mVarIndex;
91 };
92
106
108 {
110 : mFileName()
111 , mColorRanges()
112 , mDataTitleStr("Unknown")
113 , mUnitsStr("Unknown")
114 {
115 }
116
119 {
120 bool operator<(const ColorRange& aRhs) const
121 {
122 return (std::make_pair(mMinValue, mMaxValue) < std::make_pair(aRhs.mMinValue, aRhs.mMaxValue));
123 }
124
125 double mMinValue;
126 double mMaxValue;
127 UtColor mColor; // RGBA
128 };
129
130 std::string mFileName;
131 std::vector<ColorRange> mColorRanges;
132 std::string mDataTitleStr;
133 std::string mUnitsStr;
134 };
135
136 using SelectorList = std::vector<Selector>;
137
138 bool BuildContours(size_t aPdVarIndex);
139 bool LoopOverTargetAltitude(size_t aPdVarIndex);
140 bool LoopOverTargetPitch(size_t aPdVarIndex);
141 bool LoopOverTargetRoll(size_t aPdVarIndex);
142
143 void ConvertCartesianToSpherical(double aDownRange, double aCrossRange, double& aLatitude, double& aLongitude);
144
145 void ConvertSphericalToCartesian(double aLatitude, double aLongitude, double& aDownRange, double& aCrossRange);
146
147 void EvaluatePoint(double aSimTime, double aRowValue, double aColValue, std::vector<double>& aDataValues);
148
149 void InitializeSensorPlatforms(double aSimTime);
150
151 void CreateSensorList(WsfSimulation& aSimulation);
152
153 bool InSelectorList(WsfSensor* aSensorPtr, const SelectorList& aSelectorList);
154
155 bool ProcessTargetRegion(UtInput& aInput);
156
157 void ReadSelector(UtInput& aInput, SelectorList& aSelectorList);
158
159 void WriteDefendedAreaReport(const std::vector<double>& aAreaByPd);
160
161 void WriteGnuPlotFile(const std::vector<double>& aRowValues,
162 const std::vector<double>& aColValues,
163 const std::vector<Point>& aVarValues);
164
166
167 void WriteKML_File(const std::vector<double>& aRowValues,
168 const std::vector<double>& aColValues,
169 const std::vector<Point>& aVarValues,
170 size_t aVarIndex);
171
172 void WritePdMapFile(const std::vector<double>& aRowValues,
173 const std::vector<double>& aColValues,
174 const std::vector<Point>& aVarValues,
175 size_t aVarIndex);
176
177 void WriteSeditContours(const std::vector<double>& aRowValues,
178 const std::vector<double>& aColValues,
179 const std::vector<Point>& aVarValues,
180 size_t aVarIndex);
181
182 void WriteWSFContours(const std::vector<double>& aRowValues,
183 const std::vector<double>& aColValues,
184 const std::vector<Point>& aVarValues,
185 size_t aVarIndex);
186
187 void WriteShapefile(const std::vector<double>& aRowValues,
188 const std::vector<double>& aColValues,
189 const std::vector<Point>& aVarValues,
190 size_t aVarIndex);
191
192 void WriteAnalysisMapFile(const std::vector<double>& aRowValues,
193 const std::vector<double>& aColValues,
194 const std::vector<Point>& aVarValues,
195 size_t aVarIndex);
196
197 void WriteTiffFile(const std::vector<double>& aRowValues,
198 const std::vector<double>& aColValues,
199 const std::vector<Point>& aVarValues) const;
200
201 // Allow derived classes to write output in custom formats.
202 // Default implementation does nothing.
203 virtual void WriteCustomOutputFormats(const std::vector<double>& aRowValues,
204 const std::vector<double>& aColValues,
205 const std::vector<Point>& aVarValues,
206 size_t aVarIndex)
207 {
208 }
209
210 std::string GetPdMapFileJsonMetadata() const;
211
213
217 std::string mModeName;
228
230
231 double mLatMin;
232 double mLatMax;
233 double mLatStep;
234 double mLonMin;
235 double mLonMax;
236 double mLonStep;
237
241 std::string mDownRangeUnits;
245 std::string mCrossRangeUnits;
246
250
251 double mHeading;
255
257
258 std::string mGnuPlotFile;
260 std::string mPdMapFile;
261 std::string mHeaderLine1;
262 std::string mHeaderLine2;
263 std::string mHeaderLine3;
265 std::string mKML_File;
266 std::string mShapefile;
267 std::string mSeditFile;
268 std::string mWSF_File;
269 std::vector<ContourLevel> mContourLevels;
270 std::string mContourVariable{"pd"};
272
274 std::string mTiffFilename;
275
278
279 std::vector<WsfSensor*> mSensors;
280 std::vector<WsfSensor*> mExcludedSensors;
281
284
285 static void GreatCircleHeadingAndDistance(double aBegLat,
286 double aBegLon,
287 double aEndLat,
288 double aEndLon,
289 double& aHeading,
290 double& aDistance);
291};
292
293#endif
UtStringId WsfStringId
WsfStringId – the same thing as UtStringId.
Definition WsfStringId.hpp:23
Definition ContourFilter2D.hpp:27
ContourFunction(const std::vector< double > &aRowValues, const std::vector< double > &aColValues, const std::vector< Point > &aDataValues, size_t aVarIndex)
Definition HorizontalMapFunction.hpp:67
double GetY(size_t aRowIndex, size_t aColIndex) override
Definition HorizontalMapFunction.hpp:79
double GetValue(size_t aRowIndex, size_t aColIndex) override
Definition HorizontalMapFunction.hpp:80
double GetX(size_t aRowIndex, size_t aColIndex) override
Definition HorizontalMapFunction.hpp:78
Definition HorizontalMapFunction.hpp:94
WsfStringId mValue
Definition HorizontalMapFunction.hpp:104
SelectorType mType
Definition HorizontalMapFunction.hpp:103
SelectorType
Definition HorizontalMapFunction.hpp:97
@ cSENSOR_CATEGORY
Definition HorizontalMapFunction.hpp:99
@ cSENSOR_TYPE
Definition HorizontalMapFunction.hpp:98
@ cPLATFORM_TYPE
Definition HorizontalMapFunction.hpp:100
@ cPLATFORM_CATEGORY
Definition HorizontalMapFunction.hpp:101
SupTMProjection mProjection
Definition HorizontalMapFunction.hpp:249
std::string mSeditFile
Definition HorizontalMapFunction.hpp:267
void EvaluatePoint(double aSimTime, double aRowValue, double aColValue, std::vector< double > &aDataValues)
Definition HorizontalMapFunction.cpp:935
std::string mGnuPlotPlayerFile
Definition HorizontalMapFunction.hpp:259
std::string mHeaderLine1
Definition HorizontalMapFunction.hpp:261
std::vector< WsfSensor * > mExcludedSensors
Definition HorizontalMapFunction.hpp:280
double mCenterEarthRadius
Definition HorizontalMapFunction.hpp:254
double mCrossRangeMin
Definition HorizontalMapFunction.hpp:242
void InitializeSensorPlatforms(double aSimTime)
Definition HorizontalMapFunction.cpp:1024
SelectorList mInclusionList
Definition HorizontalMapFunction.hpp:277
double mSensorToENU_Transform[3][3]
Definition HorizontalMapFunction.hpp:282
double mCenterLat
Definition HorizontalMapFunction.hpp:252
std::string mTiffFilename
Definition HorizontalMapFunction.hpp:274
void WriteGnuPlotFile(const std::vector< double > &aRowValues, const std::vector< double > &aColValues, const std::vector< Point > &aVarValues)
Write output gnuplot 'splot' output.
Definition HorizontalMapFunction.cpp:1325
double mSensorPlatformRoll
Definition HorizontalMapFunction.hpp:216
double mLatStep
Definition HorizontalMapFunction.hpp:233
double mTargetAltMax
Definition HorizontalMapFunction.hpp:223
double mCrossRangeStep
Definition HorizontalMapFunction.hpp:244
std::string mHeaderLine2
Definition HorizontalMapFunction.hpp:262
void CreateSensorList(WsfSimulation &aSimulation)
Definition HorizontalMapFunction.cpp:1072
std::vector< Selector > SelectorList
Definition HorizontalMapFunction.hpp:136
void WriteWSFContours(const std::vector< double > &aRowValues, const std::vector< double > &aColValues, const std::vector< Point > &aVarValues, size_t aVarIndex)
Write the scenario editor output if requested.
Definition HorizontalMapFunction.cpp:1855
double mTargetAltMin
Definition HorizontalMapFunction.hpp:222
double mSensorPlatformYaw
Definition HorizontalMapFunction.hpp:214
void ConvertCartesianToSpherical(double aDownRange, double aCrossRange, double &aLatitude, double &aLongitude)
Given a down range and cross range value from the sensor, compute the equivalent latitude and longitu...
Definition HorizontalMapFunction.cpp:891
HorizontalMapFunction(const WsfScenario &aScenario)
Definition HorizontalMapFunction.cpp:56
std::string mCrossRangeUnits
Definition HorizontalMapFunction.hpp:245
bool mTargetAltRangeAGL
Definition HorizontalMapFunction.hpp:225
Target mTarget
Definition HorizontalMapFunction.hpp:219
void WriteDefendedAreaReport(const std::vector< double > &aAreaByPd)
Write the defended area report if requested.
Definition HorizontalMapFunction.cpp:1243
bool LoopOverTargetPitch(size_t aPdVarIndex)
Definition HorizontalMapFunction.cpp:321
void ConvertSphericalToCartesian(double aLatitude, double aLongitude, double &aDownRange, double &aCrossRange)
Given a latitude and longitude, compute the equivalent down range and cross range values.
Definition HorizontalMapFunction.cpp:910
std::vector< ContourLevel > mContourLevels
Definition HorizontalMapFunction.hpp:269
double mHeading
Definition HorizontalMapFunction.hpp:251
std::string mPdMapFile
Definition HorizontalMapFunction.hpp:260
void WriteKML_File(const std::vector< double > &aRowValues, const std::vector< double > &aColValues, const std::vector< Point > &aVarValues, size_t aVarIndex)
Write the KML output if requested.
Definition HorizontalMapFunction.cpp:1463
std::string GetPdMapFileJsonMetadata() const
Definition HorizontalMapFunction.cpp:2346
std::string mGnuPlotFile
Definition HorizontalMapFunction.hpp:258
double mCenterLon
Definition HorizontalMapFunction.hpp:253
void WriteGnuPlotPlayerFile()
Write output gnuplot player location output.
Definition HorizontalMapFunction.cpp:1401
std::vector< double > Point
The list of values at a specified sample point.
Definition HorizontalMapFunction.hpp:30
static void GreatCircleHeadingAndDistance(double aBegLat, double aBegLon, double aEndLat, double aEndLon, double &aHeading, double &aDistance)
static const double cUNDEFINED
Definition HorizontalMapFunction.hpp:32
bool ProcessTargetRegion(UtInput &aInput)
Definition HorizontalMapFunction.cpp:1150
std::string mWSF_File
Definition HorizontalMapFunction.hpp:268
AnalysisMapOptions mAnalysisMapOptions
Definition HorizontalMapFunction.hpp:273
bool LoopOverTargetAltitude(size_t aPdVarIndex)
Definition HorizontalMapFunction.cpp:294
bool Execute(WsfSimulation &aSimulation) override
Definition HorizontalMapFunction.cpp:129
SelectorList mExclusionList
Definition HorizontalMapFunction.hpp:276
double mSensorPlatformPitch
Definition HorizontalMapFunction.hpp:215
bool LoopOverTargetRoll(size_t aPdVarIndex)
Definition HorizontalMapFunction.cpp:349
size_t mModeIndex
Definition HorizontalMapFunction.hpp:218
bool InSelectorList(WsfSensor *aSensorPtr, const SelectorList &aSelectorList)
Definition HorizontalMapFunction.cpp:1114
double mLonMax
Definition HorizontalMapFunction.hpp:235
std::string mModeName
Definition HorizontalMapFunction.hpp:217
void WriteSeditContours(const std::vector< double > &aRowValues, const std::vector< double > &aColValues, const std::vector< Point > &aVarValues, size_t aVarIndex)
Write the scenario editor output if requested.
Definition HorizontalMapFunction.cpp:1730
std::string mShapefile
Definition HorizontalMapFunction.hpp:266
std::vector< WsfSensor * > mSensors
Definition HorizontalMapFunction.hpp:279
void ReadSelector(UtInput &aInput, SelectorList &aSelectorList)
Definition HorizontalMapFunction.cpp:1208
double mLonMin
Definition HorizontalMapFunction.hpp:234
void WritePdMapFile(const std::vector< double > &aRowValues, const std::vector< double > &aColValues, const std::vector< Point > &aVarValues, size_t aVarIndex)
Write the PdMap output if requested.
Definition HorizontalMapFunction.cpp:1656
double mCrossRangeMax
Definition HorizontalMapFunction.hpp:243
void WriteTiffFile(const std::vector< double > &aRowValues, const std::vector< double > &aColValues, const std::vector< Point > &aVarValues) const
Definition HorizontalMapFunction.cpp:2292
bool mLineOfSightMasking
Definition HorizontalMapFunction.hpp:227
std::string mContourVariable
Definition HorizontalMapFunction.hpp:270
void WriteShapefile(const std::vector< double > &aRowValues, const std::vector< double > &aColValues, const std::vector< Point > &aVarValues, size_t aVarIndex)
Write the shapefile output if requested.
Definition HorizontalMapFunction.cpp:2023
bool mAutomaticTargetCueing
Definition HorizontalMapFunction.hpp:226
size_t mOutputColumnLimit
Definition HorizontalMapFunction.hpp:264
std::string mDownRangeUnits
Definition HorizontalMapFunction.hpp:241
WsfStringId mTargetPlatformId
Definition HorizontalMapFunction.hpp:229
WsfSimulation * mSimulationPtr
Definition HorizontalMapFunction.hpp:212
std::string mDefendedAreaReportFile
Definition HorizontalMapFunction.hpp:271
double mDownRangeMax
Definition HorizontalMapFunction.hpp:239
double mLatMin
Definition HorizontalMapFunction.hpp:231
double mLatMax
Definition HorizontalMapFunction.hpp:232
double mDownRangeMin
Definition HorizontalMapFunction.hpp:238
std::string mHeaderLine3
Definition HorizontalMapFunction.hpp:263
bool mTargetAltAGL
Definition HorizontalMapFunction.hpp:221
bool mFirstWrite
Definition HorizontalMapFunction.hpp:283
std::string mKML_File
Definition HorizontalMapFunction.hpp:265
double mDownRangeStep
Definition HorizontalMapFunction.hpp:240
void WriteAnalysisMapFile(const std::vector< double > &aRowValues, const std::vector< double > &aColValues, const std::vector< Point > &aVarValues, size_t aVarIndex)
Definition HorizontalMapFunction.cpp:2173
double mTargetAltStep
Definition HorizontalMapFunction.hpp:224
bool mUseTM_Projection
Definition HorizontalMapFunction.hpp:256
double mLonStep
Definition HorizontalMapFunction.hpp:236
bool ProcessInput(UtInput &aInput) override
Process the horizontal_map input block.
Definition HorizontalMapFunction.cpp:596
virtual void WriteCustomOutputFormats(const std::vector< double > &aRowValues, const std::vector< double > &aColValues, const std::vector< Point > &aVarValues, size_t aVarIndex)
Definition HorizontalMapFunction.hpp:203
bool BuildContours(size_t aPdVarIndex)
Definition HorizontalMapFunction.cpp:377
double mTargetAlt
Definition HorizontalMapFunction.hpp:220
MapPlotFunction()=default
Definition SupTMProjection.hpp:18
Definition Target.hpp:27
Platforms represent a entity within the simulation.
Definition WsfPlatform.hpp:115
Contains the data required to create a simulation, and acts as the entry point for input file process...
Definition WsfScenario.hpp:111
Definition WsfSensor.hpp:92
The main controller for a simulation.
Definition WsfSimulation.hpp:109
A color rule for analysis map output.
Definition HorizontalMapFunction.hpp:119
double mMaxValue
Definition HorizontalMapFunction.hpp:126
double mMinValue
Definition HorizontalMapFunction.hpp:125
bool operator<(const ColorRange &aRhs) const
Definition HorizontalMapFunction.hpp:120
UtColor mColor
Definition HorizontalMapFunction.hpp:127
Definition HorizontalMapFunction.hpp:108
std::string mUnitsStr
Definition HorizontalMapFunction.hpp:133
AnalysisMapOptions()
Definition HorizontalMapFunction.hpp:109
std::string mDataTitleStr
Definition HorizontalMapFunction.hpp:132
std::vector< ColorRange > mColorRanges
Definition HorizontalMapFunction.hpp:131
std::string mFileName
Definition HorizontalMapFunction.hpp:130
A contour level for sedit contour level output.
Definition HorizontalMapFunction.hpp:56
int mLineWidth
Definition HorizontalMapFunction.hpp:59
int mLineStyle
Definition HorizontalMapFunction.hpp:60
double mLevel
Definition HorizontalMapFunction.hpp:57
UtColor mLineColor
Definition HorizontalMapFunction.hpp:58
bool operator()(const Point &p1, const Point &p2)
Definition HorizontalMapFunction.hpp:48
PointCompare(size_t aVarIndex)
Definition HorizontalMapFunction.hpp:43
Copyrights Multiple, All Rights Reserved