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 ¶
Where a position falls on the map image, in pixels from its top-left corner.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
position
|
Sequence[float]
|
|
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 ¶
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.
distance ¶
Distance in studs between two positions, across the ground (ignoring height).
nearest ¶
The entry in places (anything with a Position, e.g. the Catalogue's
Map.Places, PointsOfInterest, players or vehicles) closest to position.