Skip to main content

Module containing all istsos compiled proto files.

Project description

istSOS𝜇 protocol buffer repository.

This module contains all the proto files of istsos.

Qry Utils

Simple usage example

from istsosproto import qry

conditions = qry(
    {
        "value": "value_obs",
        "updated": "updated_obs"
    }
).get_conditions(
    Where(
        operator=Where.AND,
        where=[
            Where(
                operator=Where.GREATER_THAN,
                property='value',
                measure=2.0
            ),
            Where(
                operator=Where.NOT_NULL,
                property='updated'
            )
        ]
    )
)

print(conditions)

get_conditions call returns a tuple with the SQL and a list of parameters:

('(value_obs > $1 AND updated_obs IS NOT NULL)', [2.0])

Comparison operators

Supported operators:

  • NULL
  • NOT_NULL
  • EQUALS
  • NOT_EQUALS
  • LIKE
  • GREATER_THAN
  • GREATER_THAN_OR_EQUAL_TO
  • LESS_THAN
  • LESS_THAN_OR_EQUAL_TO

NULL

Where(
    operator=Where.NULL,
    property='updated'
)

result:

(
    "updated IS NULL",
    []
)

NOT_NULL

Where(
    operator=Where.EQUALS,
    property='updated'
)

result:

(
    "updated IS NOT NULL",
    []
)

EQUALS

Where(
    operator=Where.EQUALS,
    property='value',
    mesaure=10.9
)

result:

(
    "value = $1",
    [10.9]
)

NOT_EQUALS

Where(
    operator=Where.NOT_EQUALS,
    property='value',
    mesaure=10.9
)

result:

(
    "value <> $1",
    [10.9]
)

LIKE

Where(
    operator=Where.LIKE,
    property='name',
    text='%foo'
)

result:

(
    "name IS LIKE $1",
    ['%foo]
)

Usage with function

Supported functions are:

  • STARTS_WITH
  • ST_INTERSECTS
  • ST_DWITHIN
  • ST_CONTAINS

INTERSECTS

from qry import *

conditions = qry(
    {
        "geom": "geom_loc"
    }
).get_conditions(
    Where(
        function=Where.ST_INTERSECTS,
        property='geom',
        ewkt='SRID=4326;BOX(-180 -90, 180 90)'
    )
)

print(conditions)

get_conditions call returns a tuple with the SQL and a list of parameters:

(
    "ST_Intersects(geom_loc, ST_GeomFromEWKT($1))",
    ['SRID=4326;BOX(-180 -90, 180 90)']
)

DWITHIN

from qry import *

conditions = qry(
    {
        "geom": "geom_loc"
    }
).get_conditions(
    Where(
        function=Where.ST_DWITHIN,
        property='geom',
        ewkt='SRID=3857;POINT(3072163.4 7159374.1)',
        xmeasure=200
    )
)

print(conditions)

get_conditions call returns a tuple with the SQL and a list of parameters:

(
    "ST_DWithin(geom_loc, ST_GeomFromEWKT($1), $2)",
    ['SRID=4326;BOX(-180 -90, 180 90)', 200]
)

CONTAINS

from qry import *

conditions = qry(
    {
        "geom": "geom_loc"
    }
).get_conditions(
    Where(
        function=Where.ST_CONTAINS,
        property='geom',
        ewkt='SRID=3857;POINT(3072163.4 7159374.1)',
        xmeasure=200
    )
)

print(conditions)

get_conditions call returns a tuple with the SQL and a list of parameters:

(
    "ST_Contains(geom_loc, ST_GeomFromEWKT($1))",
    ['SRID=3857;POINT(3072163.4 7159374.1)']
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

istsos-proto-0.0.1b3.tar.gz (15.1 kB view hashes)

Uploaded Source

Built Distribution

istsos_proto-0.0.1b3-py3-none-any.whl (21.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page