Extensions

At the front-end, all maps and layers are controlled by Leaflet JavaScript library. Initially, Leaflet is designed to work with tiled web maps stored as many PNG images. To make the visualization customizable, Vizic creates vector tiles on the fly from catalogs stored in MongoDB database.

The data pipeline is composed of two modules: db_connect and extension. The db_connect provides all of the functions that are used to access the catalogs stored in the database. The extension module contains custom server handlers, which listen to URL requests, call the functions in the db_connect module and return requested information.

In the future, any added functionality that requires the access to the database by URL, can takes advantage of existing database utility function and custom server handlers found below. In addition, users can write their own database functions and server handlers.

Regarding how to write custom server handler for Jupyter Notebook App, an in-depth explanation can be found here.

The API for existing database functions and custom server handlers can be found under Database Utils and Server Handlers respectively.

Database Utils

class vizic.mongo_ext.db_connect.MongoConnect(host, port, db)[source]

MongoDB utility wrapper.

range_dict

dict – Geographical coverage, represented as the value ranges in RA and DEC, for catalog collections displayed in the notebooks.

zoom_dict

dict – Maximum zooms for catalog collections displayed in Jupyter notebooks.

Initiate an asynchronous client and a static client.

Parameters:
  • host (str) – MongoDB host name or address.
  • port (int) – The port number that MongoDB listens to.
  • db (str) – MongoDB database name for storing and retriving data.
__init__(host, port, db)[source]

Initiate an asynchronous client and a static client.

Parameters:
  • host (str) – MongoDB host name or address.
  • port (int) – The port number that MongoDB listens to.
  • db (str) – MongoDB database name for storing and retriving data.
close()[source]

Close existing clients.

getCircles(coll)[source]

Retrive previously imported circles layer data.

Parameters:coll (str) – Associated catalog collection name for the requested circles layer.
Returns:A cursor object
getCoordRange(xc, yc, zoom, maxZoom)[source]

Determine the projection of a tile on the maximum zoom level.

For tiles at lower (smaller) zoom levels, this function returns tile coordinates for the set of tiles that cover the same area as the provided one at the maximum zoom level.

Parameters:
  • xc (int) – x-coordinate of the required tile.
  • yc (int) – y-coordinate of the required tile.
  • zoom (int) – Zoom level of the required tile.
  • maxZoom (int) – Maximum allowed zoom for the particular catalog collection.
Returns:

A tuple representing the smallest and largest coordinate in both x and y direction.

getHealpix(coll)[source]

Retrive previously calcuated Healpix grid.

Parameters:coll (str) – Associated catalog collection name for the requested Healpix grid.
Returns:A cursor object
getMinRadius(zoom, mapSizeV)[source]

Returns the length scale of a one pixel.

Converting from pixel to degree, with provided projecting zoom level and the size of the map measure in degree.

Parameters:
  • zoom (int) – The projected zoom level.
  • mapSizeV (float) – The size of the map in vertial direction.
Returns:

A length correspoding to one pixel given the zoom level

and map szie.

Return type:

float

getMst(coll)[source]

Retrive previously calcuated minimum spanning tree (MST).

Parameters:coll (str) – Associated catalog collection name for the requested MST.
Returns:A cursor object
getOjbectByPos(coll, ra, dec)[source]

Query the data for a particular object.

Parameters:
  • coll (str) – The collection to search for object.
  • ra (float) – RA for the requested object.
  • dec (float) – DEC for the requested object.
Returns:

The data for the requested object stored in a dictionary.

getRectSelection(coll, swLng, swLat, neLng, neLat)[source]

Query data requested using selction tool.

Parameters:
  • coll (str) – The collection to search for data.
  • swLng (float) – The longitude of the southwest corner on the selection bound.
  • swLat (float) – The latitute of the southwest corner on the selection bound.
  • neLng (float) – The longitude of the northeast corner on the selection bound.
  • neLat (float) – The latitute of the northeast corner on the selection bound.
Returns:

A list of dictionary for the returned catalog.

getTileData(coll, xc, yc, zoom)[source]

Query the database for catalog in a particular tile.

Parameters:
  • coll (str) – A user-defined or automatically generated MongoDB collection name for a specific catalog.
  • xc (int) – x-coordinate the required tile.
  • yc (int) – y-coordinate the required tile.
  • zoom (int) – Zoom level for the required tile.
getVoronoi(collection)[source]

Retriev the entire catalog.

The retured catalog will be used to calculate Voronoi diagram at the front-end.

Parameters:collection (str) – Collection name for the required catalog.
Returns:A cursor object with the required data.

Server Handlers

class vizic.mongo_ext.extension.circlesHandler(application, request, **kwargs)[source]

Bases: notebook.base.handlers.IPythonHandler

Handler for data request on CirclesOverLays.

get(coll)[source]
class vizic.mongo_ext.extension.dbHandler(application, request, **kwargs)[source]

Bases: notebook.base.handlers.IPythonHandler

Handler for request on database change.

post()[source]
class vizic.mongo_ext.extension.healpixHandler(application, request, **kwargs)[source]

Bases: notebook.base.handlers.IPythonHandler

Handler for data request on healpix grid.

get(coll)[source]
vizic.mongo_ext.extension.load_jupyter_server_extension(nbapp)[source]

nbapp is instance of Jupyter.notebook.notebookapp.NotebookApp nbapp.web_app is instance of tornado.web.Application - can register new tornado.web.RequestHandlers to extend API backend.

class vizic.mongo_ext.extension.mstHandler(application, request, **kwargs)[source]

Bases: notebook.base.handlers.IPythonHandler

Handler for MST data request.

get(coll)[source]
class vizic.mongo_ext.extension.popupHandler(application, request, **kwargs)[source]

Bases: notebook.base.handlers.IPythonHandler

Handler for data request on clicked object.

get()[source]
class vizic.mongo_ext.extension.rangeHandler(application, request, **kwargs)[source]

Bases: notebook.base.handlers.IPythonHandler

Handler for updates on catalog metadata.

post()[source]
class vizic.mongo_ext.extension.selectionHandler(application, request, **kwargs)[source]

Bases: notebook.base.handlers.IPythonHandler

Handler for data request on selected objects by selection tool.

get()[source]
class vizic.mongo_ext.extension.tileHandler(application, request, **kwargs)[source]

Bases: notebook.base.handlers.IPythonHandler

Handler for tiled catalogs requests.

get(coll, zoom, xc, yc)[source]
class vizic.mongo_ext.extension.voronoiHandler(application, request, **kwargs)[source]

Bases: notebook.base.handlers.IPythonHandler

Hanlder for request on voronoi diagram data.

get(coll)[source]