コード例 #1
0
    def __init__(
        self,
        tie_post,
        lat_dist,
        lon_dist,
        frequency,
        time_window,
        label,
        drawing_order=0,
        image="images/train.png",
    ):
        self.clat, self.clon = tie_post
        self.lat_dist = lat_dist
        self.lon_dist = lon_dist
        self.frequency = int(frequency)

        TrackingViz.__init__(
            self,
            label,
            image,
            self.get_loc_at_time,
            time_window,
            (
                self.clat - self.lat_dist,
                self.clat + self.lat_dist,
                self.clon - self.lon_dist,
                self.clon + self.lon_dist,
            ),
            drawing_order,
        )
コード例 #2
0
ファイル: custom_animations.py プロジェクト: hugovk/osmviz
    def __init__(
        self,
        tiepost,
        lat_dist,
        lon_dist,
        frequency,
        time_window,
        label,
        drawing_order=0,
        image="images/train.png",
    ):
        self.clat, self.clon = tiepost
        self.lat_dist = lat_dist
        self.lon_dist = lon_dist
        self.frequency = int(frequency)

        TrackingViz.__init__(
            self,
            label,
            image,
            self.getLocAtTime,
            time_window,
            (
                self.clat - self.lat_dist,
                self.clat + self.lat_dist,
                self.clon - self.lon_dist,
                self.clon + self.lon_dist,
            ),
            drawing_order,
        )
コード例 #3
0
  def __init__(self,bustrack,label,image,
               drawing_order=10):
    """
    Given bustrack a BusTrack object, label a string, and image a
    filename, creates a BusTrackViz wrapper around bustrack with
    the given label and image for visualization.
    """
    self.track = bustrack;
    time_window = bustrack.getRouteTimeInterval()
    bounding_box = bustrack.getBoundingBox()

    TrackingViz.__init__(self,label,image,
                         bustrack.getLocationAtTime,
                         time_window,bounding_box,
                         drawing_order)
コード例 #4
0
ファイル: test.py プロジェクト: ozzie00/osmviz
def test_sim(route, zoom, image="images/train.png"):
    time_window, bbox = find_bounds(route)

    def getLL(time):
        if time <= time_window[0]:
            return route[0][:2]
        elif time > time_window[1]:
            return route[-1][:2]

        for (lat1, lon1, time1), (lat2, lon2,
                                  time2) in zip(route[:-1], route[1:]):
            if time1 < time <= time2:
                break

        frac = (time - time1) / (time2 - time1)
        lat = lat1 + frac * (lat2 - lat1)
        lon = lon1 + frac * (lon2 - lon1)
        return lat, lon

    viz = TrackingViz("Test Train", image, getLL, time_window, bbox, 1)
    sim = Simulation([viz], [], 0)
    sim.run(speed=0, refresh_rate=0.1, osmzoom=zoom, windowsize=(600, 600))
コード例 #5
0
def makeInterpolator(begin_ll, end_ll, begin_t, end_t):
    def ret(t):
        if t < begin_t:
            return begin_ll
        elif t > end_t:
            return end_ll
        else:
            blat, blon = begin_ll
            elat, elon = end_ll
            frac = float(t) / (end_t - begin_t)
            return (blat + frac * (elat - blat), blon + frac * (elon - blon))

    return ret


for i in range(num_trains):
    lat = bottom_lat + i * (top_lat - bottom_lat) / (num_trains - 1)

    locAtTime = makeInterpolator((lat, left_lon), (lat, right_lon), begin_time,
                                 end_time)

    tviz = TrackingViz("Train %d" % (i + 1, ), image_f, locAtTime,
                       (begin_time, end_time), (30, 46, -119, -68.5),
                       1)  # drawing order doesn't really matter here

    trackvizs.append(tviz)

sim = Simulation(trackvizs, [], 0)
sim.run(speed=1, refresh_rate=0.1, osmzoom=zoom)
コード例 #6
0
ファイル: multiple_trackvizs.py プロジェクト: hugovk/osmviz
        elif t > end_t:
            return end_ll
        else:
            blat, blon = begin_ll
            elat, elon = end_ll
            frac = float(t) / (end_t - begin_t)
            return blat + frac * (elat - blat), blon + frac * (elon - blon)

    return ret


for i in range(num_trains):
    lat = bottom_lat + i * (top_lat - bottom_lat) / (num_trains - 1)

    loc_at_time = make_interpolator((lat, left_lon), (lat, right_lon),
                                    begin_time, end_time)

    tviz = TrackingViz(
        f"Train {i+1}",
        image_f,
        loc_at_time,
        (begin_time, end_time),
        (30, 46, -119, -68.5),
        1,
    )  # drawing order doesn't really matter here

    track_vizs.append(tviz)

sim = Simulation(track_vizs, [], 0)
sim.run(speed=1, refresh_rate=0.1, osmzoom=zoom)
コード例 #7
0
ファイル: track_points.py プロジェクト: rikiji/gl-engine
 def drawToSurface(self, surf):
   if self.xy != None:
       TrackingViz.drawToSurface(self, surf)
       x,y = self.xy
       surf.blit(self.text,(x+6,y+6))
コード例 #8
0
ファイル: track_points.py プロジェクト: rikiji/gl-engine
 def __init__(self, label, image, getLatLonAtTimeFunc, time_window, bounding_box, drawing_order=0):
   TrackingViz.__init__(self, label, image, getLatLonAtTimeFunc, time_window, bounding_box, drawing_order)
   # self.label= label
   pygame.font.init()
   font = pygame.font.Font(None, 18)
   self.text = font.render(label , True, (255, 255, 255), (255, 76, 84))