Skip to content

oxrpy.map

Put API positions on Oxford's map image.

Oxford publishes a top-down map image (https://docs.oxfd.re/#res-map) whose top-left corner is x = -6700, z = -2500 and bottom-right corner is x = 1450, z = 3800. Positions from the API are [x, y, z]; only x and z matter on the map (y is height).

The full-size image is 8151 x 6301 pixels, so 1 stud is about 1 pixel. If you resize the image, pass your size to :func:to_pixels.

Example::

from oxrpy.map import to_pixels

for player in api.get_players() or []:
    if player.get("Position"):
        px, py = to_pixels(player["Position"], width=1630, height=1260)   # a 20% size copy

to_pixels

to_pixels(position, width=None, height=None, *, clamp=False)

Where a position falls on the map image, in pixels from its top-left corner.

Parameters:

Name Type Description Default
position Sequence[float]

[x, y, z] from the API (or (x, z)).

required
width Optional[float]

Your image's width in pixels. Defaults to the full-size image.

None
height Optional[float]

Your image's height in pixels. Defaults to the full-size image.

None
clamp bool

Keep the point inside the image (otherwise points off the map come back negative or larger than the image).

False

from_pixels

from_pixels(px, py, width=None, height=None)

The other way: a pixel on the map image -> (x, z) in studs. Handy for api.create_incident(team, priority, x, z, text) from a click on a map.

on_map

on_map(position)

Whether a position is inside the area the map image covers.

distance

distance(a, b)

Distance in studs between two positions, across the ground (ignoring height).

nearest

nearest(position, places)

The entry in places (anything with a Position, e.g. the Catalogue's Map.Places, PointsOfInterest, players or vehicles) closest to position.