1 %module gpstk 2 3 %{ 4 // The header includes are kept in a separate file so they can be used 5 // to build other swig modules 6 #include "gpstk_swig.hpp" 7 using namespace gpstk; 8 %} 9 10 11 // ============================================================= 12 // Section 1: C++ template containers & typedefs 13 // ============================================================= 14 %feature("autodoc", "1"); 15 %include "doc/doc.i" 16 %include "std_string.i" 17 %include "std_vector.i" 18 %include "std_pair.i" 19 %include "std_map.i" 20 %include "std_list.i" 21 %include "std_set.i" 22 %include "std_multimap.i" 23 %include "stdint.i" 24 25 // ============================================================= 26 // Section 1b: Enumerations 27 // ============================================================= 28 // Put these enum definitions near the top so that SWIG knows that they're 29 // enums, otherwise it will generate code treating them as objects. 30 31 // The gpstk::StringUtils generate a bunch of shadowing warnings, since SWIG can't tell them apart. 32 // This may be fixed in SWIG 4.0. 33 %ignore gpstk::StringUtils::asString; 34 35 %include "gpstk_enum_typemaps.i" 36 37 // Some enumerations don't have non-colliding string-conversion method names. Can't use StringUtils::asString() 38 %include "SatelliteSystem.hpp" 39 %include "CarrierBand.hpp" 40 %include "TrackingCode.hpp" 41 %include "ObservationType.hpp" 42 %include "NavType.hpp" 43 %include "TimeSystem.hpp" 44 %include "ReferenceFrame.hpp" 45 46 // This code allows us to turn C++ enums into Python enums while 47 // maintaining compatibility in SWIG bindings. We specifically use an 48 // IntEnum class in Python to allow the implicit conversion to int 49 // when calling C++ code from Python, as SWIG treats the enums as ints 50 // when generating code. 51 /** @note During the implementation of this code, Python would 52 * commonly issue an exception with the text "Wrong number or type of 53 * arguments for overloaded function". This turned out to be caused 54 * by SWIG not having knowledge of the C++ enumeration's definition 55 * before generating code to use it, thus resulting in the enumeration 56 * being handled like an object. To resolve this issue, we have 57 * inline forward declarations for the enums at the top of this 58 * file. 59 * However, this must occur _after_ the std*.i files are included, or it won't 60 * be able to handle things like python string conversions. */ 61 %pythoncode %{ 62 from enum import IntEnum 63 def renameEnums(prefix): 64 tmpD = {k:v for k,v in globals().items() if k.startswith(prefix+'_')} 65 for k,v in tmpD.items(): 66 del globals()[k] 67 tmpD = {k[len(prefix)+1:]:v for k,v in tmpD.items()} 68 globals()[prefix] = IntEnum(prefix,tmpD) 69 globals()[prefix].__str__ = lambda x: str(x.name) 70 # Turn the gpstk.SatelliteSystem_* constants into a Python enum 71 renameEnums('SatelliteSystem') 72 renameEnums('CarrierBand') 73 renameEnums('TrackingCode') 74 renameEnums('ObservationType') 75 renameEnums('NavType') 76 renameEnums('TimeSystem') 77 renameEnums('ReferenceFrame') 78 del renameEnums 79 del IntEnum 80 %} 81 82 83 84 // Several clases have specifc .i files that 85 // may override this 86 %rename(__str__) *::asString() const; 87 88 // Ignores on things we can't wrap 89 %ignore *::dump; // takes a stream as a parameter 90 %ignore operator<<; 91 %ignore operator>>; 92 %ignore *::operator<<; 93 %ignore *::operator>>; 94 %ignore *::operator=; 95 %ignore *::operator++; 96 %ignore *::operator--; 97 98 %include "ValidType.hpp" 99 %include "gpstk_typemaps.i" 100 %include "STLTemplates.i" 101 %include "STLHelpers.i" 102 %include "gpstk_templates.i" 103 104 %include "exception.i" 105 %exceptionclass Exception; 106 %rename(__str__) gpstk::Exception::what() const; 107 %include "Exception.hpp" 108 %include "FFStreamError.hpp" 109 %include "GPSTkException.i" 110 111 112 // ============================================================= 113 // Section 2: Time classes 114 // ============================================================= 115 %rename (toString) *::operator std::string() const; 116 %rename(toCommonTime) *::convertToCommonTime() const; 117 %ignore *::operator CommonTime() const; 118 119 120 %include "TimeTag.hpp" 121 %include "TimeConstants.hpp" 122 123 // Long doubles are used in several interfaces but 124 // swig really doesn't handle them 125 %apply double { long double }; 126 127 %ignore gpstk::CommonTime::get; // takes non-const values as parameters for output 128 %include "CommonTime.hpp" 129 %include "Week.hpp" 130 %include "WeekSecond.hpp" 131 %feature("notabstract") UnixTime; 132 %include "UnixTime.hpp" 133 %feature("notabstract") SystemTime; 134 %include "SystemTime.hpp" 135 %feature("notabstract") ANSITime; 136 %include "ANSITime.hpp" 137 %feature("notabstract") CivilTime; 138 %ignore gpstk::CivilTime::MonthNames; 139 %ignore gpstk::CivilTime::MonthAbbrevNames; 140 %include "CivilTime.hpp" 141 %include "GPSZcount.hpp" 142 %include "GPSWeek.hpp" 143 %feature("notabstract") GPSWeekSecond; 144 %include "GPSWeekSecond.hpp" 145 %feature("notabstract") GPSWeekZcount; 146 %include "GPSWeekZcount.hpp" 147 %feature("notabstract") JulianDate; 148 %include "JulianDate.hpp" 149 %feature("notabstract") BDSWeekSecond; 150 %include "BDSWeekSecond.hpp" 151 %feature("notabstract") GALWeekSecond; 152 %include "GALWeekSecond.hpp" 153 %feature("notabstract") QZSWeekSecond; 154 %include "QZSWeekSecond.hpp" 155 %feature("notabstract") MJD; 156 %include "MJD.hpp" 157 %feature("notabstract") YDSTime; 158 %include "YDSTime.hpp" 159 %ignore gpstk::scanTime(TimeTag& btime, const std::string& str, const std::string& fmt); 160 %ignore gpstk::scanTime(CommonTime& btime, const std::string& str, const std::string& fmt); 161 %ignore gpstk::mixedScanTime(CommonTime& btime, const std::string& str, const std::string& fmt); 162 163 %include "TimeString.hpp" 164 %include "TimeString.i" 165 %include "TimeSystemCorr.hpp" 166 167 168 // ============================================================= 169 // Section 3: General/Utils classes 170 // ============================================================= 171 // Utils stuff 172 %include "gps_constants.hpp" 173 %include "SatID.hpp" 174 %include "SatID.i" 175 %include "ObsID.hpp" 176 %include "ObsID.i" 177 %include "NavID.hpp" 178 %include "NavID.i" 179 %ignore gpstk::SV_ACCURACY_GLO_INDEX; // wrapper added in GPS_URA.i 180 %include "GNSSconstants.hpp" 181 %include "DeprecatedConsts.hpp" 182 %include "FreqConsts.hpp" 183 %ignore gpstk::Triple::operator[](const size_t index); 184 %ignore gpstk::Triple::operator()(const size_t index); 185 %ignore gpstk::Triple::operator*(double right, const Triple& rhs); 186 %ignore gpstk::Triple::theArray; 187 %include "Triple.hpp" 188 %include "Triple.i" 189 190 %include "EllipsoidModel.hpp" 191 %include "Xvt.hpp" 192 193 %ignore gpstk::Position::convertSphericalToCartesian(const Triple& tpr, Triple& xyz) throw(); 194 %ignore gpstk::Position::convertCartesianToSpherical(const Triple& xyz, Triple& tpr) throw(); 195 %ignore gpstk::Position::convertCartesianToGeodetic(const Triple& xyz, Triple& llh, const double A, const double eccSq) throw(); 196 %ignore gpstk::Position::convertGeodeticToCartesian(const Triple&, llh, Triple& xyz, const double A, const double eccSq) throw(); 197 %ignore gpstk::Position::convertCartesianToGeocentric(const Triple& xyz, Triple& llr) throw(); 198 %ignore gpstk::Position::convertGeocentricToCartesian(const Triple& llr, Triple& xyz) throw(); 199 %ignore gpstk::Position::convertGeocentricToGeodetic(const Triple& llr, Triple& geodeticllr, const double A, const double eccSq) throw(); 200 %ignore gpstk::Position::convertGeodeticToGeocentric(const Triple& geodeticllh, Triple& llr, const double A, const double eccSq) throw(); 201 %include "Position.hpp" 202 %include "Position.i" 203 204 %include "convhelp.hpp" 205 %ignore gpstk::VectorBase::operator[] (size_t i) const; 206 %ignore gpstk::VectorBase::operator() (size_t i) const; 207 %ignore gpstk::RefVectorBaseHelper::zeroTolerance; 208 %ignore gpstk::RefVectorBaseHelper::perator[] (size_t i); 209 %ignore gpstk::RefVectorBaseHelper::operator() (size_t i); 210 %ignore gpstk::RefVectorBaseHelper::zeroize(); 211 %include "VectorBase.hpp" 212 %include "Vector.i" 213 %include "DataStatus.hpp" 214 215 216 // ============================================================= 217 // Section 4: "XvtStore and friends" 218 // ============================================================= 219 // Renames on a few commonly used operators 220 %rename (toEngEphemeris) *::operator EngEphemeris() const; 221 %rename (toGalEphemeris) *::operator GalEphemeris() const; 222 %rename (toGloEphemeris) *::operator GloEphemeris() const; 223 %rename (toAlmOrbit) *::operator AlmOrbit() const; 224 225 %include "AstronomicalFunctions.hpp" 226 %include "PZ90Ellipsoid.hpp" 227 %include "WGS84Ellipsoid.hpp" 228 229 %include "XvtStore.hpp" 230 %template(XvtStore_SatID) gpstk::XvtStore<gpstk::SatID>; 231 %template(XvtStore_string) gpstk::XvtStore<std::string>; 232 233 %include "gpstkplatform.h" 234 %include "FFStreamError.hpp" 235 %include "FileStore.hpp" 236 %include "FFData.hpp" 237 %include "EngNav.hpp" 238 %include "YumaBase.hpp" 239 // This is to silence warning about not knowing about the fstream base class 240 namespace std { class fstream {}; } 241 %include "FFStream.hpp" 242 %include "FFTextStream.hpp" 243 %include "AlmOrbit.hpp" 244 %include "YumaHeader.hpp" 245 %ignore gpstk::EngAlmanac::getUTC; 246 %include "EngAlmanac.hpp" 247 248 %include "OrbAlmStore.hpp" 249 %include "OrbElemBase.hpp" 250 %include "OrbElem.hpp" 251 %include "OrbElemStore.hpp" 252 %include "AlmOrbit.hpp" 253 %include "YumaStream.hpp" 254 %include "YumaData.hpp" 255 %include "GPSAlmanacStore.hpp" 256 %template(FileStore_YumaHeader) gpstk::FileStore<gpstk::YumaHeader>; 257 %include "YumaAlmanacStore.hpp" 258 259 %include "SVNumXRef.hpp" 260 //%include "RinexSatID.hpp" 261 262 %ignore gpstk::SV_ACCURACY_GPS_MIN_INDEX; 263 %ignore gpstk::SV_ACCURACY_GPS_NOMINAL_INDEX; 264 %ignore gpstk::SV_ACCURACY_GPS_MAX_INDEX; 265 %ignore gpstk::SV_CNAV_ACCURACY_GPS_MIN_INDEX; 266 %ignore gpstk::SV_CNAV_ACCURACY_GPS_NOM_INDEX; 267 %ignore gpstk::SV_CNAV_ACCURACY_GPS_MAX_INDEX; 268 %include "GPS_URA.hpp" 269 %include "GPS_URA.i" 270 271 %include "BrcClockCorrection.hpp" 272 %include "BrcKeplerOrbit.hpp" 273 %include "EphemerisRange.hpp" 274 // %include "EphReader.hpp" 275 276 // Ephemeris: 277 %include "OrbitEph.hpp" 278 %include "BDSEphemeris.hpp" 279 %include "EngEphemeris.hpp" 280 %include "GalEphemeris.hpp" 281 %include "GloEphemeris.hpp" 282 %include "GPSEphemeris.hpp" 283 %include "QZSEphemeris.hpp" 284 285 // RINEX format: 286 %include "RinexSatID.hpp" 287 %include "RinexObsID.hpp" 288 %include "RinexSatID.i" 289 %include "RinexObsID.i" 290 // RINEX obs: 291 %include "RinexObsBase.hpp" 292 %include "RinexObsHeader.hpp" 293 %include "RinexObsData.hpp" 294 %include "RinexObsStream.hpp" 295 // RINEX nav: 296 %include "RinexNavBase.hpp" 297 %include "RinexNavHeader.hpp" 298 %include "RinexNavStream.hpp" 299 %include "RinexNavData.hpp" 300 // RINEX meteorological: 301 %include "RinexMetBase.hpp" 302 %include "RinexMetHeader.hpp" 303 %include "RinexMetStream.hpp" 304 305 %ignore gpstk::RinexMetData::data; 306 %include "RinexMetData.hpp" 307 %include "RinexMetData.i" 308 309 // RINEX 3 nav: 310 %include "Rinex3NavBase.hpp" 311 %include "Rinex3NavHeader.hpp" 312 %include "Rinex3NavStream.hpp" 313 %include "Rinex3NavData.hpp" 314 %include "OrbElemRinex.hpp" 315 316 // RINEX 3 clock/obs: 317 %include "RinexDatum.hpp" 318 %include "Rinex3ClockBase.hpp" 319 %include "Rinex3ObsBase.hpp" 320 321 %include "Rinex3ObsHeader.i" 322 323 %include "Rinex3ObsData.hpp" 324 %include "Rinex3ObsStream.hpp" 325 %include "Rinex3ClockHeader.hpp" 326 %include "Rinex3ClockData.hpp" 327 %include "Rinex3ClockStream.hpp" 328 %include "Rinex3EphemerisStore.hpp" 329 330 // Ephemeris stores: 331 %include "OrbitEphStore.hpp" 332 %include "BDSEphemerisStore.hpp" 333 %include "GalEphemerisStore.hpp" 334 %include "GloEphemerisStore.hpp" 335 %include "GPSEphemerisStore.hpp" 336 %include "QZSEphemerisStore.hpp" 337 %template (FileStore_RinexNavHeader) gpstk::FileStore<gpstk::RinexNavHeader>; 338 %include "RinexEphemerisStore.hpp" 339 340 // SP3 format: 341 %include "TabularSatStore.hpp" 342 %include "ClockSatStore.hpp" 343 %include "SP3Base.hpp" 344 %include "SP3SatID.hpp" 345 %include "SP3Header.hpp" 346 %include "SP3Data.hpp" 347 %include "SP3Stream.hpp" 348 %include "PositionSatStore.hpp" 349 %include "SP3EphemerisStore.hpp" 350 %include "RinexUtilities.hpp" 351 352 // SEM format: 353 %include "SEMBase.hpp" 354 %include "SEMHeader.hpp" 355 %include "SEMStream.hpp" 356 %include "SEMData.hpp" 357 %template(FileStore_SEMHeader) gpstk::FileStore<gpstk::SEMHeader>; 358 %include "SEMAlmanacStore.hpp" 359 360 %include "ObsEpochMap.hpp" 361 %include "WxObsMap.hpp" 362 %include "TropModel.hpp" 363 %include "GCATTropModel.hpp" 364 %include "GGHeightTropModel.hpp" 365 %include "GGTropModel.hpp" 366 %include "MOPSTropModel.hpp" 367 %include "NBTropModel.hpp" 368 %include "NeillTropModel.hpp" 369 %include "SaasTropModel.hpp" 370 %include "SimpleTropModel.hpp" 371 %include "PRSolutionLegacy.hpp" 372 %ignore gpstk::Expression::print(std::ostream& ostr) const; 373 %include "Expression.hpp" 374 375 %include "FFBinaryStream.hpp" 376 %include "AshtechStream.hpp" 377 %include "AshtechData.hpp" 378 %include "AshtechALB.hpp" 379 %include "AshtechEPB.hpp" 380 %include "AshtechMBEN.hpp" 381 %include "AshtechPBEN.hpp" 382 383 %include "MoonPosition.hpp" 384 %include "SunPosition.hpp" 385 %include "PoleTides.hpp" 386 %include "SolidTides.hpp" 387 388 // PosSol 389 %include "Combinations.hpp" 390 %include "PRSolution.hpp" 391 392 // Ionosphere Model 393 %include "IonoModel.hpp" 394 395 // Geomatics: 396 %include "Geomatics.i" 397 %include "SunEarthSatGeometry.hpp" 398 399 // OrbSysGPS 400 %include "OrbSysStore.hpp" 401 %include "OrbData.hpp" 402 %include "OrbDataSys.hpp" 403 %include "OrbSysGpsC.hpp" 404 %include "OrbSysGpsC_30.hpp" 405 // %include "OrbSysGpsC_32.hpp" 406 // %include "OrbSysGpsC_33.hpp" 407 %include "OrbSysGpsL.hpp" 408 // %include "OrbSysGpsL_51.hpp" 409 // %include "OrbSysGpsL_52.hpp" 410 // %include "OrbSysGpsL_55.hpp" 411 %include "OrbDataUTC.hpp" 412 %include "OrbSysGpsL_56.hpp" 413 // %include "OrbSysGpsL_63.hpp" 414 %include "OrbSysGpsL_Reserved.hpp" 415 %include "PackedNavBits.hpp" 416 %include "OrbDataSysFactory.hpp" 417 418 // v 2.0.12 required for KLOBUCHAR IONO MODEL 419 #define KLOBUCHAR_SUPPORT (SWIG_VERSION >= 0x020012 ? True : False) 420 #if SWIG_VERSION >= 0x020012 421 %inline %{ cast_to_OrbSysGpsC_30(gpstk::OrbDataSys * ods)422 gpstk::OrbSysGpsC_30* cast_to_OrbSysGpsC_30(gpstk::OrbDataSys* ods) { 423 return static_cast<gpstk::OrbSysGpsC_30*>(ods); 424 } cast_to_OrbSysGpsL_56(gpstk::OrbDataSys * ods)425 gpstk::OrbSysGpsL_56* cast_to_OrbSysGpsL_56(gpstk::OrbDataSys* ods) { 426 return static_cast<gpstk::OrbSysGpsL_56*>(ods); 427 } 428 %} 429 // Include to generate swig::trait::typename() 430 %{ 431 namespace swig { 432 template <> struct traits<gpstk::OrbDataSys> { 433 typedef pointer_category category; 434 static const char* type_name() {return "gpstk::OrbDataSys";} 435 }; 436 } 437 %} 438 439 // SWIG out the msgMap in gpstk::OrbSysStore 440 %template (TimeMsgMap) std::map<gpstk::CommonTime, gpstk::OrbDataSys* >; 441 %template (UIDMsgMap) std::map<uint16_t, std::map<gpstk::CommonTime, gpstk::OrbDataSys* > >; 442 %template (NavIDMsgMap) std::map<gpstk::NavID, std::map<uint16_t, std::map<gpstk::CommonTime, gpstk::OrbDataSys* > > >; 443 %template (SatIDMsgMap) std::map<gpstk::SatID, std::map<gpstk::NavID, std::map<uint16_t, std::map<gpstk::CommonTime, gpstk::OrbDataSys* > > > >; 444 #endif 445 446 // Encapsulation of many the __str__, __getitem__, etc. functions to avoid clutter. 447 // When the only change to a class is adding a simple wrapper, add to pythonfunctions 448 // instead of creating another small file. 449 %include "pythonfunctions.i" 450 %include "FileIO.i" 451 452 // Note that the path functions really don't make sense outside of the build 453 // environment 454 %include "build_config.h" 455 456 %include "ord.i" 457 458 459 %pythoncode %{ 460 # clean-up the dir listing by removing *_swigregister. 461 import gpstk 462 stuff=None 463 to_remove=[] 464 for stuff in locals(): 465 if stuff.endswith('_swigregister'): 466 to_remove.append(stuff) 467 for stuff in to_remove: 468 del locals()[stuff] 469 del locals()['stuff'] 470 del locals()['to_remove'] 471 %} 472