KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | List of all members
kjb::TopoFusion::DOrthoQuad Class Reference

Digital orthoquad buffer. More...

#include <dorthoquad.h>

Public Types

typedef unsigned char Pixel
 a single pixel is a gray level 0-255 More...
 

Public Member Functions

int num_tiles_to_cover (int) const
 Compute how many tiles are needed to cover X number of meters. More...
 
 DOrthoQuad (unsigned edge_length_pix=0)
 Construct a digital orthoquad image buffer; must be square. More...
 
int fill (const pt &)
 Fill the array with image data roughly around a given point. More...
 
int refill (const pt &)
 Like fill(), but force a download from the internet. More...
 
char select_tileset (char)
 change the tileset "theme" – see themes in lib/topo/master.h More...
 
long left () const
 Return the "easting" coordinate of the left edge of the DOQ. More...
 
long top () const
 Return the "northing" coordinate of the top edge of the DOQ. More...
 
char zone () const
 return UTM zone for the DOQ (which must lie entirely in a zone). More...
 
size_t width () const
 Return the east-west size of the image, in meters. More...
 
size_t height () const
 Return the north-south size of the image, in meters. More...
 
bool isReady () const
 Returns true iff the array has been filled with image data. More...
 
int as_matrix (Int_matrix *) const
 represent DOQ as a matrix of integers: row 0, col 0 is northwest More...
 
kjb_c::Pixel read_color (unsigned, unsigned) const
 Read pixel RELATIVE TO current left,top settings (meters offset) More...
 
kjb_c::Pixel read_abs_color (long, long) const
 Return color pixel at given UTM coordinates (zone assumed) More...
 
Pixel read (unsigned, unsigned) const
 Read pixel RELATIVE TO current left,top settings (meters offset) More...
 
Pixel read_abs (long, long) const
 Return pixel at given UTM coordinates (zone assumed) More...
 
Pixel read_abs (const pt &) const
 Return pixel at given UTM coordinates. More...
 
pt center () const
 Return UTM coordinates of the center of the DOQ. More...
 
const kjb::Imagedebug_access_internal_image_buffer () const
 access internal buffer, but with clunky name to discourage you More...
 
float meters_per_pixel () const
 retrieve the number of meters per pixel for chosen imagery theme More...
 

Detailed Description

Digital orthoquad buffer.

This class lets you build grayscale digital orthoquad images. You choose the size, and then you can "fill" it centered at a given UTM coordinate. This downloads the data for you; then you can read pixels out of the buffer at will. The "fill" process queries an on-disk cache, and if any desired tiles are absent, it will request the missing tiles over the internets.

Centering is approximate. There is a granularity of about 200 pixels; the resulting image can have an offset of about plus or minus 100 pixels in each direction. The best way to cope with centering jitter is to use the read_abs() method to read pixels into a matrix, instead of the as_matrix method.

Default tileset: aerial imagery at 1 meter per pixel resolution, i.e., the tileset coded AIR_1M in header file lib/topo/master.h. You can change the tileset with the select_tileset() method. This is a new method, and much of the code and documentation assumes a 1 meter per pixel resolution. But many other tilesets have a different resolution, and so the code might not work as expected or the documentation might be wrong for such tilesets. It is a (low-priority) work in progress to make the code and documentation consistent with the recent possibility for other resolutions.

Member Typedef Documentation

typedef unsigned char kjb::TopoFusion::DOrthoQuad::Pixel

a single pixel is a gray level 0-255

Constructor & Destructor Documentation

kjb::TopoFusion::DOrthoQuad::DOrthoQuad ( unsigned  edge_length_pix = 0)

Construct a digital orthoquad image buffer; must be square.

Member Function Documentation

int kjb::TopoFusion::DOrthoQuad::as_matrix ( Int_matrix doq) const

represent DOQ as a matrix of integers: row 0, col 0 is northwest

Returns
kjb_c::ERROR if DOQ is not yet filled, otherwise kjb_c::NO_ERROR.
Warning
Remember the DOQ is not centered at the point given to the ctor.
See Also
read_abs() to get precise centering control over the DOQ imagery.
pt kjb::TopoFusion::DOrthoQuad::center ( ) const
inline

Return UTM coordinates of the center of the DOQ.

const kjb::Image& kjb::TopoFusion::DOrthoQuad::debug_access_internal_image_buffer ( ) const
inline

access internal buffer, but with clunky name to discourage you

int kjb::TopoFusion::DOrthoQuad::fill ( const pt center)

Fill the array with image data roughly around a given point.

Use fill() under ordinary circumstances, since it will make use of locally cached results.

3 Dec 2010: It's unbelievable that I'm only discovering this after 2 years working with this code, but I now think the resulting image is only ROUGHLY centered on the given location, with a granularity of one "tile" (an internal unit of image tranfer that I thought was encapsulated so that you, the client, would never have to know about it). A tile, at this writing, is 200 x 200 pixels, so the filled image could, I think, be offset from your specified center by plus or minus 100 pixels, in either axis.

Use the read_abs() method to avoid the above granularity.

Returns
ERROR or NO_ERROR indicating outcome.
size_t kjb::TopoFusion::DOrthoQuad::height ( ) const

Return the north-south size of the image, in meters.

bool kjb::TopoFusion::DOrthoQuad::isReady ( ) const
inline

Returns true iff the array has been filled with image data.

long kjb::TopoFusion::DOrthoQuad::left ( ) const

Return the "easting" coordinate of the left edge of the DOQ.

float kjb::TopoFusion::DOrthoQuad::meters_per_pixel ( ) const

retrieve the number of meters per pixel for chosen imagery theme

int kjb::TopoFusion::DOrthoQuad::num_tiles_to_cover ( int  meters) const

Compute how many tiles are needed to cover X number of meters.

How many tiles does it take to cover a given number of (linear) meters? This will tell you. Basically it computes the "ceiling" of the length in meters, divided by tile size in meters.

Returns
that number of tiles
DOrthoQuad::Pixel kjb::TopoFusion::DOrthoQuad::read ( unsigned  xcoord,
unsigned  ycoord 
) const

Read pixel RELATIVE TO current left,top settings (meters offset)

DOrthoQuad::Pixel kjb::TopoFusion::DOrthoQuad::read_abs ( long  abs_xcoord,
long  abs_ycoord 
) const

Return pixel at given UTM coordinates (zone assumed)

Parameters
abs_xcoordUTM easting (in meters) in same zone as last fill.
abs_ycoordUTM northing (in meters) in same zone as last fill.
Returns
grayscale level of the imagery at that location
Exceptions
Index_out_of_boundsif the query is outside the buffer contents

This is at absolute location (not relative to current left,top), conditioned on the current value of zone(). If you go out of bounds it will throw.

DOrthoQuad::Pixel kjb::TopoFusion::DOrthoQuad::read_abs ( const pt p) const

Return pixel at given UTM coordinates.

Parameters
pquery location (absolute, not relative to current left,top)
Returns
intensity of aerial imagery at query location p
Exceptions
Index_out_of_boundsif the DOQ does not hold imagery at point p
Warning
The query point zone must match the center point zone, even if the query point properly ought to be in a different zone. In that case, you must "stretch" the center zone to cover the query point.
kjb_c::Pixel kjb::TopoFusion::DOrthoQuad::read_abs_color ( long  abs_xcoord,
long  abs_ycoord 
) const

Return color pixel at given UTM coordinates (zone assumed)

Parameters
abs_xcoordUTM easting (in meters) in same zone as last fill.
abs_ycoordUTM northing (in meters) in same zone as last fill.
Returns
pixel value at the specified location
Exceptions
Index_out_of_boundsif the query is outside the buffer contents

This is at absolute location (not relative to current left,top). The zone for the coordinates is the same as that of the last fill command, but if you aren't sure what that was, just use the zone() method. If you go out of bounds it will throw.

kjb_c::Pixel kjb::TopoFusion::DOrthoQuad::read_color ( unsigned  xcoord_m,
unsigned  ycoord_m 
) const

Read pixel RELATIVE TO current left,top settings (meters offset)

int kjb::TopoFusion::DOrthoQuad::refill ( const pt center)

Like fill(), but force a download from the internet.

Use refill() when an image is obviously corrupted, and it will clear out the cache and force a fresh download.

Returns
ERROR or NO_ERROR indicating outcome.
char kjb::TopoFusion::DOrthoQuad::select_tileset ( char  tileset)

change the tileset "theme" – see themes in lib/topo/master.h

long kjb::TopoFusion::DOrthoQuad::top ( ) const

Return the "northing" coordinate of the top edge of the DOQ.

size_t kjb::TopoFusion::DOrthoQuad::width ( ) const

Return the east-west size of the image, in meters.

char kjb::TopoFusion::DOrthoQuad::zone ( ) const
inline

return UTM zone for the DOQ (which must lie entirely in a zone).


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