-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathgolf_map.py
More file actions
20 lines (18 loc) · 754 Bytes
/
Copy pathgolf_map.py
File metadata and controls
20 lines (18 loc) · 754 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import logging
import os
import numpy as np
import sympy
import json
import constants
class GolfMap:
def __init__(self, map_filepath, logger) -> None:
self.logger = logger
self.logger.info("Map file loaded: {}".format(map_filepath))
with open(map_filepath, "r") as f:
json_obj = json.load(f)
self.map_filepath = map_filepath
self.start = sympy.geometry.Point2D(*json_obj["start"])
self.target = sympy.geometry.Point2D(*json_obj["target"])
self.golf_map = sympy.Polygon(*json_obj["map"])
assert self.golf_map.encloses(self.start), "Start point doesn't lie inside map polygon"
assert self.golf_map.encloses(self.target), "Target point doesn't lie inside map polygon"