export m export sphere # ----- sector bounds ----- struct sector_id int level, row, cell # row ranges from 0 (north of equator) to 2^level-1 (near north pole) # and from -1 (south of equator) to -2^level (near south pole) # cell ranges from 0 (east of grenwich) to sectors_in_row(level, row) struct sector_bounds num west, east, south, north # TODO make sure calc_sector_bounds, etc are as accurate as possible calc_sector_bounds(const sector_id &id, sector_bounds &b) # this is a bit more complex because I need to be sure that the boundaries of the # sectors near ew == 0 (and at the poles) are exactly right int sector_rows_eq_to_pole = 1<= b.west && p.longitude < b.east && p.latitude >= b.south && p.latitude < b.north