aisdb.database.sql_query_strings module

aisdb.database.sql_query_strings.has_mmsi(*, alias, mmsi, **_)[source]

SQL callback selecting a single vessel identifier

Parameters:
  • alias (string) – the ‘alias’ in a ‘WITH tablename AS alias …’ SQL statement

  • mmsi (int) – vessel identifier

Returns:

SQL code (string)

aisdb.database.sql_query_strings.in_bbox(*, alias, xmin, xmax, ymin, ymax, **_)[source]

SQL callback restricting vessels in bounding box region

Parameters:
  • alias (string) – the ‘alias’ in a ‘WITH tablename AS alias …’ SQL statement

  • xmin (float) – minimum longitude

  • xmax (float) – maximum longitude

  • ymin (float) – minimum latitude

  • ymax (float) – maximum latitude

Returns:

SQL code (string)

aisdb.database.sql_query_strings.in_bbox_geom(*, alias, xmin, xmax, ymin, ymax, **_)[source]

PostGIS-optimized SQL callback using GIST spatial index for bounding box queries. This is the PREFERRED method when geom column exists with GIST index.

Parameters:
  • alias (string) – table alias in SQL query

  • xmin (float) – minimum longitude

  • xmax (float) – maximum longitude

  • ymin (float) – minimum latitude

  • ymax (float) – maximum latitude

Returns:

SQL code (string) using PostGIS spatial operators

aisdb.database.sql_query_strings.in_mmsi(*, alias, mmsis, **_)[source]

SQL callback selecting multiple vessel identifiers

Parameters:
  • alias (string) – the ‘alias’ in a ‘WITH tablename AS alias …’ SQL statement

  • mmsis (tuple) – tuple of vessel identifiers (int)

Returns:

SQL code (string)

aisdb.database.sql_query_strings.in_polygon_geom(*, alias, polygon_wkt, srid=4326, **_)[source]

polygon_wkt: ‘POLYGON((lon lat, …))’ in WKT, srid default 4326. Uses && for fast reject + ST_Intersects for correctness.

aisdb.database.sql_query_strings.in_timerange(*, alias, start, end, **_)[source]

SQL callback restricting vessels in temporal range.

Parameters:
  • alias (string) – the ‘alias’ in a ‘WITH tablename AS alias …’ SQL statement

  • start (datetime)

  • end (datetime)

Returns:

SQL code (string)

aisdb.database.sql_query_strings.valid_mmsi(*, alias='m123', **_)[source]

SQL callback selecting all vessel identifiers within the valid vessel mmsi range, e.g. (201000000, 776000000)

Parameters:

alias (string) – the ‘alias’ in a ‘WITH tablename AS alias …’ SQL statement

Returns:

SQL code (string)