![]() |
VR-Forces 4.0.4 Class Documentation
|
00001 /******************************************************************************* 00002 ** Copyright (c) 2005 MAK Technologies, Inc. 00003 ** All rights reserved. 00004 *******************************************************************************/ 00005 /******************************************************************************* 00006 ** $RCSfile: shapeProjectionInformation.h,v $ $Revision: 1.12 $ $State: Exp $ 00007 *******************************************************************************/ 00008 #ifndef shapeProjectionInformation_H_ 00009 #define shapeProjectionInformation_H_ 00010 00011 #include "shape/shapeDefines.h" 00012 #include <vlutil/vlString.h> 00013 #include <vlutil/vlConfig.h> 00014 #include <list> 00015 #include <map> 00016 00017 class DtShapeProjectionInformation; 00018 class DtPoint; 00019 class Coordinate_System; 00020 class DtShapeInitializer; 00021 class DtShapeVectorInitializer; 00022 class DtFilename; 00023 00024 typedef std::list<DtShapeProjectionInformation*> DtShapeProjectionInformationList; 00025 00026 class DT_DLL_shape DtShapeProjectionInformation 00027 { 00028 public: 00029 DtShapeProjectionInformation(); 00030 DtShapeProjectionInformation(const DtString& s); 00031 00032 virtual ~DtShapeProjectionInformation(); 00033 00034 virtual bool load(FILE*); 00035 virtual bool valueFor(const DtString& key, DtString& value) const; 00036 virtual void parseBracketString(const DtString& bracketString); 00037 00038 DtString key() const; 00039 DtString value() const; 00040 void setValue(const DtString&); 00041 const DtShapeProjectionInformationList& children() const; 00042 00043 virtual void add(const DtString& key, const DtString& val); 00044 00045 virtual void addKeyword(const DtString& kw, const DtString& expectedValues); 00046 void initializeKeywords(); 00047 00048 protected: 00049 virtual DtString readKeyword(FILE* f); 00050 virtual bool parseContents(FILE* f, const DtString& expected); 00051 virtual DtString parseString(FILE* f); 00052 virtual DtString allBetweenBrackets(FILE* f); 00053 virtual void addChildren(FILE* f); 00054 virtual void parseKeyValuePair(); 00055 00056 protected: 00057 DtString myKey; 00058 00059 DtString myValue; 00060 00061 DtString mySubKey; 00062 00063 DtShapeProjectionInformationList myChildren; 00064 00065 std::map<DtString, DtString> myKeywords; 00066 }; 00067 00068 class DT_DLL_shape DtShapeProjection 00069 { 00070 public: 00071 DtShapeProjection(); 00072 virtual ~DtShapeProjection(); 00073 00074 virtual bool load(FILE*, const DtShapeInitializer*); 00075 virtual bool load(FILE*, const DtShapeVectorInitializer*); 00076 virtual bool valueFor(const DtString& key, DtString& value) const; 00077 00078 static DtShapeProjection* create(); 00079 00080 // Returns true if the projection is a transverse mercator projection. It will then convert 00081 // the TM value to geodetic. The projection will be considered a TM projection if it is 00082 // projected and has both a central meridian and scale factor defined 00083 virtual bool isTransverseMercator() const; 00084 virtual bool isProjected() const; 00085 00086 virtual void add(const DtString& key, const DtString& val); 00087 Coordinate_System* coordinateSystem() { return myCoordinateSystem; }; 00088 virtual Coordinate_System* createCoordinateSystem() const; 00089 00090 // Creates a new coordinate system based on contents of a given projection (.prj) file. 00091 // Caller is responsible for deleting the memory associated with the coordinate system. 00092 static Coordinate_System* createCoordinateSystem(const DtFilename& projectionFile); 00093 00094 public: 00095 // Given the projection, convert from source projection to geodetic (degrees, not radians). This 00096 // supports mappings from keywords (string) to coordinate system types. Currently supported type 00097 // is only UTM. Note the point p must be in the source mapping. If no mapping exists, the point 00098 // is not modified 00099 virtual bool convertPointFromProjectionToGeodetic(DtPoint& p) const; 00100 00101 void setInitializer(const DtShapeInitializer*); 00102 void setVectorInitializer(const DtShapeVectorInitializer*); 00103 00104 protected: 00105 DtShapeProjectionInformation myShapeProjectionInformation; 00106 00107 mutable Coordinate_System* myCoordinateSystem; 00108 const DtShapeInitializer* myInitializer; 00109 const DtShapeVectorInitializer* myVectorInitializer; 00110 }; 00111 00112 typedef DtShapeProjection* (*DtShapeProjectionCreatorFcn)(); 00113 00114 inline void DtShapeProjection::setInitializer(const DtShapeInitializer* i) 00115 { 00116 myInitializer = i; 00117 } 00118 00119 inline void DtShapeProjection::setVectorInitializer(const DtShapeVectorInitializer* i) 00120 { 00121 myVectorInitializer = i; 00122 } 00123 00124 inline DtString DtShapeProjectionInformation::key() const 00125 { 00126 return myKey; 00127 } 00128 00129 inline DtString DtShapeProjectionInformation::value() const 00130 { 00131 return myValue; 00132 } 00133 00134 inline void DtShapeProjectionInformation::setValue(const DtString& val) 00135 { 00136 myValue = val; 00137 } 00138 00139 inline const DtShapeProjectionInformationList& DtShapeProjectionInformation::children() const 00140 { 00141 return myChildren; 00142 } 00143 00144 #endif