pytopo package

Submodules

pytopo.GenericMapCollection module

pytopo.MapCollection module

MapCollection: the base class for all pytopo map collections.

class pytopo.MapCollection.MapCollection(_name, _location)

Bases: object

A MapCollection is a set of maplet tiles on disk, combined with knowledge about the geographic coordinates and scale of those tiles so they can be drawn in a map window.

Child classes implementing MapCollection must define functions __init__, get_maplet, draw_map.

draw_attribution(drawwin)

Draw attribution/copyright for the map tiles used in this collection.

draw_map(center_lon, center_lat, drawwin)

Draw a map in a window, centered around the specified coordinates. drawwin is a DrawWin object.

exists()

Does the collection have its map files in place?

get_maplet(longitude, latitude)

Returns pixbuf, x_offset, y_offset:

  • the pixbuf for the maplet image (or null)

  • the offset in pixels into the image for the given coordinates, from top left.

lat2y(a)

Spherical Mercator conversion from latitude (decimal degrees)

y2lat(a)

Spherical Mercator conversion to latitude (decimal degrees)

zoom(amount, latitude=45)

Zoom by the given number of steps (positive to zoom in, negative to zoom out). Pass amount=0 to recalculate/redraw. Some map collections need to know latitude to determine scale.

zoom_to(newzoom, latitude=45)

Zoom to a specific zoom level and recalculate scales. Some map collections need to know latitude to determine scale.

zoom_to_bounds(*args)

Zoom to a reasonable level for the given bounds, which may be either a TrackPoints.BoundingBox or minlon, minlat, maxlon, maxlat.

pytopo.MapUtils module

MapUtils: some useful utility functions useful for mapping classes.

pytopo.MapUtils.angle_to_quadrant(angle)
pytopo.MapUtils.bearing()

staticmethod(function) -> method

Convert a function to be a static method.

A static method does not receive an implicit first argument. To declare a static method, use this idiom:

class C:

@staticmethod def f(arg1, arg2, …):

It can be called either on the class (e.g. C.f()) or on an instance (e.g. C().f()). The instance is ignored except for its class.

Static methods in Python are similar to those found in Java or C++. For a more advanced concept, see the classmethod builtin.

pytopo.MapUtils.coord2str_dd(lon, lat)

Convert a longitude, latitude pair into a pretty string, in decimal degrees

pytopo.MapUtils.dec_deg2deg_min(coord)

Convert decimal degrees to degrees . decimal minutes

pytopo.MapUtils.dec_deg2dms(dd)

Convert decimal degrees to (degrees, minutes, seconds)

pytopo.MapUtils.dec_deg2dms_str(coord)

Convert decimal degrees to a human-readable degrees/minutes string

pytopo.MapUtils.deg_min2dec_deg(coord)

Convert degrees.decimal_minutes to decimal degrees

pytopo.MapUtils.deg_min_sec2dec_deg(coord)

Convert degrees.minutes_seconds to decimal degrees

pytopo.MapUtils.haversine_angle(latitude_1, longitude_1, latitude_2, longitude_2)

Haversine angle between two points. From https://github.com/tkrajina/gpxpy/blob/master/gpxpy/geo.py Implemented from http://www.movable-type.co.uk/scripts/latlong.html

pytopo.MapUtils.haversine_distance(latitude_1, longitude_1, latitude_2, longitude_2, metric=False)

Haversine distance between two points. Returns distance in miles or meters.

pytopo.MapUtils.int_trunc(num)

Truncate to an integer, but no .999999 stuff

pytopo.MapUtils.main()

You can use this file for degree conversions. It’s installed as a commandline script called “degreeconv”.

pytopo.MapUtils.ohstring(num, numdigits)

Return a zero-prefixed string of the given number of digits.

pytopo.MapUtils.parse_full_coords(coordstr, degformat='DD')

Parse a full coordinate string, e.g. 35 deg 53’ 30.81” N 106 deg 24’ 4.17” W” Return a tuple of floats. # XXX Needs smarts about which is lat and which is lon. Can also parse a single coordinate, in which case returns a 1-tuple.

pytopo.MapUtils.to_decimal_degrees(coord, degformat='DD', report_chars_matched=False)

Try to parse various different forms of deg-min-sec strings as well as floats for a single coordinate (lat or lon, not both). Returns float decimal degrees.

degformat can be “DM”, “DMS” or “DD” and controls whether float inputs are just passed through, or converted from degrees + decimal minutes or degrees minutes seconds.

If report_chars_matched is true, returns a tuple: the coordinate parsed, plus the number of characters matched, to make it easier to parse the second coordinate.

pytopo.MapUtils.truncate2frac(num, frac)

Truncate to a multiple of the given fraction

pytopo.MapViewer module

pytopo.MapWindow module

pytopo.OSMMapCollection module

pytopo.TiledMapCollection module

pytopo.TopoMapCollection module

pytopo.TrackPoints module

pytopo.trackstats module

Module contents