包含所有ISTSOS编译的原始文件的模块。
istsos-proto的Python项目详细描述
ISTSOS_协议缓冲存储库。
此模块包含ISTSOS的所有原始文件。
qry utils
简单用法示例
fromistsosprotoimportqryconditions=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调用返回带有sql和参数列表的元组:
('(value_obs > $1 AND updated_obs IS NOT NULL)',[2.0])
比较运算符
支持的运算符:
- 空
- 非空
- 等于
- 不等于
- 喜欢
- 大于
- 大于u或等于
- 小于
- 小于u或等于u
空值
Where(operator=Where.NULL,property='updated')
结果:
("updated IS NULL",[])
非空
Where(operator=Where.EQUALS,property='updated')
结果:
("updated IS NOT NULL",[])
等于
Where(operator=Where.EQUALS,property='value',mesaure=10.9)
结果:
("value = $1",[10.9])
不等于
Where(operator=Where.NOT_EQUALS,property='value',mesaure=10.9)
结果:
("value <> $1",[10.9])
喜欢
Where(operator=Where.LIKE,property='name',text='%foo')
结果:
("name IS LIKE $1",['%foo])
与函数一起使用
支持的功能有:
- 以 开头
- ST U相交
- 圣德维辛
- St_包含
相交
fromqryimport*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调用返回带有sql和参数列表的元组:
("ST_Intersects(geom_loc, ST_GeomFromEWKT($1))",['SRID=4326;BOX(-180 -90, 180 90)'])
dWithin
fromqryimport*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调用返回带有sql和参数列表的元组:
("ST_DWithin(geom_loc, ST_GeomFromEWKT($1), $2)",['SRID=4326;BOX(-180 -90, 180 90)',200])
包含
fromqryimport*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调用返回带有sql和参数列表的元组:
("ST_Contains(geom_loc, ST_GeomFromEWKT($1))",['SRID=3857;POINT(3072163.4 7159374.1)'])