OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimTilingRect.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 //
3 // License: LGPL
4 //
5 // See LICENSE.txt file in the top level directory for more details.
6 //
7 // Author: Mingjie Su
8 //
9 // Description: implementation for image generator
10 //
11 //*************************************************************************
12 // $Id: ossimTilingRect.cpp 2725 2011-06-15 18:13:07Z david.burken $
13 
14 #include <sstream>
15 #include <iomanip>
20 #include <ossim/base/ossimTrace.h>
24 
25 static ossimTrace traceDebug("ossimTilingRect:debug");
26 
27 RTTI_DEF1(ossimTilingRect, "ossimTilingRect", ossimTiling);
28 
30  : ossimTiling(),
31  m_clipToAoi(true),
32  m_lastWidth(0),
33  m_lastHeight(0),
34  m_useOffset(false),
35  m_offsetInPixels(0,0),
36  m_tilingDistanceInPixels(0,0),
37  m_tilinResolutionDistance(ossim::nan(),ossim::nan()),
38  m_tilingResolutionUnitType(OSSIM_UNIT_UNKNOWN),
39  m_fractionalPixelMisalignment(ossim::nan(),ossim::nan())
40 {
41 }
42 
44 {
45 }
46 
48  const ossimIrect& boundingRect,
49  ossimDpt& convertedTilingDistance)
50 {
52  theImageRect = boundingRect;
53 
55  // Find image center and GSD at that point:
57  {
60  gsd = geom->getMetersPerPixel();
61  }
62 
64 
65  //if resolution and resolution type are defined, need to reset degree/meter per pixel and the image rect. do calculation below
66  ossim_float64 latDiff = 0.0;
67  ossim_float64 lonDiff = 0.0;
68  ossim_uint32 imageWidth = 0;
69  ossim_uint32 imageHeight = 0;
71  {
72  ossimDpt result(0,0);
74  {
75  ossimGpt ulg;
76  ossimGpt llg;
77  ossimGpt lrg;
78  ossimGpt urg;
79 
84 
85  latDiff = fabs(ulg.lat - llg.lat);
86  lonDiff = fabs(urg.lon - llg.lon);
87 
89  {
90  ossim_float64 tileHorizatalNum = lonDiff/m_tilinResolutionDistance.x;
91  ossim_float64 tileVerticalNum = latDiff/m_tilinResolutionDistance.y;
92 
93  if (theTilingDistanceUnitType != OSSIM_PIXEL) //convert tiling distance to pixel if unit type is not pixel
94  {
95  ossimDpt convertedDis = m_tilingDistanceInPixels;
97  imageWidth = (ossim_uint32)convertedDis.x/gsd.x*tileHorizatalNum;
98  imageHeight = (ossim_uint32)convertedDis.y/gsd.y*tileVerticalNum;
99  }
100  else
101  {
102  imageWidth = (ossim_uint32)m_tilingDistanceInPixels.x*tileHorizatalNum;
103  imageHeight = (ossim_uint32)m_tilingDistanceInPixels.y*tileVerticalNum;
104  }
105  result = ossimDpt(theImageRect.width()*gsd.x/imageWidth, theImageRect.height()*gsd.y/imageHeight);
106  gsd = result;
107 
109  }
110  else
111  {
114 
116  }
117  }
118  else //only handle degree type for resolution
119  {
120  return false;
121  }
122  }
123 
125  {
126  ossimDpt paddingSize = getPaddingSize();//convert padding size to meters or degree
127  getConvertedDistance(convertedTilingDistance, theTilingDistance);
128 
129  ossimDpt convertedOffset = m_offsetInPixels;
130  if (m_useOffset)
131  {
132  getConvertedDistance(convertedOffset, m_offsetInPixels);
133  }
134 
136  {
137  thePaddingSizeInPixels.x = ossim::round<int>(paddingSize.x / theMapProjection->getDecimalDegreesPerPixel().x);
138  thePaddingSizeInPixels.y = ossim::round<int>(paddingSize.y / theMapProjection->getDecimalDegreesPerPixel().y);
139 
140  double intpart;
141  m_fractionalPixelMisalignment.x = modf(convertedTilingDistance.x / theMapProjection->getDecimalDegreesPerPixel().x, &intpart);
142  m_fractionalPixelMisalignment.y = modf(convertedTilingDistance.y / theMapProjection->getDecimalDegreesPerPixel().y, &intpart);
143 
144  m_tilingDistanceInPixels.x = ossim::round<int>(convertedTilingDistance.x / theMapProjection->getDecimalDegreesPerPixel().x);
145  m_tilingDistanceInPixels.y = ossim::round<int>(convertedTilingDistance.y / theMapProjection->getDecimalDegreesPerPixel().y);
146 
147  if (m_useOffset)
148  {
149  m_offsetInPixels.x = ossim::round<int>(convertedOffset.x / theMapProjection->getDecimalDegreesPerPixel().x);
150  m_offsetInPixels.y = ossim::round<int>(convertedOffset.y / theMapProjection->getDecimalDegreesPerPixel().y);
151  }
152  }
153  else
154  {
155  thePaddingSizeInPixels.x = ossim::round<int>(paddingSize.x / gsd.x);
156  thePaddingSizeInPixels.y = ossim::round<int>(paddingSize.y / gsd.y);
157 
158  double intpart;
159  m_fractionalPixelMisalignment.x = modf(convertedTilingDistance.x / gsd.x, &intpart);
160  m_fractionalPixelMisalignment.y = modf(convertedTilingDistance.y / gsd.y, &intpart);
161 
162  m_tilingDistanceInPixels.x = ossim::round<int>(convertedTilingDistance.x / gsd.x);
163  m_tilingDistanceInPixels.y = ossim::round<int>(convertedTilingDistance.y / gsd.y);
164 
165  if (m_useOffset)
166  {
167  m_offsetInPixels.x = ossim::round<int>(convertedOffset.x / gsd.x);
168  m_offsetInPixels.y = ossim::round<int>(convertedOffset.y / gsd.y);
169  }
170  }
171  }
172  else
173  {
175  {
178  }
179  else
180  {
183  }
184  }
185 
186  //re-calculation the image rect if resolution and resolution type defined
188  {
190  {
191  imageWidth = (ossim_uint32)m_tilingDistanceInPixels.x * lonDiff;
192  imageHeight = (ossim_uint32)m_tilingDistanceInPixels.y * latDiff;
193  }
194 
195  //avoid very small pixel offset by calculation if tiling distance unit type is pixel
197  {
198  if (imageWidth % (ossim_int32)m_tilingDistanceInPixels.x != 0)
199  {
200  ossim_int32 numX = ossim::round<int>((double)imageWidth/m_tilingDistanceInPixels.x);
201  imageWidth = m_tilingDistanceInPixels.x * numX;
202  }
203  if (imageHeight % (ossim_int32)m_tilingDistanceInPixels.y != 0)
204  {
205  ossim_int32 numY = ossim::round<int>((double)imageHeight/m_tilingDistanceInPixels.y);
206  imageHeight = m_tilingDistanceInPixels.y * numY;
207  }
208  }
209 
210  theImageRect = ossimIrect(boundingRect.ul(),
211  ossimIpt((boundingRect.ul().x + imageWidth), boundingRect.ul().y),
212  ossimIpt((boundingRect.ul().x + imageWidth), (imageHeight - boundingRect.ul().y)),
213  ossimIpt(boundingRect.ul().x , (imageHeight - boundingRect.ul().y)));
214  }
215  return true;
216 }
217 
219  const ossimIrect& boundingRect)
220 {
221  bool result = false;
222  if(traceDebug())
223  {
225  << "ossimTilingRect::initialize DEBUG: Entered..."
226  << "\nBounding rect === " << boundingRect
227  << std::endl;
228  }
229 
230  ossimDpt convertedTilingDistance = theTilingDistance;
231  result = initializeBase(proj, boundingRect, convertedTilingDistance);
232  ossimDrect tilingRectInPixels = theImageRect;
233 
234  // Let's setup the bounding tile rect.
236  {
237  ossimGpt ul;
238  ossimGpt ur;
239  ossimGpt lr;
240  ossimGpt ll;
241 
246 
249 
250  if(traceDebug())
251  {
253  << "DEBUG: Geographic input bounds = "
254  << theTilingRect
255  << std::endl;
256  }
257 
258  if (!m_clipToAoi)
259  {
260  theTilingRect.stretchToTileBoundary(convertedTilingDistance);
261  }
262 
263  if(traceDebug())
264  {
266  << "DEBUG: Geographic input bounds stretched = "
267  << theTilingRect << std::endl;
268  }
269 
271 
272  if(traceDebug())
273  {
275  << "DEBUG: Geographic input bounds clamped = "
276  << theTilingRect << std::endl;
277  }
278 
279  } // End "if(theMapProjection->isGeographic())"
280  else // meters
281  {
282  ossimDpt ul;
283  ossimDpt ur;
284  ossimDpt lr;
285  ossimDpt ll;
286 
291  theTilingRect = ossimDrect(ul, ur, lr, ll, OSSIM_RIGHT_HANDED);
292 
293  if (!m_clipToAoi)
294  {
295  theTilingRect.stretchToTileBoundary(convertedTilingDistance);
296  }
297  }
298 
299  theTotalHorizontalTiles = ossim::round<int>(fabs(tilingRectInPixels.ur().x - tilingRectInPixels.ul().x)/m_tilingDistanceInPixels.x);
300  theTotalVerticalTiles = ossim::round<int>(fabs(tilingRectInPixels.ur().y - tilingRectInPixels.lr().y)/m_tilingDistanceInPixels.y);
301 
302  if (m_clipToAoi)
303  {
304  if (m_useOffset)
305  {
306  ossim_float32 totalHorizontalTilesAfterOffset =
307  ((fabs(tilingRectInPixels.ur().x - tilingRectInPixels.ul().x))-m_tilingDistanceInPixels.x)/(m_tilingDistanceInPixels.x - m_offsetInPixels.x) + 1;
308  ossim_float32 totalVerticalTilesAfterOffset =
309  ((fabs(tilingRectInPixels.ur().y - tilingRectInPixels.lr().y))-m_tilingDistanceInPixels.y)/(m_tilingDistanceInPixels.y - m_offsetInPixels.y) + 1;
310 
311  ossim_float32 lastHorizontal = totalHorizontalTilesAfterOffset - (ossim_int32)totalHorizontalTilesAfterOffset;
312  ossim_float32 lastVertical = totalVerticalTilesAfterOffset - (ossim_int32)totalVerticalTilesAfterOffset;
313 
314  m_lastWidth = ossim::round<int>(fabs(lastHorizontal* (m_tilingDistanceInPixels.x - m_offsetInPixels.x) + m_offsetInPixels.x));
315  m_lastHeight = ossim::round<int>(fabs(lastVertical* (m_tilingDistanceInPixels.y - m_offsetInPixels.y) + m_offsetInPixels.y));
316 
317  theTotalHorizontalTiles = ossim::round<int>(totalHorizontalTilesAfterOffset);
318  theTotalVerticalTiles = ossim::round<int>(totalVerticalTilesAfterOffset);
319 
320  if (m_lastWidth > 0 && (lastHorizontal < 0.5))//if lastHorizontal is less than 0.5, the last tile will not add to total tiles after rounding, do here
321  {
323  }
324  if (m_lastHeight > 0 && (lastVertical < 0.5))
325  {
327  }
328  }
329  else
330  {
331  ossim_int32 tmpX = (ossim_int32)(fabs(tilingRectInPixels.ur().x - tilingRectInPixels.ul().x)) + 1;
332  ossim_int32 tmpY = (ossim_int32)(fabs(tilingRectInPixels.ur().y - tilingRectInPixels.lr().y)) + 1;
333 
336  if (modValueX >= 1)
337  {
338  m_lastWidth = modValueX;
339  }
340  else
341  {
343  }
344  if (modValueY >= 1)
345  {
346  m_lastHeight = modValueY;
347  }
348  else
349  {
351  }
352 
353  if (m_lastWidth > 0)
354  {
356  {
358  }
359  }
360  if (m_lastHeight > 0)
361  {
363  {
365  }
366  }
367  }
368  }
369 
371 
372  // reset the tile id to the beginning
373  reset();
374 
375  if(traceDebug())
376  {
378 
380  << "\nossimTiling::initialize DEBUG: Leaving..." << std::endl;
381  }
382 
383  return result;
384 }
385 
387  ossimIrect& resultingBounds,
388  ossimString& resultingName)
389 {
390  bool result = true;
391 
393  {
394  ossimDpt origin;
395  ossim_int64 row=0;
396  ossim_int64 col=0;
397 
398  getRowCol(row, col, theTileId);
399 
400  getTileName(resultingName,
401  (row+1), (col+1), theTileId);
402 
403  getOrigin(origin, row, col);
404 
406  {
407  if (row == 0 && col != 0)
408  {
409  if (m_fractionalPixelMisalignment.x >= 0.5)
410  {
412  {
414  }
415  else
416  {
417  origin.x = origin.x + (1 - m_fractionalPixelMisalignment.x) * theMapProjection->getMetersPerPixel().x * col;
418  }
419  }
420  else
421  {
423  {
425  }
426  else
427  {
429  }
430  }
431  }
432  else if (col == 0 && row != 0)
433  {
434  if (m_fractionalPixelMisalignment.y >= 0.5)
435  {
437  {
439  }
440  else
441  {
442  origin.y = origin.y - (1 - m_fractionalPixelMisalignment.y) * theMapProjection->getMetersPerPixel().y * row;
443  }
444  }
445  else
446  {
448  {
450  }
451  else
452  {
454  }
455  }
456  }
457  else if (col != 0 && row != 0)
458  {
459  if (m_fractionalPixelMisalignment.x >= 0.5)
460  {
462  {
464  }
465  else
466  {
467  origin.x = origin.x + (1 - m_fractionalPixelMisalignment.x) * theMapProjection->getMetersPerPixel().x * col;
468  }
469  }
470  else
471  {
473  {
475  }
476  else
477  {
479  }
480  }
481 
482  if (m_fractionalPixelMisalignment.y >= 0.5)
483  {
485  {
487  }
488  else
489  {
490  origin.y = origin.y - (1 - m_fractionalPixelMisalignment.y) * theMapProjection->getMetersPerPixel().y * row;
491  }
492  }
493  else
494  {
496  {
498  }
499  else
500  {
502  }
503  }
504  }
505  }
506 
508 
510  {
512  ossimGpt(origin.lat,
513  origin.lon,
514  0.0,
516  }
517  else
518  {
519  theMapProjection->setUlTiePoints(ossimDpt(origin.x, origin.y));
520  }
521 
522  if (m_clipToAoi || m_useOffset)
523  {
524  if (row == 0 && col == 0)
525  {
526  resultingBounds = ossimIrect(0, 0,
527  (pixels.x-1) + (ossim_int32)thePaddingSizeInPixels.x,
528  (pixels.y-1) + (ossim_int32)thePaddingSizeInPixels.y);
529  }
530  else if (row == 0 && col != 0)
531  {
532  if (col == (theTotalHorizontalTiles-1))
533  {
534  resultingBounds = ossimIrect(-(ossim_int32)thePaddingSizeInPixels.x, 0,
535  (m_lastWidth-1),
536  (pixels.y-1) + (ossim_int32)thePaddingSizeInPixels.y);
537 
538  if (m_useOffset)
539  {
540  ossim_int32 lr_x = -((ossim_int32)m_offsetInPixels.x*col)- resultingBounds.width();
541  resultingBounds = ossimIrect(-((ossim_int32)m_offsetInPixels.x*col), 0,
542  lr_x, (resultingBounds.height()-1));
543  }
544  }
545  else
546  {
547  resultingBounds = ossimIrect(-(ossim_int32)thePaddingSizeInPixels.x, 0,
548  (pixels.x-1) + (ossim_int32)thePaddingSizeInPixels.x,
549  (pixels.y-1) + (ossim_int32)thePaddingSizeInPixels.y);
550 
551  if (m_useOffset)
552  {
553  resultingBounds = ossimIrect(-((ossim_int32)m_offsetInPixels.x*col), 0,
554  (resultingBounds.width()-1)-((ossim_int32)m_offsetInPixels.x*col),
555  (resultingBounds.height()-1));
556  }
557  }
558  }
559  else if (row != 0 && col == 0)
560  {
561  if (row == (theTotalVerticalTiles-1))
562  {
563  resultingBounds = ossimIrect(0, -(ossim_int32)thePaddingSizeInPixels.y,
564  (pixels.x-1) + (ossim_int32)thePaddingSizeInPixels.x,
565  (m_lastHeight-1));
566 
567  if (m_useOffset)
568  {
569  ossim_int32 lr_y = -((ossim_int32)m_offsetInPixels.y*row)-resultingBounds.height();
570  resultingBounds = ossimIrect(0, -((ossim_int32)m_offsetInPixels.y*row),
571  (resultingBounds.width()-1), lr_y);
572  }
573  }
574  else
575  {
576  resultingBounds = ossimIrect(0,
578  (pixels.x-1) + (ossim_int32)thePaddingSizeInPixels.x,
579  (pixels.y-1) + (ossim_int32)thePaddingSizeInPixels.y);
580 
581  if (m_useOffset)
582  {
583  resultingBounds = ossimIrect(0, -((ossim_int32)m_offsetInPixels.y*row),
584  (resultingBounds.width()-1),
585  (resultingBounds.height()-1)-((ossim_int32)m_offsetInPixels.y*row));
586  }
587  }
588  }
589  else if (row != 0 && col != 0)
590  {
591  if (row == (theTotalVerticalTiles-1) && col == (theTotalHorizontalTiles-1))
592  {
593  resultingBounds = ossimIrect(-(ossim_int32)thePaddingSizeInPixels.x,
595  (m_lastWidth-1),
596  (m_lastHeight-1));
597 
598  if (m_useOffset)
599  {
600  ossim_int32 lr_x = -((ossim_int32)m_offsetInPixels.x*col)-resultingBounds.width();
601  ossim_int32 lr_y = -((ossim_int32)m_offsetInPixels.y*row)-resultingBounds.height();
602  resultingBounds = ossimIrect(-((ossim_int32)m_offsetInPixels.x*col),
604  lr_x, lr_y);
605  }
606  }
607  else if (row != (theTotalVerticalTiles-1) && col == (theTotalHorizontalTiles-1))
608  {
609  resultingBounds = ossimIrect(-(ossim_int32)thePaddingSizeInPixels.x,
611  (m_lastWidth-1),
612  (pixels.y-1) + (ossim_int32)thePaddingSizeInPixels.y);
613 
614  if (m_useOffset)
615  {
616  ossim_int32 lr_x = -((ossim_int32)m_offsetInPixels.x*col)-resultingBounds.width();
617  resultingBounds = ossimIrect(-((ossim_int32)m_offsetInPixels.x*col),
619  lr_x, (resultingBounds.height()-1)-((ossim_int32)m_offsetInPixels.y*row));
620  }
621  }
622  else if (row == (theTotalVerticalTiles-1) && col != (theTotalHorizontalTiles-1))
623  {
624  resultingBounds = ossimIrect(-(ossim_int32)thePaddingSizeInPixels.x,
626  (pixels.x-1) + (ossim_int32)thePaddingSizeInPixels.x,
627  (m_lastHeight-1));
628 
629  if (m_useOffset)
630  {
631  ossim_int32 lr_y = -((ossim_int32)m_offsetInPixels.y*row)-resultingBounds.height();
632  resultingBounds = ossimIrect(-((ossim_int32)m_offsetInPixels.x*col),
634  (resultingBounds.width()-1)-((ossim_int32)m_offsetInPixels.x*col),
635  lr_y);
636  }
637  }
638  else
639  {
640  resultingBounds = ossimIrect(-(ossim_int32)thePaddingSizeInPixels.x,
642  (pixels.x-1) + (ossim_int32)thePaddingSizeInPixels.x,
643  (pixels.y-1) + (ossim_int32)thePaddingSizeInPixels.y);
644 
645  if (m_useOffset)
646  {
647  resultingBounds = ossimIrect(-((ossim_int32)m_offsetInPixels.x*col),
649  (resultingBounds.width()-1)-((ossim_int32)m_offsetInPixels.x*col),
650  (resultingBounds.height()-1)-((ossim_int32)m_offsetInPixels.y*row));
651  }
652  }
653  }
654  }
655  else
656  {
657  resultingBounds = ossimIrect(-(ossim_int32)thePaddingSizeInPixels.x,
659  (pixels.x-1) + (ossim_int32)thePaddingSizeInPixels.x,
660  (pixels.y-1) + (ossim_int32)thePaddingSizeInPixels.y);
661 
662  if (m_useOffset)
663  {
664  resultingBounds = ossimIrect(-(ossim_int32)m_offsetInPixels.x,
666  (resultingBounds.width()-1), (resultingBounds.height()-1));
667  }
668  }
669 
670  if(traceDebug()&&resultProjection.valid())
671  {
672  ossimKeywordlist projKwl;
673 
674  resultProjection->saveState(projKwl);
676  << "ossimTilingRect::next DEBUG: rect = " << resultingBounds
677  << "\nproj = " << projKwl
678  << "\ntileName = " << resultingName
679  << "\norigin = " << origin << std::endl;
680  }
681 
682  resultProjection = theMapProjection;
683 
684  ++theTileId;
685  }
686  else
687  {
688  result = false;
689  }
690 
691  return result;
692 }
693 
695  const char* prefix)const
696 {
697  std::stringstream tilingDistance;
698 
699  tilingDistance << theTilingDistance.x << " " << theTilingDistance.y << std::endl;
700 
701  kwl.add(prefix,
702  "tile_size",
703  tilingDistance.str().c_str(),
704  true);
705 
706  kwl.add(prefix,
707  "units",
709  getTableIndexString(theTilingDistanceUnitType),
710  true);
711 
712  std::ostringstream padding;
713 
714  padding << thePaddingSizeInPixels.x << " " << thePaddingSizeInPixels.y;
715  kwl.add(prefix,
716  "padding",
717  padding.str().c_str(),
718  true);
719 
720  kwl.add(prefix,
721  "output_file_name",
723  true);
724 
725  kwl.add(prefix,
726  "clip_to_aoi",
727  m_clipToAoi,
728  true);
729 
730  return true;
731 }
732 
734  const char* prefix)
735 {
736  bool result = false;
737 
738  // Get the mask if any.
739  theTileNameMask = kwl.find(prefix, "output_file_name");
740  if (!theTileNameMask.contains("%f%")) //%f% format is used for feature id in a shape file
741  {
743  }
744 
745  const char* paddingSizeInPixels = kwl.find(prefix, "padding");
746 
747  if (paddingSizeInPixels)
748  {
749  ossimString x,y;
750  std::istringstream padding(ossimString(paddingSizeInPixels).c_str());
751  padding >> x >> y;
752  thePaddingSizeInPixels.x = x.toFloat64();
753  thePaddingSizeInPixels.y = y.toFloat64();
754  }
755 
756  const char* tilingDistance = kwl.find(prefix, "tile_size");
757 
758  const char* tilingDistanceType = kwl.find(prefix, "units");
759 
760  result = tilingDistance&&tilingDistanceType&&paddingSizeInPixels;
761 
762  ossimString x,y;
763  std::istringstream distance(ossimString(tilingDistance).c_str());
764  distance >> x >> y;
765  theTilingDistance.x = x.toFloat64();
766  theTilingDistance.y = y.toFloat64();
767  if(theTilingDistance.x <= 0.0)
768  {
769  theTilingDistance.x = 1.0;
770  }
771  if(theTilingDistance.y<=0.0)
772  {
774  }
775 
778  ossimString(tilingDistanceType).c_str());
779 
780  const char* clipToAoi = kwl.find(prefix, "clip_to_aoi");
781  if (clipToAoi)
782  {
783  if (!ossimString(clipToAoi).toBool())
784  {
785  m_clipToAoi = false;
786  }
787  }
788 
789  const char* offset = kwl.find(prefix, "use_offset");
790  if (offset)
791  {
792  ossimString width, height;
793  std::istringstream distanceOffset(ossimString(offset).c_str());
794  distanceOffset >> width >> height;
795  m_offsetInPixels.x = width.toFloat64();
796  m_offsetInPixels.y = height.toFloat64();
797  if (m_offsetInPixels.x > 0 || m_offsetInPixels.y > 0.0)
798  {
799  m_useOffset = true;
800  result = true;
801  }
802  }
803 
804  const char* tileRes = kwl.find(prefix, "resolution");
805  if (tileRes)
806  {
807  theDelta = ossimDpt(0,0);
808  x="";
809  y="";
810  std::istringstream tileResValues(ossimString(tileRes).c_str());
811  tileResValues >> x >> y;
812 
813  m_tilinResolutionDistance.x = x.toFloat64();
814  m_tilinResolutionDistance.y = y.toFloat64();
815  }
816 
817  const char* tilingResType = kwl.find(prefix, "resolution_units");
818  if (tilingResType)
819  {
822  ossimString(tilingResType).c_str());
823  }
824 
825  if (traceDebug())
826  {
828  }
829  return result;
830 }
831 
833 {
835 
836  if (!theMapProjection.valid())
837  return result;
838 
840  {
841  return result;
842  }
843  else
844  {
846  unitConverter.setValue(result.x, theTilingDistanceUnitType);
847  result.x = unitConverter.getValue(OSSIM_METERS);
848 
849  unitConverter.setValue(result.y, theTilingDistanceUnitType);
850  result.y = unitConverter.getValue(OSSIM_METERS);
851  }
852 
853  return result;
854 }
855 
857 {
858  if (!theMapProjection)
859  {
860  // This should not happen...
862  << "ossimTiling::getConvertedDistance WARNING"
863  << " projection not set!" << endl;
864  pt = inputDistance;
865  return;
866  }
867 
869  {
870  pt = inputDistance;
871  }
872  else
873  {
875  1.0,
877 
878  unitConverter.setValue(inputDistance.x,
880  pt.x = unitConverter.getValue(OSSIM_METERS);
881 
882  unitConverter.setValue(inputDistance.y,
884  pt.y = unitConverter.getValue(OSSIM_METERS);
885  }
886 }
virtual bool next(ossimRefPtr< ossimMapProjection > &resultProjection, ossimIrect &resultingBounds, ossimString &resultingName)
ossim_uint32 x
virtual const ossimDpt & getDecimalDegreesPerPixel() const
Returns decimal degrees per pixel as an ossimDpt with "x" representing longitude and "y" representing...
virtual ossimObject * dup() const =0
ossimDpt m_fractionalPixelMisalignment
double getValue(ossimUnitType unitType=OSSIM_METERS) const
ossimUnitType m_tilingResolutionUnitType
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
ossimUnitType theTilingDistanceUnitType
The unit type for "theDelta", and "theTilingDistance".
Definition: ossimTiling.h:125
std::basic_stringstream< char > stringstream
Class for char mixed input and output memory streams.
Definition: ossimIosFwd.h:38
ossimDpt m_tilinResolutionDistance
ossimUnitType
Represents serializable keyword/value map.
ossim_uint32 y
ossim_int64 theTileId
Definition: ossimTiling.h:176
bool valid() const
Definition: ossimRefPtr.h:75
const char * find(const char *key) const
float ossim_float32
double nan()
Method to return ieee floating point double precision NAN.
Definition: ossimCommon.h:135
This code was derived from https://gist.github.com/mshockwave.
Definition: Barrier.h:8
const ossimDpt & ul() const
Definition: ossimDrect.h:339
void setValue(double value, ossimUnitType unitType=OSSIM_METERS)
double y
Definition: ossimDpt.h:165
ossim_uint32 height() const
Definition: ossimIrect.h:487
bool contains(char aChar) const
Definition: ossimString.h:58
void getConvertedDistance(ossimDpt &pt, ossimDpt inputDistance) const
ossimRefPtr< ossimMapProjection > theMapProjection
Definition: ossimTiling.h:173
virtual bool isGeographic() const
const ossimIpt & ul() const
Definition: ossimIrect.h:274
ossim_int64 theTotalVerticalTiles
Definition: ossimTiling.h:178
virtual ossim_int32 getEntryNumber(const char *entry_string, bool case_insensitive=true) const
ossimIrect theImageRect
Definition: ossimTiling.h:174
virtual void setDecimalDegreesPerPixel(const ossimDpt &gsd)
bool isNan() const
Definition: ossimDpt.h:72
void getTileName(ossimString &resultingName, ossim_int64 row, ossim_int64 col, ossim_int64 id) const
void setImageSize(const ossimIpt &size)
const ossimIpt & ll() const
Definition: ossimIrect.h:277
virtual void setMetersPerPixel(const ossimDpt &gsd)
const ossimDatum * datum() const
datum().
Definition: ossimGpt.h:196
void clampGeographic(ossimDrect &rect) const
double ossim_float64
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
virtual ossimGpt lineSampleToWorld(const ossimDpt &projectedPoint) const
ossimDpt theDelta
If (theDeltaType == ossimTilingDeltaType_TOTAL_PIXELS) then this is the size of the tile in pixels li...
Definition: ossimTiling.h:134
virtual bool initialize(const ossimMapProjection &proj, const ossimIrect &boundingRect)
void setTileNameMask(const ossimString &mask)
This sets the tilename mask.
double lat
Definition: ossimDpt.h:165
ossim_float64 lon
Definition: ossimGpt.h:266
virtual void lineSampleToEastingNorthing(const ossimDpt &liineSample, ossimDpt &eastingNorthing) const
ossimDpt m_tilingDistanceInPixels
virtual ossimGpt origin() const
unsigned int ossim_uint32
ossim_int64 theTotalTiles
Definition: ossimTiling.h:179
ossimDpt getMetersPerPixel() const
Returns the GSD associated with this image in the active projection.
ossim_float64 m_lastHeight
ossim_float64 toFloat64() const
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
const ossimIpt & lr() const
Definition: ossimIrect.h:276
bool getOrigin(ossimDpt &origin, ossim_int64 tileId) const
bool getRowCol(ossim_int64 &row, ossim_int64 &col, ossim_int64 tileId) const
ossim_uint32 width() const
Definition: ossimIrect.h:500
bool hasNans() const
Definition: ossimDpt.h:67
double lon
Definition: ossimDpt.h:164
ossimDpt getPaddingSize() const
ossim_int64 theTotalHorizontalTiles
Definition: ossimTiling.h:177
virtual std::ostream & print(std::ostream &out) const
Generic print method.
const ossimIpt & ur() const
Definition: ossimIrect.h:275
ossimDrect theTilingRect
Definition: ossimTiling.h:175
Container class that holds both 2D transform and 3D projection information for an image Only one inst...
RTTI_DEF1(ossimTilingRect, "ossimTilingRect", ossimTiling)
ossimString theTileNameMask
Definition: ossimTiling.h:180
ossimDpt theTilingDistance
The size of a tile in theTilingDistanceUnitType.
Definition: ossimTiling.h:122
void stretchToTileBoundary(const ossimDpt &widthHeight)
Definition: ossimDrect.cpp:396
ossim_int32 y
Definition: ossimIpt.h:142
virtual ~ossimTilingRect()
ossimDpt thePaddingSizeInPixels
Definition: ossimTiling.h:172
const ossimDpt & ur() const
Definition: ossimDrect.h:340
double x
Definition: ossimDpt.h:164
ossimDpt m_offsetInPixels
long long ossim_int64
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
bool initializeBase(const ossimMapProjection &proj, const ossimIrect &boundingRect, ossimDpt &convertedTilingDistance)
virtual void setUlTiePoints(const ossimGpt &gpt)
ossim_int32 x
Definition: ossimIpt.h:141
ossim_float64 lat
Definition: ossimGpt.h:265
std::basic_istringstream< char > istringstream
Class for char input memory streams.
Definition: ossimIosFwd.h:32
virtual ossimDpt getMetersPerPixel() const
float distance(double lat1, double lon1, double lat2, double lon2, int units)
static ossimUnitTypeLut * instance()
Returns the static instance of an ossimUnitTypeLut object.
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
const ossimDpt & lr() const
Definition: ossimDrect.h:341
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
ossim_float64 m_lastWidth
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
int ossim_int32