-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to extend _SQLITE_FUNCTIONS list? #356
Comments
Hi @shenzhuxi |
Hi @adrien-berchet geoalchemy2/geoalchemy2/functions.py Line 89 in b107df9
So we won't need to constantly make PR for all the different functions. |
Yeah we could provide an API so people can register whatever they need. _SQLITE_FUNCTIONS = {
"ST_GeomFromEWKT": "GeomFromEWKT",
"ST_GeomFromEWKB": "GeomFromEWKB",
"ST_AsBinary": "AsBinary",
"ST_AsEWKB": "AsEWKB",
"ST_AsGeoJSON": "AsGeoJSON",
}
# Default handlers are required for SQLAlchemy < 1.1
# See more details in https://github.com/geoalchemy/geoalchemy2/issues/213
def _compiles_default(cls):
def _compile_default(element, compiler, **kw):
return "{}({})".format(cls, compiler.process(element.clauses, **kw))
compiles(globals()[cls])(_compile_default)
def _compiles_sqlite(cls, fn):
def _compile_sqlite(element, compiler, **kw):
return "{}({})".format(fn, compiler.process(element.clauses, **kw))
compiles(globals()[cls], "sqlite")(_compile_sqlite)
def register_sqlite_mapping(mapping):
"""Register compilation mappings for the given functions.
``mapping`` should have the following form::
{
"function_name_1": "sqlite_function_name_1",
"function_name_2": "sqlite_function_name_2",
...
}
"""
for cls, fn in mapping.items():
_compiles_default(cls)
_compiles_sqlite(cls, fn)
register_sqlite_mapping(_SQLITE_FUNCTIONS) But adding entries in the |
#360 should allow you to register new mappings.
I am not sure to understand this part of the issue. The |
For example, in PostGIS, ST_Buffer can take options like quad_segs, endcap, join, mitre_limit and side from the third parameter. In the PostGIS statistics functions, for example, ST_Histogram will return a set of records. https://postgis.net/docs/RT_ST_Histogram.html |
Hmmm I see. There are several issues here:
|
Ah and please tell me if #360 is relevant to you? |
Hi @shenzhuxi |
Hi @adrien-berchet |
Hi @adrien-berchet
It works well.
Thanks! |
Thanks for your feedback @shenzhuxi ! |
I found that there are many common functions like MakeLine, MakePoint and etc. don't have ST_ prefix in spatialite.
https://www.gaia-gis.it/gaia-sins/spatialite-sql-latest.html
I wonder if there is any easy way to extend the _SQLITE_FUNCTIONS list?
geoalchemy2/geoalchemy2/functions.py
Line 235 in b107df9
The text was updated successfully, but these errors were encountered: