Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
flask-admin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
flask-admin
Commits
90b3e771
Commit
90b3e771
authored
Dec 06, 2014
by
Alex Kerney
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Passing the srid into GeoJSONField
parent
01683b92
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
2 deletions
+3
-2
fields.py
flask_admin/contrib/geoa/fields.py
+2
-2
form.py
flask_admin/contrib/geoa/form.py
+1
-0
No files found.
flask_admin/contrib/geoa/fields.py
View file @
90b3e771
...
...
@@ -37,7 +37,7 @@ class JSONField(TextAreaField):
class
GeoJSONField
(
JSONField
):
widget
=
LeafletWidget
()
def
__init__
(
self
,
label
=
None
,
validators
=
None
,
geometry_type
=
"GEOMETRY"
,
srid
=
'-1'
,
**
kwargs
):
def
__init__
(
self
,
label
=
None
,
validators
=
None
,
geometry_type
=
"GEOMETRY"
,
srid
=
'-1'
,
session
=
None
,
**
kwargs
):
super
(
GeoJSONField
,
self
)
.
__init__
(
label
,
validators
,
**
kwargs
)
self
.
web_srid
=
4326
self
.
srid
=
srid
...
...
@@ -55,4 +55,4 @@ class GeoJSONField(JSONField):
super
(
GeoJSONField
,
self
)
.
process_formdata
(
valuelist
)
web_shape
=
self
.
session
.
scalar
(
func
.
ST_AsText
(
func
.
ST_Transform
(
func
.
ST_GeomFromText
(
shape
(
self
.
data
)
.
wkt
,
self
.
web_srid
),
self
.
srid
)))
if
type
(
self
.
data
):
self
.
data
=
'SRID='
+
str
(
self
.
srid
)
+
';'
+
web_shape
self
.
data
=
'SRID='
+
str
(
self
.
srid
)
+
';'
+
str
(
web_shape
)
flask_admin/contrib/geoa/form.py
View file @
90b3e771
...
...
@@ -7,5 +7,6 @@ class AdminModelConverter(SQLAAdminConverter):
@
converts
(
'Geometry'
)
def
convert_geom
(
self
,
column
,
field_args
,
**
extra
):
field_args
[
'geometry_type'
]
=
column
.
type
.
geometry_type
field_args
[
'srid'
]
=
column
.
type
.
srid
field_args
[
'session'
]
=
self
.
session
return
GeoJSONField
(
**
field_args
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment