Package mapproxy :: Package core :: Module srs
[hide private]
[frames] | no frames]

Module srs

source code

Spatial reference systems and transformation of coordinates.
Classes [hide private]
  TransformationError
  _SRS
Functions [hide private]
 
get_epsg_num(epsg_code) source code
 
_clean_srs_code(code) source code
 
_init_proj() source code
 
SRS(srs_code) source code
 
generate_envelope_points(bbox, n)
Generates points that form a linestring around a given bbox.
source code
 
calculate_bbox(points)
Calculates the bbox of a list of points.
source code
 
merge_bbox(bbox1, bbox2)
Merge two bboxes.
source code
 
bbox_equals(src_bbox, dst_bbox, x_delta, y_delta=None)
Compares two bbox and checks if they are equal, or nearly equal.
source code
 
make_lin_transf(src_bbox, dst_bbox)
Create a transformation function that transforms linear between two cartesian coordinate systems.
source code
Variables [hide private]
  log = logging.getLogger(__name__)
  _proj_initalized = False
  _srs_cache = {}
Function Details [hide private]

generate_envelope_points(bbox, n)

source code 

Generates points that form a linestring around a given bbox.

@param bbox: bbox to generate linestring for @param n: the number of points to generate around the bbox

>>> generate_envelope_points((10.0, 5.0, 20.0, 15.0), 4)
[(10.0, 5.0), (20.0, 5.0), (20.0, 15.0), (10.0, 15.0)]
>>> generate_envelope_points((10.0, 5.0, 20.0, 15.0), 8)
... #doctest: +NORMALIZE_WHITESPACE
[(10.0, 5.0), (15.0, 5.0), (20.0, 5.0), (20.0, 10.0),     (20.0, 15.0), (15.0, 15.0), (10.0, 15.0), (10.0, 10.0)]

calculate_bbox(points)

source code 

Calculates the bbox of a list of points.

>>> calculate_bbox([(-5, 20), (3, 8), (99, 0)])
(-5, 0, 99, 20)

@param points: list of points [(x0, y0), (x1, y2), ...] @returns: bbox of the input points.

bbox_equals(src_bbox, dst_bbox, x_delta, y_delta=None)

source code 

Compares two bbox and checks if they are equal, or nearly equal.

>>> src_bbox = (939258.20356824622, 6887893.4928338043,
...             1095801.2374962866, 7044436.5267618448)
>>> dst_bbox = (939258.20260000182, 6887893.4908000007,
...             1095801.2365000017, 7044436.5247000009)
>>> bbox_equals(src_bbox, dst_bbox, 61.1, 61.1)
True
>>> bbox_equals(src_bbox, dst_bbox, 0.0001)
False
Parameters:
  • x_delta (bbox units) - how precise the comparison should be. should be reasonable small, like a tenth of a pixle

make_lin_transf(src_bbox, dst_bbox)

source code 

Create a transformation function that transforms linear between two cartesian coordinate systems.

>>> transf = make_lin_transf((7, 50, 8, 51), (0, 0, 500, 400))
>>> transf((7.5, 50.5))
(250.0, 200.0)
>>> transf((7.0, 50.0))
(0.0, 400.0)
>>> transf = make_lin_transf((7, 50, 8, 51), (200, 300, 700, 700))
>>> transf((7.5, 50.5))
(450.0, 500.0)
Returns:
function that takes src x/y and returns dest x/y coordinates