Reference
- renderer.__version__: str
The version.
Main
- renderer.render(components: ~renderer.misc_types.pla2.Pla2File, zoom: ~renderer.misc_types.zoom_params.ZoomParams, skin: ~renderer.misc_types.skin.Skin = <renderer.misc_types.skin.Skin object>, export_id: str = 'unnamed', save_images: bool = True, save_dir: ~pathlib.Path = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/tile-renderer/checkouts/v3.0/docs/tiles'), assets_dir: ~pathlib.Path = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/tile-renderer/checkouts/v3.0/renderer/skins/assets'), temp_dir: ~pathlib.Path = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/tile-renderer/checkouts/v3.0/docs/temp'), processes: int = 2, tiles: list[renderer.misc_types.coord.TileCoord] | None = None, offset: ~vector._methods.Vector2D = VectorObject2D(x=0, y=0), part1_batch_size: int = 8, part1_chunk_size: int = 8, part1_serial: bool = False) dict[renderer.misc_types.coord.TileCoord, PIL.Image.Image]
Renders tiles from given coordinates and zoom values.
Warning
Run this function under
if __name__ == "__main__"
ifuse_ray
is False, or else there would be a lot of multiprocessing RuntimeErrors.- Parameters:
components (Pla2File) – a JSON of components
zoom (ZoomParams) – a ZoomParams object
skin (Skin) – The skin to use for rendering the tiles
export_id (str) – The name of the rendering task
save_images (int) – whether to save the tile images in a folder or not
save_dir (Path) – the directory to save tiles in
assets_dir (Path) – the asset directory for the skin
temp_dir (Path) – the temporary data folder that will be used to save data
processes (int) – The amount of processes to run for rendering
tiles (list[TileCoord] | None) – a list of tiles to render
offset (tuple[float, float]) – the offset to shift all node coordinates by, given as
(x,y)
part1_batch_size (int) – The batch size for part 1
part1_chunk_size (int) – The chunk size for part 1
part1_serial (int) – Whether part 1 will be run serially
- Returns:
Given in the form of
{tile_coord: image}
- Return type:
dict[TileCoord, Image.Image]
- renderer.merge_tiles(images: Path | dict[renderer.misc_types.coord.TileCoord, PIL.Image.Image], save_images: bool = True, save_dir: Path = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/tile-renderer/checkouts/v3.0/docs'), zoom: list[int] | None = None) dict[int, PIL.Image.Image]
Merges tiles rendered by
render()
.- Parameters:
images (Path | dict[TileCoord, Image]) – Give in the form of
(tile coord): (PIL Image)
, like the return value ofrender()
, or as a path to a directory.save_images (bool) – whether to save the tile images in a folder or not
save_dir (Path) – the directory to save tiles in
zoom (list[int] | None) – if left empty, automatically calculates all zoom values based on tiles; otherwise, the layers of zoom to merge.
- Returns:
Given in the form of
(Zoom): (PIL Image)
Types
- class renderer.misc_types.Pla1ComponentJson
Represents a component JSON object.
- renderer.misc_types.Pla1ComponentListJson
Represents a component list JSON.
- class renderer.misc_types.Pla1NodeJson
Represents a node JSON object.
- renderer.misc_types.Pla1NodeListJson
Represents a node list JSON.
- class renderer.misc_types.SkinInfo
Represents the
info
portion of a skin JSON.
- class renderer.misc_types.SkinJson
Represents a skin JSON.
- class renderer.misc_types.SkinType
Represents a component type in the
types
portion of a skin JSON.
- class renderer.misc_types.coord.Bounds(x_max: _T, x_min: _T, y_max: _T, y_min: _T)
Represents a bounding box, like a rectangle
- class renderer.misc_types.coord.Coord(*args: float | Point)
Represents a 2-dimensional point. Wrapper of shapely.Point
- as_tuple() tuple[float, float]
Represent the coordinates as a tuple
- property x: float
The x-coordinate of the point
- property y: float
The y-coordinate of the point
- class renderer.misc_types.coord.ImageCoord(*args: float | Point)
Represents a 2-dimensional coordinate on an image
- to_world_coord(skin: Skin, tile_coord: TileCoord, zoom: ZoomParams) WorldCoord
Converts the coordinate to a WorldCoord
- Parameters:
skin – The skin that the render job is using
tile_coord – The tile coordinate that the coordinate is part of
zoom – The zoom parameters
- Returns:
The world coordinate
- class renderer.misc_types.coord.ImageLine(line: list[renderer.misc_types.coord.ImageCoord] | LineString)
- property coords: list[renderer.misc_types.coord.ImageCoord]
The coordinates in the line
- to_world_line(skin: Skin, tile_coord: TileCoord, zoom: ZoomParams) WorldLine
Converts the line into a WorldLine
- Parameters:
skin – The skin that the render job is using
tile_coord – The tile coordinate that the coordinate is part of
zoom – The zoom parameters
- Returns:
The world coordinate
- class renderer.misc_types.coord.Line(line: list[renderer.misc_types.coord.Coord] | LineString)
Represents a 2-dimensional line. Wrapper of shapely.LineString
- property bounds: Bounds[float]
Find the minimum and maximum x/y values in a list of coords.
- Returns:
Returns in the form
(x_max, x_min, y_max, y_min)
- property centroid
Calls shapely.LineString.centroid()
- property coords: list[renderer.misc_types.coord.Coord]
The coordinates in the line
- in_bounds(bounds: Bounds[int]) bool
Finds whether any part of the LineString is entirely within a bound
- Parameters:
bounds – The bounds to check for
- Returns:
If the above is true
- to_tiles(z: ZoomParams) list[renderer.misc_types.coord.TileCoord]
- Generates tile coordinates from a list of regular coordinates.
Mainly for rendering whole components.
- Parameters:
z (ZoomParams) – The zoom params
- Returns:
A list of tile coordinates
- class renderer.misc_types.coord.TileCoord(z: int, x: int, y: int)
Represents a tile coordinate in the form
(z, x, y)
.- static bounds(tile_coords: list[renderer.misc_types.coord.TileCoord]) Bounds[int]
Find the minimum and maximum x/y values in a set of TileCoords.
- Parameters:
tile_coords (List[TileCoord]) – a list of tile coordinates, provide in a tuple of
(z,x,y)
- Returns:
Returns in the form
(x_max, x_min, y_max, y_min)
- x: int
Represents x-coordinate
- y: int
Represents y-coordinate
- z: int
Represents zoom
- class renderer.misc_types.coord.WorldCoord(*args: float | Point)
Represents a 2-dimensional coordinate in the world
- tiles(zoom_params: ZoomParams) list[renderer.misc_types.coord.TileCoord]
Returns all tiles in the form of tile coordinates that contain the provided regular coordinate.
- Parameters:
zoom_params (ZoomParams) – The zoom parameters
- Returns:
A list of tile coordinates
- to_image_coord = <methodtools._LruCacheWire object>
- class renderer.misc_types.coord.WorldLine(line: list[renderer.misc_types.coord.WorldCoord] | LineString)
Represents a line in the world
- property coords: list[renderer.misc_types.coord.WorldCoord]
The coordinates in the line
- to_image_line(skin: Skin, tile_coord: TileCoord, zoom: ZoomParams) ImageLine
Converts the line into an ImageLine
- Parameters:
skin – The skin that the render job is using
tile_coord – The tile coordinate that the coordinate is part of
zoom – The zoom parameters
- Returns:
The image line
- class renderer.misc_types.pla2.Component(namespace: str, id: str, display_name: str, description: str, type: str, layer: float, nodes: WorldLine, tags: list[str], attrs: dict | None = None)
A component to be rendered
- attrs: dict | None
Additional attributes of the component, will probably be used in newer versions
- description: str
The description of the component
- display_name: str
This will appear on the map itself, if the component type’s style has a Text layer
- property fid: str
The full ID of the component (<namespace>-<id>)
- static find_ends(components: list[renderer.misc_types.pla2.Component]) Bounds[float]
Finds the minimum and maximum X and Y values in a JSON of components
- Parameters:
components (ComponentList) – a JSON of components
- Returns:
The minimum and maximum X and Y values
- id: str
The ID of the component
- layer: float
The layer of the component. Higher numbers mean further in front
- namespace: str
The namespace that the coordinate belongs to
- static rendered_in(components: list[renderer.misc_types.pla2.Component], zoom_params: ZoomParams) list[renderer.misc_types.coord.TileCoord]
Like
tools.line.to_tiles()
, but for a JSON of components.- Parameters:
components (ComponentList) – a JSON of components
zoom_params – The zoom parameters
- Returns:
A list of tile coordinates
- tags: list[str]
The tags of the component
- type: str
The component type of the map
- class renderer.misc_types.pla2.Pla2File(namespace: str, components: list[renderer.misc_types.pla2.Component])
Represents a PLA2 file
- components: list[renderer.misc_types.pla2.Component]
The components in the file
- static from_file(file: Path) Pla2File
Load a PLA2 file, can be either in JSON or MessagePack format
- Parameters:
file – The file to load from
- Returns:
The PLA2 file
- static from_json(file: Path) Pla2File
Load a PLA2 file, must be in JSON
- Parameters:
file – The file to load from
- Returns:
The PLA2 file
- static from_msgpack(file: Path) Pla2File
Load a PLA2 file, must be in MessagePack
- Parameters:
file – The file to load from
- Returns:
The PLA2 file
- property ids: list[str]
A list of IDs that all the components have
- namespace: str
The namespace of the file, all components included belong to this namespace
- save_json(directory: Path)
Save the PLA2 file in JSON format
- Parameters:
directory – The directory to save the file in
- save_msgpack(directory: Path)
Save the PLA2 file in MessagePack format
- Parameters:
directory – The directory to save the file in
- static validate(comps: list[renderer.misc_types.pla2.Component]) list[renderer.misc_types.pla2.Component]
Check for duplicate IDs
- Parameters:
comps – The list of components to look for
- Returns:
The same list of components
- Raises:
ValueError – if a duplicated ID is found
- class renderer.misc_types.skin.Skin(json: SkinJson)
Represents a skin.
- Parameters:
json (SkinJson) – The JSON of the skin.
- class ComponentTypeInfo(name: str, json: SkinType, order: list[str], skin: Skin)
An object representing a component type in the
types
portion of a skin.- Parameters:
name (str) – Will set
name
json (SkinType) – The JSON of the component type
order (list[str]) – Will set
_order
skin – The skin that the render job is using
- class AreaBorderText(json: dict | None = None, type_info: ComponentTypeInfo | None = None, shape: Literal['point', 'line', 'area'] | None = None)
Represent the border text of an area. Will be rendered in the future
- render(component: Component, imd: ImageDraw.ImageDraw, img: Image.Image, coords: ImageLine, consts: Part1Consts, tile_coord: TileCoord, text_list: list[TextObject], points_text_list: list[TextObject])
TODO fix
- class AreaCenterImage(json: dict | None = None, type_info: ComponentTypeInfo | None = None, shape: Literal['point', 'line', 'area'] | None = None)
Represents the image at the centre of an area
- render(component: Component, imd: ImageDraw.ImageDraw, img: Image.Image, coords: ImageLine, consts: Part1Consts, tile_coord: TileCoord, text_list: list[TextObject], points_text_list: list[TextObject])
Renders the component into an ImageDraw instance.
- class AreaCenterText(json: dict | None = None, type_info: ComponentTypeInfo | None = None, shape: Literal['point', 'line', 'area'] | None = None)
Represents the text at the centre of an area
- render(component: Component, imd: ImageDraw.ImageDraw, img: Image.Image, coords: ImageLine, consts: Part1Consts, tile_coord: TileCoord, text_list: list[TextObject], points_text_list: list[TextObject])
Renders the component into an ImageDraw instance.
- class AreaFill(json: dict | None = None, type_info: ComponentTypeInfo | None = None, shape: Literal['point', 'line', 'area'] | None = None)
Represents the fill and outline of an area
- render(component: Component, imd: ImageDraw.ImageDraw, img: Image.Image, coords: ImageLine, consts: Part1Consts, tile_coord: TileCoord, text_list: list[TextObject], points_text_list: list[TextObject])
Renders the component into an ImageDraw instance.
- class ComponentStyle(json: dict | None = None, type_info: ComponentTypeInfo | None = None, shape: Literal['point', 'line', 'area'] | None = None)
Represents the
styles
portion of a ComponentTypeInfo. Base class for all types of ComponentStyle.- Parameters:
json (dict) – JSON dictionary as input
type_info (Skin.ComponentTypeInfo) – The type_info that the ComponentStyle is under
- render(component: Component, imd: ImageDraw.ImageDraw, img: Image.Image, coords: ImageLine, consts: Part1Consts, tile_coord: TileCoord, text_list: list[TextObject], points_text_list: list[TextObject])
Renders the component into an ImageDraw instance.
- class LineBack(json: dict | None = None, type_info: ComponentTypeInfo | None = None, shape: Literal['point', 'line', 'area'] | None = None)
Represents the back layer of a line
- render(component: Component, imd: ImageDraw.ImageDraw, img: Image.Image, coords: ImageLine, consts: Part1Consts, tile_coord: TileCoord, text_list: list[TextObject], points_text_list: list[TextObject])
Renders the component into an ImageDraw instance.
- class LineFore(json: dict | None = None, type_info: ComponentTypeInfo | None = None, shape: Literal['point', 'line', 'area'] | None = None)
Represent the front layer of a line
- class LineText(json: dict | None = None, type_info: ComponentTypeInfo | None = None, shape: Literal['point', 'line', 'area'] | None = None)
Represents text of a point
- render(component: Component, imd: ImageDraw.ImageDraw, img: Image.Image, coords: ImageLine, consts: Part1Consts, tile_coord: TileCoord, text_list: list[TextObject], points_text_list: list[TextObject])
Renders the component into an ImageDraw instance.
- class PointCircle(json: dict | None = None, type_info: ComponentTypeInfo | None = None, shape: Literal['point', 'line', 'area'] | None = None)
Represents a circle of a point
- render(component: Component, imd: ImageDraw.ImageDraw, img: Image.Image, coords: ImageLine, consts: Part1Consts, tile_coord: TileCoord, text_list: list[TextObject], points_text_list: list[TextObject])
Renders the component into an ImageDraw instance.
- class PointImage(json: dict | None = None, type_info: ComponentTypeInfo | None = None, shape: Literal['point', 'line', 'area'] | None = None)
Represents an image of a point
- render(component: Component, imd: ImageDraw.ImageDraw, img: Image.Image, coords: ImageLine, consts: Part1Consts, tile_coord: TileCoord, text_list: list[TextObject], points_text_list: list[TextObject])
Renders the component into an ImageDraw instance.
- class PointSquare(json: dict | None = None, type_info: ComponentTypeInfo | None = None, shape: Literal['point', 'line', 'area'] | None = None)
Represents a square of a point
- render(component: Component, imd: ImageDraw.ImageDraw, img: Image.Image, coords: ImageLine, consts: Part1Consts, tile_coord: TileCoord, text_list: list[TextObject], points_text_list: list[TextObject])
Renders the component into an ImageDraw instance.
- class PointText(json: dict | None = None, type_info: ComponentTypeInfo | None = None, shape: Literal['point', 'line', 'area'] | None = None)
Represents a text of a point
- render(component: Component, imd: ImageDraw.ImageDraw, img: Image.Image, coords: ImageLine, consts: Part1Consts, tile_coord: TileCoord, text_list: list[TextObject], points_text_list: list[TextObject])
Renders the component into an ImageDraw instance.
- name: str
The name of the component.
- shape: Literal['point', 'line', 'area']
The shape of the component, must be one of
point
,line
,area
- styles: dict[tuple[int, int], list[renderer.misc_types.skin.Skin.ComponentTypeInfo.ComponentStyle]]
The styles of the object, denoted as
{(max_zoom, min_zoom): [style, ...]}
- tags: list[str]
The list of tags attributed to the component.
- classmethod from_name(name: str = 'default') Skin
Gets a skin from inside the package.
- Parameters:
name (str) – the name of the skin
- Returns:
The skin
- Raises:
FileNotFoundError – if skin does not exist
- get_font = <methodtools._LruCacheWire object>
- renderer.misc_types.skin_builder.CS
alias of
ComponentStyle
- renderer.misc_types.skin_builder.CTI
alias of
ComponentTypeInfo
- class renderer.misc_types.skin_builder.SkinBuilder(tile_size: int, fonts: dict[str, list[pathlib.Path]], background: int)
Utility class for building skins.
- Parameters:
tile_size (int) – Size of the tiles that the skin produces.
fonts (dict[str, list[Path]]) – Keys are the formatting, eg “”, “b”, “i”, “bi”, values are the relative paths to the fonts.
background (int) – The colour of the background in hexadecimal.
- class ComponentTypeInfo(shape: Literal['point', 'line', 'area'], tags: list[str] | None = None)
Utility class for building the component type info for the skin.
- Parameters:
shape (str) – The shape of the component. Must be either point, line or area.
tags (list[str]) – A list of tags for the component
- class ComponentStyle
Utility class for building the component style for the component.
- json() dict
Returns a JSON representation of the skin. :rtype: dict
- json() dict
Returns a JSON representation of the skin. :rtype: dict
- renderer.misc_types.skin_builder.blend(h1: int, h2: int, prop: float = 0.5) int
Blend two colours together
- Parameters:
h1 – The first colour
h2 – The second colour
prop – The proportion of the second colour, between 0.0 and 1.0
- Returns:
The final colour
- renderer.misc_types.skin_builder.darken(h1: int, strength: float = 0.5) int
Darken a colour
- Parameters:
h1 – The colour
strength – The strength of the darkening, between 0.0 and 1.0
- Returns:
The final colour
- renderer.misc_types.skin_builder.hex_to_colour(h: int) str
- renderer.misc_types.skin_builder.hex_to_colour(h: None) None
Converts a hex colour, represented as an integer, into a string of format
#XXXXXX
:param h: The hex code (0xXXXXXX
) :return: The string
- renderer.misc_types.skin_builder.lighten(h1: int, strength: float = 0.5) int
Lighten a colour
- Parameters:
h1 – The colour
strength – The strength of the lightening, between 0.0 and 1.0
- Returns:
The final colour
- class renderer.misc_types.zoom_params.ZoomParams(min: int, max: int, range: float)
Utility object for storing zoom parameters.
- Parameters:
min (int) – minimum zoom value
max (int) – maximum zoom value
range (float) – actual distance covered by a tile in the maximum zoom
- Raises:
ValueError – if min > max
Math Utils
- renderer.math_utils.dash(coords: ImageLine, dash_length: float, gap_length: float) list[renderer.misc_types.coord.ImageLine]
Takes a list of coordinates and returns a list of lines that make up a dashed line.
- Parameters:
coords (list[renderer.misc_types.Vector2D.Vector2D]) – the coordinates
dash_length (float) – the length of each dash
gap_length (float) – the length of the gap between dashes
- Returns:
a list of pairs of Vector2Ds.
- renderer.math_utils.rotate_around_pivot(coord: Coord, pivot: Coord, theta: float) Coord
Rotates a set of coordinates about a pivot point.
- Parameters:
coord (float) – the coordinate to be rotated
pivot (float) – the pivot to be rotated about
theta (float) – angle to rotate in radians
- Returns:
The rotated coordinates, given in
(x,y)
- Return type:
Rendering
- renderer.render.render(components: ~renderer.misc_types.pla2.Pla2File, zoom: ~renderer.misc_types.zoom_params.ZoomParams, skin: ~renderer.misc_types.skin.Skin = <renderer.misc_types.skin.Skin object>, export_id: str = 'unnamed', save_images: bool = True, save_dir: ~pathlib.Path = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/tile-renderer/checkouts/v3.0/docs/tiles'), assets_dir: ~pathlib.Path = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/tile-renderer/checkouts/v3.0/renderer/skins/assets'), temp_dir: ~pathlib.Path = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/tile-renderer/checkouts/v3.0/docs/temp'), processes: int = 2, tiles: list[renderer.misc_types.coord.TileCoord] | None = None, offset: ~vector._methods.Vector2D = VectorObject2D(x=0, y=0), part1_batch_size: int = 8, part1_chunk_size: int = 8, part1_serial: bool = False) dict[renderer.misc_types.coord.TileCoord, PIL.Image.Image]
Renders tiles from given coordinates and zoom values.
Warning
Run this function under
if __name__ == "__main__"
ifuse_ray
is False, or else there would be a lot of multiprocessing RuntimeErrors.- Parameters:
components (Pla2File) – a JSON of components
zoom (ZoomParams) – a ZoomParams object
skin (Skin) – The skin to use for rendering the tiles
export_id (str) – The name of the rendering task
save_images (int) – whether to save the tile images in a folder or not
save_dir (Path) – the directory to save tiles in
assets_dir (Path) – the asset directory for the skin
temp_dir (Path) – the temporary data folder that will be used to save data
processes (int) – The amount of processes to run for rendering
tiles (list[TileCoord] | None) – a list of tiles to render
offset (tuple[float, float]) – the offset to shift all node coordinates by, given as
(x,y)
part1_batch_size (int) – The batch size for part 1
part1_chunk_size (int) – The chunk size for part 1
part1_serial (int) – Whether part 1 will be run serially
- Returns:
Given in the form of
{tile_coord: image}
- Return type:
dict[TileCoord, Image.Image]
- renderer.render.prepare.prepare_render(components: ~renderer.misc_types.pla2.Pla2File, zoom: ~renderer.misc_types.zoom_params.ZoomParams, export_id: str, skin: ~renderer.misc_types.skin.Skin = <renderer.misc_types.skin.Skin object>, tiles: list[renderer.misc_types.coord.TileCoord] | None = None, zooms: list[int] | None = None, offset: ~vector._methods.Vector2D = VectorObject2D(x=0, y=0), temp_dir: ~pathlib.Path = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/tile-renderer/checkouts/v3.0/docs/temp')) dict[renderer.misc_types.coord.TileCoord, list[list[renderer.misc_types.pla2.Component]]]
The data-preparing step of the rendering job. Check render() for the full list of parameters
- class renderer.render.part1.Part1Consts(coord_to_comp: dict[renderer.misc_types.coord.WorldCoord, list[renderer.misc_types.pla2.Component]], skin: Skin, zoom: ZoomParams, assets_dir: Path, export_id: str, temp_dir: Path)
The constants used for part 1
- renderer.render.part1.render_part1(zoom: ~renderer.misc_types.zoom_params.ZoomParams, export_id: str, skin: ~renderer.misc_types.skin.Skin = <renderer.misc_types.skin.Skin object>, assets_dir: ~pathlib.Path = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/tile-renderer/checkouts/v3.0/renderer/skins/assets'), batch_size: int = 8, chunk_size: int = 8, temp_dir: ~pathlib.Path = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/tile-renderer/checkouts/v3.0/docs/temp'), serial: bool = False) dict[renderer.misc_types.coord.TileCoord, list[renderer.render.utils.TextObject]]
Part 1 of the rendering job. Check render() for the full list of parameters
- renderer.render.part2.file_loader(zoom: int, temp_dir: Path, export_id: str) Generator[tuple[renderer.misc_types.coord.TileCoord, list[renderer.render.utils.TextObject]], Any, None]
Loads the intermediate files for a certain zoom level
- Parameters:
zoom – The zoom to look for
temp_dir – The temporary directory to look into
export_id – The export ID to look into
- Returns:
The files
- renderer.render.part2.render_part2(export_id: str, temp_dir: Path = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/tile-renderer/checkouts/v3.0/docs/temp')) dict[renderer.misc_types.coord.TileCoord, list[renderer.render.utils.TextObject]]
Part 2 of the rendering job. Check render() for the full list of parameters
- renderer.render.part3.render_part3(export_id: str, zoom: ZoomParams, skin: Skin = <renderer.misc_types.skin.Skin object>, save_images: bool = True, save_dir: Path = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/tile-renderer/checkouts/v3.0/docs'), temp_dir: Path = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/tile-renderer/checkouts/v3.0/docs/temp'), serial: bool = False, batch_size: int = 2) dict[TileCoord, Image.Image]
Part 3 of the rendering job. Check render() for the full list of parameters
- class renderer.render.utils.TextObject(img: Image.Image, imd: ImageDraw.ImageDraw, center: ImageCoord, width_height: tuple[float, float], rot: float, tile_coord: TileCoord, consts: Part1Consts)
A text to be pasted into the map at part 3
- bounds: list[shapely.geometry.polygon.Polygon]
The bounds of the text in each image
- center: list[renderer.misc_types.coord.WorldCoord]
The centers of each image
- export_id: str = 'unnamed'
The export ID of the render job
- classmethod from_multiple(*text_object: TextObject) TextObject
Create a new compound TextObject from multiple TextObjects
- image: list[uuid.UUID]
A list of UUIDs, each representing an image in the temporary folder
- static img_to_uuid(img: Image, temp_dir: Path, export_id: str) UUID
Puts the image into the temporary directory and returns the UUID corresponding to the image
- Parameters:
img – The image to save
temp_dir – The temporary directory to save into
export_id – The export ID of the render job
- Returns:
The UUID
- static remove_img(u: UUID, temp_dir: Path, export_id: str)
Remove the image from the temporary directory
- Parameters:
u – The UUID
temp_dir – The temporary directory to save into
export_id – The export ID of the render job
- Raises:
FileNotFoundError – if the UUID is invalid
- temp_dir: Path = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/tile-renderer/checkouts/v3.0/docs/temp')
The temporary directory that the images belong to
- static uuid_to_img(u: UUID, temp_dir: Path, export_id: str) Image
Retrieves an image object, given its corresponding UUID
- Parameters:
u – The UUID
temp_dir – The temporary directory to save into
export_id – The export ID of the render job
- Returns:
The image object
- Raises:
FileNotFoundError – if the UUID is invalid
- renderer.render.utils.part_dir(temp_dir: Path, export_id: str, part: int) Path
Retrieve the directory for data from each of the parts
- Parameters:
temp_dir – The temporary directory
export_id – The export ID of the render job
part – The part number (0, 1, 2)
- Returns:
The path of the directory
- renderer.render.utils.text_object_path(temp_dir: Path, export_id: str, id_: UUID) Path
Retrieve the directory for a text object
- Parameters:
temp_dir – The temporary directory
export_id – The export ID of the render job
id – The UUID of the text object
- Returns:
The path of the directory
- renderer.render.utils.wip_tiles_dir(temp_dir: Path, export_id: str) Path
Retrieve the directory for half-complete tiles
- Parameters:
temp_dir – The temporary directory
export_id – The export ID of the render job
- Returns:
The path of the directory