示例#1
0
 def get_data(self, request, object):
     ducts = []
     # Get all conduits
     conduits = defaultdict(list)
     for c, remote, _ in object.get_genderless_connections("conduits"):
         conduit, _ = c.p2p_get_other(object)
         for cc, t, _ in conduit.get_genderless_connections("conduits"):
             if t != object:
                 conduits[t] += [{
                     "id": str(conduit.id),
                     "n": int(conduit.name),
                     "x": cc.data["plan"]["x"],
                     "y": cc.data["plan"]["y"],
                     "d": 100,  # remote.data.get("...."),
                     "status": True,  # remote.data....
                 }]
     # Get neighbor ducts
     for c, remote, _ in object.get_genderless_connections("ducts"):
         map_distance = None
         br = None
         sbr = None
         if object.point and remote.point:
             map_distance = distance(object.point, remote.point)
             br = bearing(object.point, remote.point)
             sbr = bearing_sym(object.data, remote.data)
         cd = conduits[remote]
         ducts += [{
             "connection_id": str(c.id),
             "target_id": str(remote.id),
             "target_name": remote.name,
             "target_model_name": remote.model.name,
             "map_distance": map_distance,
             "project_distance": c.data.get("project_distance"),
             "n_conduits": len(cd),
             "conduits": cd,
             "bearing": br,
             "s_bearing": sbr,
         }]
     return {"id": str(object.id), "name": object.name, "ducts": ducts}
示例#2
0
def test_geo_bearing(config, config1, expected):
    assert int(bearing(config, config1)) == expected