Live » History » Version 2
  Philippe May, 06/05/2019 17:14 
  
| 1 | 1 | Philippe May | h1. Live | 
|---|---|---|---|
| 2 | 1 | Philippe May | |
| 3 | 1 | Philippe May | While the primary intention is use a database for all layers, Gisaf has the capability to display layers directly from GeoPandas GeodataFrames. | 
| 4 | 1 | Philippe May | |
| 5 | 1 | Philippe May | In this case, they can also be updated dynamically, adding animation capabilities to the maps. | 
| 6 | 1 | Philippe May | |
| 7 | 1 | Philippe May | This can be used for, eg: | 
| 8 | 1 | Philippe May | |
| 9 | 1 | Philippe May | * displaying text (eg. temperatures, well levels) | 
| 10 | 1 | Philippe May | * moving elements | 
| 11 | 1 | Philippe May | * results of computations and analysis... | 
| 12 | 1 | Philippe May | |
| 13 | 1 | Philippe May | h2. Using live directly from a Python script on the Gisaf server | 
| 14 | 1 | Philippe May | |
| 15 | 1 | Philippe May | Eg: | 
| 16 | 1 | Philippe May | |
| 17 | 1 | Philippe May | <pre><code class="python"> | 
| 18 | 1 | Philippe May | #!/usr/bin/env python | 
| 19 | 1 | Philippe May | from asyncio import run | 
| 20 | 1 | Philippe May | |
| 21 | 1 | Philippe May | import geopandas as gpd | 
| 22 | 1 | Philippe May | |
| 23 | 1 | Philippe May | from shapely.geometry import Point | 
| 24 | 1 | Philippe May | |
| 25 | 1 | Philippe May | from gisaf.live import live_server | 
| 26 | 1 | Philippe May | |
| 27 | 1 | Philippe May | async def run(gs): | 
| 28 | 1 | Philippe May | gdf = gpd.GeoDataFrame( | 
| 29 | 1 | Philippe May |         data={ | 
| 30 | 1 | Philippe May | 'geometry': [ | 
| 31 | 1 | Philippe May | Point(12.01, 79.81) | 
| 32 | 1 | Philippe May | ] | 
| 33 | 1 | Philippe May | }, | 
| 34 | 1 | Philippe May | crs='epsg:4326' | 
| 35 | 1 | Philippe May | ) | 
| 36 | 1 | Philippe May | |
| 37 | 1 | Philippe May |     await live_server.publish_gdf('FooLayer', gdf) | 
| 38 | 1 | Philippe May | |
| 39 | 1 | Philippe May | |
| 40 | 1 | Philippe May | async def main(): | 
| 41 | 1 | Philippe May | await live_server.create_connections() | 
| 42 | 1 | Philippe May | await run(gs) | 
| 43 | 1 | Philippe May | |
| 44 | 1 | Philippe May | if __name__ == '__main__': | 
| 45 | 1 | Philippe May | run(main()) | 
| 46 | 1 | Philippe May | </code></pre> | 
| 47 | 2 | Philippe May | |
| 48 | 2 | Philippe May | Explanations: | 
| 49 | 2 | Philippe May | |
| 50 | 2 | Philippe May | 1. Initialize the connection with @live_server.create_connections()@. | 
| 51 | 2 | Philippe May | |
| 52 | 2 | Philippe May | 2. Publish a geo dataframe with @live_server.publish_gdf('name of the layer', gdf)@ | 
| 53 | 2 | Philippe May | |
| 54 | 2 | Philippe May | |
| 55 | 2 | Philippe May | h2. From Jupyter notebooks | 
| 56 | 2 | Philippe May | |
| 57 | 2 | Philippe May | Quite similarly to the case above, jupyter notebooks (running on a different machine) can be used to publish and control live layers. See the examples in @Templates/gisaf_live_templates@. | 
| 58 | 2 | Philippe May | |
| 59 | 2 | Philippe May | |
| 60 | 2 | Philippe May | h2. Architecture | 
| 61 | 2 | Philippe May | |
| 62 | 2 | Philippe May | Gisaf live layers use a redis data store for: | 
| 63 | 2 | Philippe May | |
| 64 | 2 | Philippe May | 1. Storage of the live layers | 
| 65 | 2 | Philippe May | |
| 66 | 2 | Philippe May | 2. Publish/subscribe for live updates. | 
| 67 | 2 | Philippe May | |
| 68 | 2 | Philippe May | The live updates are sent through a websocket, initiated by the clients (web browsers). | 
| 69 | 2 | Philippe May | |
| 70 | 2 | Philippe May | Moreover, Gisaf exposes an HTTP API for external control of the live layers, eg. by Jupyter notebooks running on another server. |