<s> from flask_admin . contrib . sqla . typefmt import DEFAULT_FORMATTERS as BASE_FORMATTERS <EOL> from jinja2 import Markup <EOL> from wtforms . widgets import html_params <EOL> from geoalchemy2 . shape import to_shape <EOL> from geoalchemy2 . elements import WKBElement <EOL> from sqlalchemy import func <EOL> def geom_formatter ( view , value ) : <EOL> params = html_params ( ** { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT:100> , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : to_shape ( value ) . geom_type , <EOL> "<STR_LIT>" : <NUM_LIT:15> , <EOL> } ) <EOL> if value . srid is - <NUM_LIT:1> : <EOL> value . srid = <NUM_LIT> <EOL> geojson = view . model . query . with_entities ( func . ST_AsGeoJSON ( value ) ) . scalar ( ) <EOL> return Markup ( '<STR_LIT>' % ( params , geojson ) ) <EOL> DEFAULT_FORMATTERS = BASE_FORMATTERS . copy ( ) <EOL> DEFAULT_FORMATTERS [ WKBElement ] = geom_formatter </s>
