Comments (6)
I used this to create a gis db: http://www.jennifergd.com/post/7/
The json encoding can be implemented with a custom JSONEncoder:
https://gist.github.com/thomaxxl/53256daf0c94b53832fd6cc1959a1451
There also seems to be a geojson format that I can use, I'll check for that and the decoding later.
from safrs.
Hi,
can you provide me with a sample database and sqla models? Then I'll have a look.
I created some custom types here: https://github.com/thomaxxl/safrs/blob/master/safrs/safrs_types.py I guess
I think the approach would be similar.
from safrs.
Hi,
You can find a preconfigured postgres/postgis installation with a ready-to-use db "gis" here:
https://hub.docker.com/r/kartoza/postgis/
Assuming you run it with:
docker run --name "postgis" -p 25432:5432 -d -t kartoza/postgis
the corresponding connection string for the preconfigured db is:
postgresql://docker:docker@localhost:25432/gis
A minimal schema including a geometry column:
# pip install GeoAlchemy2
from geoalchemy2 import Geometry
class FooBar(SAFRSBase, db.Model):
__tablename__ = 'FooBar'
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
geom = db.Column(Geometry('POINT', srid=25833, dimension=2))
def __init__(self, geom):
self.geom = geom
A sample body for POST (which should successfully execute the INSERT):
{
"data": {
"attributes": {
"geom": "SRID=25833;POINT(-71.064544 42.28787)"
},
"type": "FooBar"
}
}
from safrs.
You can implement the POST/INSERT like this:
https://gist.github.com/thomaxxl/53256daf0c94b53832fd6cc1959a1451#file-geo1-py-L29-L34
Does this work for you?
I may add this to safrs eventually, but I don't know the geo types well enough.
from safrs.
Thank you for the impressively efficient work on this :)
The insert can also be done with the native representation:
"geom": "SRID=25833;POINT(-71.064544 42.28787)"
Decoding to the same format can similarly be done using (in sql syntax)
concat('SRID=',ST_SRID(geom), ';', ST_AsText(geom))
from safrs.
I implemented this with json encoding here:
https://github.com/thomaxxl/safrs/wiki/Postgis-Geoalchemy2 . I changed the safrs code a bit so I am able to add a sample value for the custom column type that will be rendered in the swagger
sample = {"coordinates": [-122.43129, 37.773972], "type": "Point"}
I guess you are able to figure out everything yourself.. if there's something else feel free to reopen or open a new issue.
from safrs.
Related Issues (20)
- Invalid swagger for "properties" under "definitions" breaks defintions display and validation HOT 7
- Patch method unreliable? HOT 2
- Read-only Columns HOT 2
- Flask-SQLAlchemy weakref KeyError
- in version 3.0 _s_count function does not apply filters to query HOT 1
- `count` property value is wrong for `GET` methods HOT 1
- Unable to delete entries HOT 5
- overriding methods does not work HOT 2
- extend API with custom classes HOT 1
- requirements.txt too restrictive HOT 1
- Duplicate definitions generated HOT 5
- safrs doesn't work in python 3.9 - TypeError HOT 4
- expose_existing starts but no swagger.json found HOT 1
- Run in example demo_relationship.py creating users or books in flask_admin returns Integrity Errors HOT 17
- Doubts about SAFRS HOT 2
- JSONAPI relationship missing in the swagger documentation HOT 4
- Swagger generation removing plurals HOT 1
- Flask 2.0 / Flask-restful "ImportError: cannot import name '_endpoint_from_view_func'" HOT 1
- Possible issue with BIGINT primary keys? HOT 5
- Make many to many relationship methods extendable HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from safrs.