OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Protected Attributes | List of all members
ossimGeographicAnnotationGrid Class Reference

#include <ossimGeographicAnnotationGrid.h>

Inheritance diagram for ossimGeographicAnnotationGrid:
ossimAnnotationObject ossimObject ossimReferenced

Public Member Functions

 ossimGeographicAnnotationGrid ()
 
virtual void draw (ossimRgbImage &anImage) const
 
virtual void setViewProjectionInformation (ossimMapProjection *projection, const ossimGrect &boundingGroundRect)
 
virtual void getBoundingRect (ossimDrect &rect) const
 
virtual void computeBoundingRect ()
 
virtual std::ostream & print (std::ostream &out) const
 Generic print method. More...
 
- Public Member Functions inherited from ossimAnnotationObject
virtual ~ossimAnnotationObject ()
 
 ossimAnnotationObject (ossim_uint8 r=255, ossim_uint8 g=255, ossim_uint8 b=255, ossim_uint8 thickness=1)
 
virtual void applyScale (double x, double y)=0
 
virtual void applyScale (const ossimDpt &scale)
 
virtual bool intersects (const ossimDrect &rect) const =0
 
virtual ossimAnnotationObjectgetNewClippedObject (const ossimDrect &rect) const =0
 
virtual ossimDrect getBoundingRect () const
 
virtual void setColor (ossim_uint8 r, ossim_uint8 g, ossim_uint8 b)
 
void getColor (ossim_uint8 &r, ossim_uint8 &g, ossim_uint8 &b) const
 
ossim_uint8 getThickness () const
 
virtual void setThickness (ossim_uint8 thickness)
 
virtual bool isPointWithin (const ossimDpt &imagePoint) const
 
virtual bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 Saves the current state of this object. More...
 
virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 Method to the load (recreate) the state of an object from a keyword list. More...
 
virtual ossimString getName () const
 
virtual void setName (const ossimString &name)
 
ossim_uint32 getId () const
 
virtual ossim_uint32 setId ()
 
- Public Member Functions inherited from ossimObject
 ossimObject ()
 
virtual ~ossimObject ()
 
virtual ossimObjectdup () const
 
virtual ossimString getShortName () const
 
virtual ossimString getLongName () const
 
virtual ossimString getDescription () const
 
virtual ossimString getClassName () const
 
virtual RTTItypeid getType () const
 
virtual bool canCastTo (ossimObject *obj) const
 
virtual bool canCastTo (const RTTItypeid &id) const
 
virtual bool canCastTo (const ossimString &parentClassName) const
 
virtual bool isEqualTo (const ossimObject &obj, ossimCompareType compareType=OSSIM_COMPARE_FULL) const
 
virtual void accept (ossimVisitor &visitor)
 
- Public Member Functions inherited from ossimReferenced
 ossimReferenced ()
 
 ossimReferenced (const ossimReferenced &)
 
ossimReferencedoperator= (const ossimReferenced &)
 
void ref () const
 increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
void unref () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unref_nodelete () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
int referenceCount () const
 

Protected Attributes

ossimRefPtr< ossimMapProjectiontheViewProjection
 
ossimGrect theGroundRect
 
ossimDrect theBoundingRect
 
double theDeltaLatSpacing
 
double theDeltaLonSpacing
 
- Protected Attributes inherited from ossimAnnotationObject
ossim_uint8 theRed
 
ossim_uint8 theGreen
 
ossim_uint8 theBlue
 
ossim_uint8 theThickness
 
ossimString theName
 
ossim_uint32 theId
 

Additional Inherited Members

- Static Public Member Functions inherited from ossimAnnotationObject
static ossim_uint32 getNextId ()
 
static void restIdCounter ()
 
- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 
- Static Protected Attributes inherited from ossimAnnotationObject
static ossim_uint32 theIdCounter = 0
 

Detailed Description

Definition at line 10 of file ossimGeographicAnnotationGrid.h.

Constructor & Destructor Documentation

◆ ossimGeographicAnnotationGrid()

ossimGeographicAnnotationGrid::ossimGeographicAnnotationGrid ( )

Definition at line 13 of file ossimGeographicAnnotationGrid.cpp.

15  theViewProjection(NULL),
16  theGroundRect(0,0,0,0),
17  theDeltaLatSpacing(1.0/60.0), // every minute
18  theDeltaLonSpacing(1.0/60.0)
19 {
20 }
ossimRefPtr< ossimMapProjection > theViewProjection
ossimAnnotationObject(ossim_uint8 r=255, ossim_uint8 g=255, ossim_uint8 b=255, ossim_uint8 thickness=1)

Member Function Documentation

◆ computeBoundingRect()

void ossimGeographicAnnotationGrid::computeBoundingRect ( )
virtual

Implements ossimAnnotationObject.

Definition at line 236 of file ossimGeographicAnnotationGrid.cpp.

References ossimAnnotationGdBitmapFont::getBoundingRect(), ossimDrect::height(), ossimGrect::ll(), ossimGrect::lr(), ossimDrect::lr(), ossimAnnotationGdBitmapFont::setCenterText(), theBoundingRect, theGroundRect, theViewProjection, ossimGrect::ul(), ossimDrect::ul(), ossimGrect::ur(), ossimRefPtr< T >::valid(), ossimDrect::width(), ossimMapProjection::worldToLineSample(), ossimDpt::x, and ossimDpt::y.

237 {
238  static const char* MODULE = "ossimGeographicAnnotationGrid::computeBoundingRect";
239 
241  {
242  vector<ossimDpt> points(4);
243 
248 
249  // now solve the bounding rect in view space.
250  theBoundingRect = ossimDrect(points);
251 
252  // for now we will add a border for the labelling
253  // of lat lon readouts. We need a better border
254  // computation that checks exactly what we need
255  // based on font sizes.
256  //
257  ossimDpt ul = theBoundingRect.ul();
258  ossimDpt lr = theBoundingRect.lr();
259 
260 
262  font->setCenterText(ossimDpt(0,0),"ddd@mm'ss.ssssC");
263  ossimDrect boundingRect;
264  font->getBoundingRect(boundingRect);
265  font = 0;
266 
267  theBoundingRect = ossimDrect(ul.x - boundingRect.width(),
268  ul.y - boundingRect.height(),
269  lr.x + boundingRect.width(),
270  lr.y + boundingRect.height());
271 
272  if(traceDebug())
273  {
274  CLOG << " bounding rect: " << theBoundingRect << endl;
275  }
276  }
277 }
ossimRefPtr< ossimMapProjection > theViewProjection
#define CLOG
Definition: ossimTrace.h:23
ossim_float64 width() const
Definition: ossimDrect.h:522
bool valid() const
Definition: ossimRefPtr.h:75
virtual ossimDpt worldToLineSample(const ossimGpt &worldPoint) const
const ossimDpt & ul() const
Definition: ossimDrect.h:339
double y
Definition: ossimDpt.h:165
const ossimGpt & ul() const
Definition: ossimGrect.h:252
ossimGpt ur() const
Definition: ossimGrect.h:257
ossim_float64 height() const
Definition: ossimDrect.h:517
virtual void setCenterText(const ossimDpt &center, const ossimString &text)
virtual void getBoundingRect(ossimDrect &rect) const
double x
Definition: ossimDpt.h:164
const ossimDpt & lr() const
Definition: ossimDrect.h:341
const ossimGpt & lr() const
Definition: ossimGrect.h:269
ossimGpt ll() const
Definition: ossimGrect.h:263

◆ draw()

void ossimGeographicAnnotationGrid::draw ( ossimRgbImage anImage) const
virtual

Implements ossimAnnotationObject.

Definition at line 22 of file ossimGeographicAnnotationGrid.cpp.

References ossimGpt::datum(), DBL_EPSILON, ossimAnnotationGdBitmapFont::draw(), ossimAnnotationLineObject::draw(), ossimAnnotationGdBitmapFont::getBoundingRect(), ossimRgbImage::getImageData(), ossimGrect::height(), ossimDrect::height(), ossimGpt::latd(), ossimGpt::lond(), ossimGrect::lr(), ossimAnnotationGdBitmapFont::setCenterText(), ossimAnnotationGdBitmapFont::setCenterTextPosition(), ossimRgbImage::setDrawColor(), ossimAnnotationLineObject::setLine(), ossimAnnotationGdBitmapFont::setText(), ossimAnnotationObject::theBlue, theDeltaLatSpacing, theDeltaLonSpacing, ossimAnnotationObject::theGreen, theGroundRect, ossimAnnotationObject::theRed, theViewProjection, ossimGrect::ul(), ossimGrect::ur(), ossimRefPtr< T >::valid(), ossimGrect::width(), ossimDrect::width(), ossimMapProjection::worldToLineSample(), ossimDpt::x, and ossimDpt::y.

24 {
25  if(!anImage.getImageData())
26  {
27  return;
28  }
30 
31  if((fabs(theDeltaLatSpacing) <= DBL_EPSILON)||
33  {
34  return;
35  }
36 
37 // ossimDrect imageRect = anImage.getImageData()->getImageRectangle();
38  // If the view projection exists we will use it to
39  // compute the bounding ground rect and find all lines
40  // that overlap that area in the lat and lon direction
41  // and draw them.
42  //
43  // I the projection doesn't exist we will assume that
44  // the geographic grid to generate will be 0,0 is origin
45  // -180lon and 90lat.
46  //
48  {
51 
52  line = new ossimAnnotationLineObject();
53  font = new ossimAnnotationGdBitmapFont();
54 
55  ossimDpt start;
56  ossimDpt end;
57  ossimGpt groundUpper(0,0,0,theGroundRect.ul().datum());
58  ossimGpt groundLower(0,0,0,theGroundRect.ul().datum());
59  double height = theGroundRect.height();
60  double width = theGroundRect.width();
61  double lat = theGroundRect.ul().latd();
62 // ossimDrect imageRect = anImage.getImageData()->getImageRectangle();
63  double lon;
64 
65  // used for the font spacing
66  ossimDrect boundingRect;
67 
68  // we will go across the longitudinal direction first
70  lon <= theGroundRect.ur().lond();
71  lon += theDeltaLonSpacing)
72  {
73  groundUpper.lond(lon);
74  groundUpper.latd(lat);
75  groundLower.lond(lon);
76  groundLower.latd(lat-height);
77 
78  theViewProjection->worldToLineSample(groundUpper, start);
79  theViewProjection->worldToLineSample(groundLower, end);
80 
81  line->setLine(start, end);
82  line->draw(anImage);
83  }
84  lon = theGroundRect.ul().lond();
85 
86  // now go accross longitude and place the
87  // text in.
89  lon <= theGroundRect.ur().lond();
90  lon += theDeltaLonSpacing)
91  {
92  groundUpper.lond(lon);
93  groundUpper.latd(lat);
94  groundLower.lond(lon);
95  groundLower.latd(lat-height);
96 
97  theViewProjection->worldToLineSample(groundUpper, start);
98  theViewProjection->worldToLineSample(groundLower, end);
99  font->setText(ossimDms(groundUpper.lond(), false).toString("ddd@mm'ss.ssss\"C"));
100  font->getBoundingRect(boundingRect);
101  start.y -= boundingRect.height();
102  font->setCenterTextPosition(start);
103  font->draw(anImage);
104 
105  end.y += boundingRect.height();
106  font->setCenterText(end,
107  ossimDms(groundLower.lond(), false).toString("ddd@mm'ss.ssssC"));
108  font->draw(anImage);
109  }
110  lon = theGroundRect.ul().lond();
111 
112  ossimGpt groundLeft;
113  ossimGpt groundRight;
114 
115  // Now go down lat direction
116  for(lat = theGroundRect.ul().latd()-theDeltaLatSpacing;
117  lat >= theGroundRect.lr().latd();
118  lat -= theDeltaLatSpacing)
119  {
120  groundLeft.lond(lon);
121  groundLeft.latd(lat);
122  groundRight.lond(lon+width);
123  groundRight.latd(lat);
124 
125  theViewProjection->worldToLineSample(groundLeft, start);
126  theViewProjection->worldToLineSample(groundRight, end);
127 
128  line->setLine(start, end);
129  line->draw(anImage);
130  }
131 
132  // now go down lat direction font
133  for(lat = theGroundRect.ul().latd()-theDeltaLatSpacing;
134  lat >= theGroundRect.lr().latd();
135  lat -= theDeltaLatSpacing)
136  {
137  groundLeft.lond(lon);
138  groundLeft.latd(lat);
139  groundRight.lond(lon+width);
140  groundRight.latd(lat);
141 
142  theViewProjection->worldToLineSample(groundLeft, start);
143  theViewProjection->worldToLineSample(groundRight, end);
144 
145 
146  font->setText(ossimDms(groundLeft.latd()).toString("ddd@mm'ss.ssss\"C"));
147  font->getBoundingRect(boundingRect);
148  start.x -= boundingRect.width()/2.0-1;
149  font->setCenterTextPosition(start);
150  font->draw(anImage);
151 
152  end.x += boundingRect.width()/2.0+1;
153  font->setCenterText(end,
154  ossimDms(groundRight.latd()).toString("ddd@mm'ss.ssssC"));
155  font->draw(anImage);
156  }
157 
158  line = 0;
159  font = 0;
160  }
161 }
ossimRefPtr< ossimMapProjection > theViewProjection
ossim_float64 width() const
Definition: ossimDrect.h:522
double lond() const
Will convert the radian measure to degrees.
Definition: ossimGpt.h:97
bool valid() const
Definition: ossimRefPtr.h:75
virtual void draw(ossimRgbImage &anImage) const
virtual ossimDpt worldToLineSample(const ossimGpt &worldPoint) const
ossim_float64 width() const
Returns the width of a rectangle in deg.
Definition: ossimGrect.h:247
double y
Definition: ossimDpt.h:165
double latd() const
Will convert the radian measure to degrees.
Definition: ossimGpt.h:87
const ossimDatum * datum() const
datum().
Definition: ossimGpt.h:196
virtual void draw(ossimRgbImage &anImage) const
ossimRefPtr< ossimImageData > getImageData()
Will return the image data.
virtual void setCenterTextPosition(const ossimDpt &position)
void setLine(const ossimDpt &start, const ossimDpt &end)
const ossimGpt & ul() const
Definition: ossimGrect.h:252
ossimGpt ur() const
Definition: ossimGrect.h:257
#define DBL_EPSILON
ossim_float64 height() const
Definition: ossimDrect.h:517
virtual void setCenterText(const ossimDpt &center, const ossimString &text)
virtual void getBoundingRect(ossimDrect &rect) const
void setDrawColor(ossim_uint8 r=255, ossim_uint8 g=255, ossim_uint8 b=255)
virtual void setText(const ossimString &text)
double x
Definition: ossimDpt.h:164
ossim_float64 height() const
Returns the height of a rectangle in deg.
Definition: ossimGrect.h:242
const ossimGpt & lr() const
Definition: ossimGrect.h:269

◆ getBoundingRect()

void ossimGeographicAnnotationGrid::getBoundingRect ( ossimDrect rect) const
virtual

Implements ossimAnnotationObject.

Definition at line 231 of file ossimGeographicAnnotationGrid.cpp.

References theBoundingRect.

232 {
233  rect = theBoundingRect;
234 }

◆ print()

std::ostream & ossimGeographicAnnotationGrid::print ( std::ostream &  out) const
virtual

Generic print method.

Derived classes should re-implement as they see fit.

Returns
std::ostream&

Reimplemented from ossimAnnotationObject.

Definition at line 279 of file ossimGeographicAnnotationGrid.cpp.

280 {
281  return out;
282 }

◆ setViewProjectionInformation()

void ossimGeographicAnnotationGrid::setViewProjectionInformation ( ossimMapProjection projection,
const ossimGrect boundingGroundRect 
)
virtual

We need to know what projection the view and we need to know the bounding rect for the view in geographic space. The bounding rect is there for an area of interest.

Definition at line 164 of file ossimGeographicAnnotationGrid.cpp.

References ossimGrect::clipToRect(), ossimGpt::datum(), ossimGpt::latd(), ossimGpt::lond(), ossimGrect::lr(), theDeltaLatSpacing, theDeltaLonSpacing, theGroundRect, theViewProjection, and ossimGrect::ul().

166 {
167  static const char* MODULE = "ossimGeographicAnnotationGrid::setViewProjectionInformation";
168  theViewProjection = projection;
169 
170  // set the ground and then stretch it
171  // to cover which even degree grid we are currently
172  // in.
173  theGroundRect = boundingGroundRect;
174 
175  // find the even degree grid.
176  ossimGrect rect(ossimGpt(90, -180),
177  ossimGpt(-90, 180));
178 
179  // make sure that it is within the range of the
180  // geographic grid.
181  ossimGrect clipRect = rect.clipToRect(boundingGroundRect);
182 
183  // for easier math we will shift the points so they
184  // are between 0..360Lon and 0..180Lat. This way
185  // we are working with just positive numbers
186  double upperLeftLonShift = clipRect.ul().lond() + 180;
187  double upperLeftLatShift = clipRect.ul().latd() + 90;
188  double lowerRightLonShift = clipRect.lr().lond() + 180;
189  double lowerRightLatShift = clipRect.lr().latd() + 90;
190 
191  // now find the even boundaries
192  double upperLeftLonCell = floor(upperLeftLonShift/theDeltaLonSpacing)*
194  double upperLeftLatCell = floor(upperLeftLatShift/theDeltaLatSpacing)*
196  double lowerRightLonCell = floor(lowerRightLonShift/theDeltaLonSpacing)*
198  double lowerRightLatCell = floor(lowerRightLatShift/theDeltaLatSpacing)*
200 
201  // now adjust them by 1 boundary distance.
202  upperLeftLonCell -= theDeltaLonSpacing;
203  upperLeftLatCell += theDeltaLatSpacing;
204  lowerRightLonCell += theDeltaLonSpacing;
205  lowerRightLatCell -= theDeltaLatSpacing;
206 
207  // now clamp to the range of the lat and lon
208  upperLeftLonCell = (upperLeftLonCell<0?0:upperLeftLonCell);
209  upperLeftLatCell = (upperLeftLatCell>180?180:upperLeftLatCell);
210  lowerRightLonCell = (lowerRightLonCell>360?360:lowerRightLonCell);
211  lowerRightLatCell = (lowerRightLatCell<0?0:lowerRightLatCell);
212 
213  // now shift them back into range
214  upperLeftLonCell -= 180;
215  upperLeftLatCell -= 90;
216  lowerRightLonCell -= 180;
217  lowerRightLatCell -= 90;
218 
219  const ossimDatum* datum = theGroundRect.ul().datum();
220  theGroundRect = ossimGrect(upperLeftLatCell, upperLeftLonCell,
221  lowerRightLatCell, lowerRightLonCell,
222  datum);
223 
224  if(traceDebug())
225  {
226  CLOG << "Ground Rect: " << theGroundRect << endl;
227  }
229 }
ossimRefPtr< ossimMapProjection > theViewProjection
#define CLOG
Definition: ossimTrace.h:23
double lond() const
Will convert the radian measure to degrees.
Definition: ossimGpt.h:97
double latd() const
Will convert the radian measure to degrees.
Definition: ossimGpt.h:87
const ossimDatum * datum() const
datum().
Definition: ossimGpt.h:196
ossimGrect clipToRect(const ossimGrect &rect) const
Definition: ossimGrect.h:190
const ossimGpt & ul() const
Definition: ossimGrect.h:252
const ossimGpt & lr() const
Definition: ossimGrect.h:269

Member Data Documentation

◆ theBoundingRect

ossimDrect ossimGeographicAnnotationGrid::theBoundingRect
protected

This will be computed based on the bounding ground and projection.

Definition at line 42 of file ossimGeographicAnnotationGrid.h.

Referenced by computeBoundingRect(), and getBoundingRect().

◆ theDeltaLatSpacing

double ossimGeographicAnnotationGrid::theDeltaLatSpacing
protected

Will hold the spacing of the grid cells in geographic lat lon change.

Definition at line 48 of file ossimGeographicAnnotationGrid.h.

Referenced by draw(), and setViewProjectionInformation().

◆ theDeltaLonSpacing

double ossimGeographicAnnotationGrid::theDeltaLonSpacing
protected

Definition at line 49 of file ossimGeographicAnnotationGrid.h.

Referenced by draw(), and setViewProjectionInformation().

◆ theGroundRect

ossimGrect ossimGeographicAnnotationGrid::theGroundRect
protected

◆ theViewProjection

ossimRefPtr<ossimMapProjection> ossimGeographicAnnotationGrid::theViewProjection
protected

Holds the view projection.

Definition at line 34 of file ossimGeographicAnnotationGrid.h.

Referenced by computeBoundingRect(), draw(), and setViewProjectionInformation().


The documentation for this class was generated from the following files: