Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modifying the projection in one layer does not trigger projecting again in the other layers #12

Open
andrea-cuttone opened this issue Jun 15, 2016 · 0 comments

Comments

@andrea-cuttone
Copy link
Owner

For example in https://github.com/andrea-cuttone/geoplotlib/blob/master/examples/follow_camera.py, changing the bottom part to:

otherdata = read_csv('data/taxi.csv')
geoplotlib.dot(otherdata)
geoplotlib.add_layer(TrailsLayer())
geoplotlib.show()

leads to the dot map not being displayed. This is because the following happens:

  1. dot adds a new DotDensityLayer with his own projection
  2. TrailsLayer changes the projection at every frame, but this is not propagated to the original projected points for the DotDensityLayer

in fact, invalidating the layers at every frame (for example in https://github.com/andrea-cuttone/geoplotlib/blob/master/geoplotlib/core.py#L229).

The code should be changed so that changes in the projection are propagated to all layers.

A workaround for now is to render the dots in the same method where the projection is modified, using two separate painters:

    def draw(self, proj, mouse_x, mouse_y, ui_manager): 
        df = self.data.where((self.data['timestamp'] > self.t) & (self.data['timestamp'] <= self.t + 30*60))
        proj.fit(BoundingBox.from_points(lons=df['lon'], lats=df['lat']), max_zoom=14)

        allx, ally = proj.lonlat_to_screen(self.data['lon'], self.data['lat'])
        self.painter = BatchPainter()
        self.painter.set_color([255,0,0])
        self.painter.points(allx, ally)
        self.painter.batch_draw()

        x, y = proj.lonlat_to_screen(df['lon'], df['lat'])
        self.painter = BatchPainter()
        self.painter.set_color([0,0,255])
        self.painter.linestrip(x, y, 10)

        self.t += 30
        if self.t > self.data['timestamp'].max():
            self.t = self.data['timestamp'].min()

        self.painter.batch_draw()
        ui_manager.info(epoch_to_str(self.t))

Thanks to Zhicheng Liu for reporting the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant