PyGlobe API
GlobeWidget
Pyside6 OpenGL Widget for Displaying a 3D Globe
Usage Example
from pyglobe import globe
class MyWidget(QWidget):
...
globe = GlobeWidget()
Signals
-
External Signals
Signal Description Params infoSig Publish debug info dict sigObjectClicked Publish clicked objects ScenObject -
Internal Signals
Signal Description Params requestTile Ask tile manager for a tile TMS z,x,y setAimpoint Tell tile manager current aimpoint TMS z,x,y
Methods
-
init_tile_manager : Set a TMS tile source
Parameter Description Type cache_dir Directory path of tile cache str url_template URL of tiles, must containx {z}, {x}, and {y} str - Returns: None
Note
There are many sources of TMS tiles - some free, some with a subscription. Please do not abuse OpenStreetMap servers.
-
add_object : Add a scene object to the map
Parameter Description Type obj SceneObject to add SceneObject - Returns: None
-
remove_object: Remove a scene object from the map
Parameter Description Type obj SceneObject to remove SceneObject - Returns: None
-
close: Closes the tile manager (and its background thread)
- Parameters : None
- Returns : None
Scene and Scene Objects
Usage Examples
Add a point to the map:
import pyglobe.scene
# 1. Point - Red marker over New York
point = scene.PointSceneObject(
'Point',
lat=12.3601,
lon=12.0589,
alt=0,
color=(1.0, 0.0, 0.0), # Red
size=10.0,
pick_radius=50000
)
self.globe.add_object(point)
Move the point:
point.set_pos(point.lat -0.1, point.lon - 0.1, point.alt)
Scene Object Types and Methods
Scene
The Scene class manages things that move (SceneObject) on the map. The GlobeWidget interacts with it to draw objects and handle clicks and events.
Scene Signals
| Signal | Description | Params |
|---|---|---|
| sigUpdate | Notify the GlobeWidget to update | None |
| sigClicked | Notify a SceneObject has been clicked | SceneObject |
Scene Methods
-
add - Add an object to the map
Parameter Description Type obj SceneObject to add SceneObject - Returns : None
-
remove - Remove an object from the map
Parameter Description Type obj SceneObject to remove SceneObject - Returns : None
-
on_object_updated - Catches update signals from SceneObject instances
- Parameters : None
- Returns : None
-
clear - Removes all from the map
- Parameters : None
- Returns : None
-
draw - Draws all objects on the map
- Parameters : None
- Returns : None
-
pick - Checks whether a given ray intersects objects on the map
Parameter Description Type ray_origin ECEF origin of ray np.ndarray[x,y,z] ray_direction ECEF vector np.ndarray[dx,dy,dz] - Returns: None
SceneObject
Parent class for all moving things on the map.
SceneObject Signals
-
External Signals
Signal Description Params sigUpdated This object ahas been updated None sigClicked This object has been clicked SceneObject
SceneObject Methods
-
draw - Draw this object
- Parameters: None
- Returns: None
Note
Must be implemented by subclass
-
intersect_ray - Check if this object has been clicked
- Parameters
Parameter Description Type ray_origin ECEF origin of ray np.ndarray[x,y,z] ray_direction ECEF vector np.ndarray[dx,dy,dz] - Returns
Retval Description Type distance distance of click from object float or None
Note
Must be implemented by subclass
PointSceneObject
Draws a point on the scene
PointSceneObject Methods
-
init
Parameter Description Type label Name for this object str lat WGS84 degrees float lon WGS84 degrees float alt WGS84 meters float color Drawing color float[3] size Drawing size float pick radius Distance around obj mouse click float - Returns: None
-
set_pos - Set a new position
Parameter Description Type lat WGS84 degrees float lon WGS84 degrees float alt WGS84 meters float - Returns: None
PolyLineSceneObject
Draw a series of connected points
PolyLineSceneObject Methods
-
init
Parameter Description Type label Name for this object str points_wgs84 WGS84 lat,lon,alt (deg, m) list(float[3]) color r,g,b color float[3] alititude_offset Alt(m) to draw object float pick radius Distance around obj mouse click float - Returns: None
-
set_points : set new points
Parameter Description Type points_wgs84 WGS84 lat,lon,alt (deg, m) list(float[3]) - Returns : None
CircleSceneObject
Draw a filled circle on the map
CircleSceneObject Methods
-
init
Parameter Description Type label Name for this object str center_lat WGS84 lat (deg) float center_lon WGS84 lat (deg) float radius_meters radius of circle (m) float color r,g,b color float[3] fill_color r,g,b color float[3] width width of outer line float num_points num points in circle int alitude offset alt of ground (m) float - Returns: None
-
set_pos - Set new position and size
Parameter Description Type center_lat WGS84 lat (deg) float[3] center_lon WGS84 lat (deg) float[3] radius_meters radius of circle (m) float
PolygonSceneObject
Draw a polygon on the map
PolygonSceneObject Methods
-
init
Parameter Description Type label Name for this object str points_wgs84 WGS84 lat,lon,alt (deg, m) list(float[3]) color r,g,b color float[3] fill_color r,g,b color float[3] width width of outer line float alitude offset alt of ground (m) float alpha Transparency float - Returns: None
-
set_points - Set new points
Parameter Description Type points_wgs84 WGS84 lat,lon,alt (deg, m) list(float[3])
ImageOverlaySceneObject
Draw an image on the surface of the earth
ImageOverlaySceneObject Methods
-
init
Parameter Description Type label Name for this object str corners_wgs84 WGS84 lat,lon,alt (deg, m) list(float[3]) image_path path to image file str alitude offset alt of ground (m) float alpha Transparency float
Note
Corners are ordered: bottom-left, bottom-right, top-right, top-left
-
set_corners - Set new location
Parameter Description Type corners_wgs84 WGS84 lat,lon,alt (deg, m) list(float[3]) - Returns: None
-
set_image - Set new image
Parameter Description Type image_path path to image file str - Returns: None
SceneModel
Draw a 3D mesh on the map
SceneModel Methods
-
init
Parameter Description Type label Name for this object str lat WGS84 degrees float lon WGS84 degrees float alt WGS84 meters float roll Deg around local east float pitch Deg around local north float yaw Deg around local up float pick radius Distance around obj mouse click float - Returns: None
-
set_pos - Set position and orientation
Parameter Description Type lat WGS84 degrees float lon WGS84 degrees float alt WGS84 meters float roll Deg around local east float pitch Deg around local north float yaw Deg around local up float - Returns: None
Map Tiles
Map tiles are managed by TileManager. It is a wrapper for TileDownloader and a thread it lives in. This is the class that the main thread should interact with,
- Methods callable by the main thread
- Sends signals to the tile downloader inside a thread
- Safelly initializes the tile downloader child objects within the threads using signals
TileManager Signals
-
Signals
Signal Description Params tileReady Send a tile to the main app TMS z,x,y,bytes sigSetAimpoint Set the current center tile TMS z,x,y sigReset Reset the downloader None sigStartDownloader Initialize child objects in the downloader None sigShutdown Shutdown the downloader thread None
TileManager Methods
-
set_downloader - Tell the downloader where to get tiles
Parameter Description Type cache_dir Directory path of tile cache str url_template URL of tiles, must containx {z}, {x}, and {y} str - Returns: None
-
start - Tell the downloader thread to start
- Parameters: None
- Returns: None
-
stop - Tell the Downloader thread to stop
- Parameters: None
- Returns: None
-
setAimpoint - Set the current center tile (for prioritization)
Parameter Description Type zoom TMS Zoom Level int x TMS X int y TMS X int - Returns: None
-
requestTile - Request a tile from the downloader
Parameter Description Type zoom TMS Zoom Level int x TMS X int y TMS X int - Returns: None