KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dorthoquad.h
Go to the documentation of this file.
1 
10 /*
11  * $Id: dorthoquad.h 15331 2013-09-16 08:33:56Z predoehl $
12  */
13 
14 #ifndef DORTHOQUAD_H_UOFARIZONAVISION
15 #define DORTHOQUAD_H_UOFARIZONAVISION
16 
17 #include <i_cpp/i_image.h>
18 #include <l_cpp/l_int_matrix.h>
19 #include <l_cpp/l_stdio_wrap.h>
20 #include <topo/master.h>
21 #include <topo_cpp/layer.h>
22 
23 #include <vector>
24 #include <boost/scoped_ptr.hpp>
25 
26 
27 namespace kjb
28 {
29 namespace TopoFusion
30 {
31 
32 
34 extern const char* IVILAB_DOQ_TILE_CACHE_DIRECTORY;
35 
36 
82 {
83  boost::scoped_ptr< Temporary_Recursively_Removing_Directory > td;
84 
85  // singleton-enforcement: you can instantiate this class at most once.
86  static bool m_instantiated;
87 
89  bool m_temp_cache;
90 
91  // Not copyable, not assignable
92  Tile_manager& operator=(const Tile_manager&); // teaser
93  Tile_manager(const Tile_manager&); // teaser
94 
95 public:
125 
127  ~Tile_manager();
128 
131  {
132  return m_temp_cache;
133  }
134 
137  {
138  return m_instantiated;
139  }
140 };
141 
142 
143 
170 {
171 
172 public:
173  typedef unsigned char Pixel;
174 
175 private:
176 
178  struct Loc
179  {
180  enum { UNUSED = -1 };
181  long left,
182  top;
183  char zone;
184 
186  Loc()
187  : left( UNUSED )
188  {}
189 
191  Loc( long l, long t, char z )
192  : left( l ),
193  top( t ),
194  zone( z )
195  {}
196 
198  bool is_unused() const
199  {
200  return UNUSED == left;
201  }
202 
204  bool operator==( const Loc& that ) const
205  {
206  return left == that.left && top == that.top && zone == that.zone;
207  }
208 
210  static Loc tile_nw_from_utm_center(
211  const pt& center,
212  int tilesize_m,
213  int numtiles
214  )
215  {
216  return Loc(
217  static_cast< long >( center.x / tilesize_m - numtiles ),
218  static_cast< long >( center.y / tilesize_m + numtiles ),
219  center.zone
220  );
221  }
222  };
223 
224  Loc m_current;
225 
226  char m_tileset_code;
227 
228  Image m_doq;
229 
230  int num_tile_buf() const;
231 
233  int fillDoq( const Loc&, int );
234 
236  void clearCache( const Loc&, int );
237 
238 public:
239 
240  int num_tiles_to_cover( int ) const;
241 
243  DOrthoQuad( unsigned edge_length_pix = 0 );
244 
245 
265  int fill( const pt& );
266 
275  int refill( const pt& );
276 
277 
279  char select_tileset(char);
280 
281 
282 
284  long left() const;
285 
287  long top() const;
288 
290  char zone() const
291  {
292  return m_current.zone;
293  }
294 
295 
297  size_t width() const;
298 
300  size_t height() const;
301 
303  bool isReady() const
304  {
305  return ! m_current.is_unused();
306  }
307 
308  int as_matrix( Int_matrix* ) const;
309 
310  kjb_c::Pixel read_color( unsigned, unsigned ) const;
311 
312  kjb_c::Pixel read_abs_color( long, long ) const;
313 
314  Pixel read( unsigned, unsigned ) const;
315 
316  Pixel read_abs( long, long ) const;
317 
318  Pixel read_abs( const pt& ) const;
319 
321  pt center() const
322  {
323  return make_pt(left()+width()/2, top()-height()/2, m_current.zone);
324  }
325 
328  {
329  return m_doq;
330  }
331 
333  float meters_per_pixel() const;
334 
335 };
336 
337 
338 Int_matrix get_aerial_image(const pt&, size_t, size_t);
339 
340 Image get_topographic_map_detail(const pt&, size_t, size_t);
341 
342 
343 } // end namespace TopoFusion
344 } // end namespace kjb
345 
346 #endif
double x
easting of a location, meters
Definition: layer.h:36
int num_tiles_to_cover(int) const
Compute how many tiles are needed to cover X number of meters.
Definition: dorthoquad.cpp:574
Definition for the Int_matrix class, a thin wrapper on the KJB Int_matrix struct and its related func...
Contains definitions of basic TopoFusion data structures.
char zone
utm zone number of a location
Definition: layer.h:38
int refill(const pt &)
Like fill(), but force a download from the internet.
Definition: dorthoquad.cpp:628
const char * IVILAB_DOQ_TILE_CACHE_DIRECTORY
intentionally-long pathname to where we cache DOQ tiles at the lab.
Definition: dorthoquad.cpp:293
This class implements matrices, in the linear-algebra sense, restricted to integer-valued elements...
Definition: l_int_matrix.h:71
Int_matrix get_aerial_image(const pt &nw_corner, size_t width, size_t height)
return a matrix (like a monochrome image) of aerial imagery
Definition: dorthoquad.cpp:783
double y
northing of a location, meters
Definition: layer.h:37
long left() const
Return the "easting" coordinate of the left edge of the DOQ.
Definition: dorthoquad.cpp:639
size_t width() const
Return the east-west size of the image, in meters.
Definition: dorthoquad.cpp:657
pt make_pt(double eee, double nnn, char zzz, double elev=NO_ELEV)
construct a point from its parameters but not as a ctor.
Definition: layer.h:44
long top() const
Return the "northing" coordinate of the top edge of the DOQ.
Definition: dorthoquad.cpp:648
bool isReady() const
Returns true iff the array has been filled with image data.
Definition: dorthoquad.h:303
kjb_c::Pixel read_abs_color(long, long) const
Return color pixel at given UTM coordinates (zone assumed)
Definition: dorthoquad.cpp:736
static bool is_already_instantiated_elsewhere()
return whether the (singleton) object already exists
Definition: dorthoquad.h:136
bool is_using_a_temporary_cache() const
returns whether the cache is stored in a temporary directory.
Definition: dorthoquad.h:130
kjb_c::Pixel read_color(unsigned, unsigned) const
Read pixel RELATIVE TO current left,top settings (meters offset)
Definition: dorthoquad.cpp:699
unsigned char Pixel
a single pixel is a gray level 0-255
Definition: dorthoquad.h:173
Image get_topographic_map_detail(const pt &nw_corner, size_t width, size_t height)
return an image of a chunk of topographic map
Definition: dorthoquad.cpp:822
pt center() const
Return UTM coordinates of the center of the DOQ.
Definition: dorthoquad.h:321
DOrthoQuad(unsigned edge_length_pix=0)
Construct a digital orthoquad image buffer; must be square.
Definition: dorthoquad.cpp:354
~Tile_manager()
dtor closes the tile cache index, maybe deleting the index.
Definition: dorthoquad.cpp:337
bool operator==(const Int_matrix &op1, const Int_matrix::Impl_type &op2)
Test for exact equality between two matrices.
Definition: l_int_matrix.cpp:218
RAII wrappers on FILE* objects from stdio.h and other stdio helpers.
Pixel read(unsigned, unsigned) const
Read pixel RELATIVE TO current left,top settings (meters offset)
Definition: dorthoquad.cpp:692
const kjb::Image & debug_access_internal_image_buffer() const
access internal buffer, but with clunky name to discourage you
Definition: dorthoquad.h:327
size_t height() const
Return the north-south size of the image, in meters.
Definition: dorthoquad.cpp:663
Digital orthoquad buffer.
Definition: dorthoquad.h:169
Code for a wrapper class around the C struct KJB_Image.
Wrapped version of the C struct KJB_image.
Definition: i_image.h:76
char zone() const
return UTM zone for the DOQ (which must lie entirely in a zone).
Definition: dorthoquad.h:290
int as_matrix(Int_matrix *) const
represent DOQ as a matrix of integers: row 0, col 0 is northwest
Definition: dorthoquad.cpp:675
char select_tileset(char)
change the tileset "theme" – see themes in lib/topo/master.h
Definition: dorthoquad.cpp:361
float meters_per_pixel() const
retrieve the number of meters per pixel for chosen imagery theme
Definition: dorthoquad.cpp:750
Pixel read_abs(long, long) const
Return pixel at given UTM coordinates (zone assumed)
Definition: dorthoquad.cpp:718
definition for a TopoFusion pt
Definition: layer.h:34
RAII tool for opening and closing the DOQ master index.
Definition: dorthoquad.h:81
int fill(const pt &)
Fill the array with image data roughly around a given point.
Definition: dorthoquad.cpp:599