mirror of
https://github.com/django/django.git
synced 2025-10-26 15:16:09 +00:00
Fixed all the E203 violations
This commit is contained in:
@@ -398,7 +398,7 @@ def admin_list_filter(cl, spec):
|
||||
tpl = get_template(spec.template)
|
||||
return tpl.render(Context({
|
||||
'title': spec.title,
|
||||
'choices' : list(spec.choices(cl)),
|
||||
'choices': list(spec.choices(cl)),
|
||||
'spec': spec,
|
||||
}))
|
||||
|
||||
|
||||
@@ -60,10 +60,10 @@ def parse_rst(text, default_reference_context, thing_being_parsed=None):
|
||||
Convert the string from reST to an XHTML fragment.
|
||||
"""
|
||||
overrides = {
|
||||
'doctitle_xform' : True,
|
||||
'inital_header_level' : 3,
|
||||
"default_reference_context" : default_reference_context,
|
||||
"link_base" : reverse('django-admindocs-docroot').rstrip('/')
|
||||
'doctitle_xform': True,
|
||||
'inital_header_level': 3,
|
||||
"default_reference_context": default_reference_context,
|
||||
"link_base": reverse('django-admindocs-docroot').rstrip('/')
|
||||
}
|
||||
if thing_being_parsed:
|
||||
thing_being_parsed = force_bytes("<%s>" % thing_being_parsed)
|
||||
@@ -85,11 +85,11 @@ def parse_rst(text, default_reference_context, thing_being_parsed=None):
|
||||
# reST roles
|
||||
#
|
||||
ROLES = {
|
||||
'model' : '%s/models/%s/',
|
||||
'view' : '%s/views/%s/',
|
||||
'template' : '%s/templates/%s/',
|
||||
'filter' : '%s/filters/#%s',
|
||||
'tag' : '%s/tags/#%s',
|
||||
'model': '%s/models/%s/',
|
||||
'view': '%s/views/%s/',
|
||||
'template': '%s/templates/%s/',
|
||||
'filter': '%s/filters/#%s',
|
||||
'tag': '%s/tags/#%s',
|
||||
}
|
||||
|
||||
def create_reference_role(rolename, urlbase):
|
||||
|
||||
@@ -229,12 +229,12 @@ def model_detail(request, app_label, model_name):
|
||||
fields.append({
|
||||
'name': "%s.all" % field.name,
|
||||
"data_type": 'List',
|
||||
'verbose': utils.parse_rst(_("all %s") % verbose , 'model', _('model:') + opts.model_name),
|
||||
'verbose': utils.parse_rst(_("all %s") % verbose, 'model', _('model:') + opts.model_name),
|
||||
})
|
||||
fields.append({
|
||||
'name' : "%s.count" % field.name,
|
||||
'data_type' : 'Integer',
|
||||
'verbose' : utils.parse_rst(_("number of %s") % verbose , 'model', _('model:') + opts.model_name),
|
||||
'name': "%s.count" % field.name,
|
||||
'data_type': 'Integer',
|
||||
'verbose': utils.parse_rst(_("number of %s") % verbose, 'model', _('model:') + opts.model_name),
|
||||
})
|
||||
|
||||
# Gather model methods.
|
||||
@@ -260,14 +260,14 @@ def model_detail(request, app_label, model_name):
|
||||
verbose = _("related `%(app_label)s.%(object_name)s` objects") % {'app_label': rel.opts.app_label, 'object_name': rel.opts.object_name}
|
||||
accessor = rel.get_accessor_name()
|
||||
fields.append({
|
||||
'name' : "%s.all" % accessor,
|
||||
'data_type' : 'List',
|
||||
'verbose' : utils.parse_rst(_("all %s") % verbose , 'model', _('model:') + opts.model_name),
|
||||
'name': "%s.all" % accessor,
|
||||
'data_type': 'List',
|
||||
'verbose': utils.parse_rst(_("all %s") % verbose, 'model', _('model:') + opts.model_name),
|
||||
})
|
||||
fields.append({
|
||||
'name' : "%s.count" % accessor,
|
||||
'data_type' : 'Integer',
|
||||
'verbose' : utils.parse_rst(_("number of %s") % verbose , 'model', _('model:') + opts.model_name),
|
||||
'name': "%s.count" % accessor,
|
||||
'data_type': 'Integer',
|
||||
'verbose': utils.parse_rst(_("number of %s") % verbose, 'model', _('model:') + opts.model_name),
|
||||
})
|
||||
return render_to_response('admin_doc/model_detail.html', {
|
||||
'root_path': urlresolvers.reverse('admin:index'),
|
||||
|
||||
@@ -86,39 +86,39 @@ class GeoModelAdmin(ModelAdmin):
|
||||
wms_options = ["%s: '%s'" % pair for pair in self.wms_options.items()]
|
||||
wms_options = ', %s' % ', '.join(wms_options)
|
||||
|
||||
params = {'default_lon' : self.default_lon,
|
||||
'default_lat' : self.default_lat,
|
||||
'default_zoom' : self.default_zoom,
|
||||
'display_wkt' : self.debug or self.display_wkt,
|
||||
'geom_type' : OGRGeomType(db_field.geom_type),
|
||||
'field_name' : db_field.name,
|
||||
'is_collection' : is_collection,
|
||||
'scrollable' : self.scrollable,
|
||||
'layerswitcher' : self.layerswitcher,
|
||||
'collection_type' : collection_type,
|
||||
'is_generic' : db_field.geom_type == 'GEOMETRY',
|
||||
'is_linestring' : db_field.geom_type in ('LINESTRING', 'MULTILINESTRING'),
|
||||
'is_polygon' : db_field.geom_type in ('POLYGON', 'MULTIPOLYGON'),
|
||||
'is_point' : db_field.geom_type in ('POINT', 'MULTIPOINT'),
|
||||
'num_zoom' : self.num_zoom,
|
||||
'max_zoom' : self.max_zoom,
|
||||
'min_zoom' : self.min_zoom,
|
||||
'units' : self.units, # likely should get from object
|
||||
'max_resolution' : self.max_resolution,
|
||||
'max_extent' : self.max_extent,
|
||||
'modifiable' : self.modifiable,
|
||||
'mouse_position' : self.mouse_position,
|
||||
'scale_text' : self.scale_text,
|
||||
'map_width' : self.map_width,
|
||||
'map_height' : self.map_height,
|
||||
'point_zoom' : self.point_zoom,
|
||||
'srid' : self.map_srid,
|
||||
'display_srid' : self.display_srid,
|
||||
'wms_url' : self.wms_url,
|
||||
'wms_layer' : self.wms_layer,
|
||||
'wms_name' : self.wms_name,
|
||||
'wms_options' : wms_options,
|
||||
'debug' : self.debug,
|
||||
params = {'default_lon': self.default_lon,
|
||||
'default_lat': self.default_lat,
|
||||
'default_zoom': self.default_zoom,
|
||||
'display_wkt': self.debug or self.display_wkt,
|
||||
'geom_type': OGRGeomType(db_field.geom_type),
|
||||
'field_name': db_field.name,
|
||||
'is_collection': is_collection,
|
||||
'scrollable': self.scrollable,
|
||||
'layerswitcher': self.layerswitcher,
|
||||
'collection_type': collection_type,
|
||||
'is_generic': db_field.geom_type == 'GEOMETRY',
|
||||
'is_linestring': db_field.geom_type in ('LINESTRING', 'MULTILINESTRING'),
|
||||
'is_polygon': db_field.geom_type in ('POLYGON', 'MULTIPOLYGON'),
|
||||
'is_point': db_field.geom_type in ('POINT', 'MULTIPOINT'),
|
||||
'num_zoom': self.num_zoom,
|
||||
'max_zoom': self.max_zoom,
|
||||
'min_zoom': self.min_zoom,
|
||||
'units': self.units, # likely should get from object
|
||||
'max_resolution': self.max_resolution,
|
||||
'max_extent': self.max_extent,
|
||||
'modifiable': self.modifiable,
|
||||
'mouse_position': self.mouse_position,
|
||||
'scale_text': self.scale_text,
|
||||
'map_width': self.map_width,
|
||||
'map_height': self.map_height,
|
||||
'point_zoom': self.point_zoom,
|
||||
'srid': self.map_srid,
|
||||
'display_srid': self.display_srid,
|
||||
'wms_url': self.wms_url,
|
||||
'wms_layer': self.wms_layer,
|
||||
'wms_name': self.wms_name,
|
||||
'wms_options': wms_options,
|
||||
'debug': self.debug,
|
||||
}
|
||||
return OLMap
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ from django.contrib.gis.geos import GEOSGeometry, GEOSException
|
||||
|
||||
# Creating a template context that contains Django settings
|
||||
# values needed by admin map templates.
|
||||
geo_context = Context({'LANGUAGE_BIDI' : translation.get_language_bidi()})
|
||||
geo_context = Context({'LANGUAGE_BIDI': translation.get_language_bidi()})
|
||||
logger = logging.getLogger('django.contrib.gis')
|
||||
|
||||
|
||||
|
||||
@@ -109,33 +109,33 @@ class OracleOperations(DatabaseOperations, BaseSpatialOperations):
|
||||
select = 'SDO_UTIL.TO_WKTGEOMETRY(%s)'
|
||||
|
||||
distance_functions = {
|
||||
'distance_gt' : (SDODistance('>'), dtypes),
|
||||
'distance_gte' : (SDODistance('>='), dtypes),
|
||||
'distance_lt' : (SDODistance('<'), dtypes),
|
||||
'distance_lte' : (SDODistance('<='), dtypes),
|
||||
'dwithin' : (SDODWithin(), dtypes),
|
||||
'distance_gt': (SDODistance('>'), dtypes),
|
||||
'distance_gte': (SDODistance('>='), dtypes),
|
||||
'distance_lt': (SDODistance('<'), dtypes),
|
||||
'distance_lte': (SDODistance('<='), dtypes),
|
||||
'dwithin': (SDODWithin(), dtypes),
|
||||
}
|
||||
|
||||
geometry_functions = {
|
||||
'contains' : SDOOperation('SDO_CONTAINS'),
|
||||
'coveredby' : SDOOperation('SDO_COVEREDBY'),
|
||||
'covers' : SDOOperation('SDO_COVERS'),
|
||||
'disjoint' : SDOGeomRelate('DISJOINT'),
|
||||
'intersects' : SDOOperation('SDO_OVERLAPBDYINTERSECT'), # TODO: Is this really the same as ST_Intersects()?
|
||||
'equals' : SDOOperation('SDO_EQUAL'),
|
||||
'exact' : SDOOperation('SDO_EQUAL'),
|
||||
'overlaps' : SDOOperation('SDO_OVERLAPS'),
|
||||
'same_as' : SDOOperation('SDO_EQUAL'),
|
||||
'relate' : (SDORelate, six.string_types), # Oracle uses a different syntax, e.g., 'mask=inside+touch'
|
||||
'touches' : SDOOperation('SDO_TOUCH'),
|
||||
'within' : SDOOperation('SDO_INSIDE'),
|
||||
'contains': SDOOperation('SDO_CONTAINS'),
|
||||
'coveredby': SDOOperation('SDO_COVEREDBY'),
|
||||
'covers': SDOOperation('SDO_COVERS'),
|
||||
'disjoint': SDOGeomRelate('DISJOINT'),
|
||||
'intersects': SDOOperation('SDO_OVERLAPBDYINTERSECT'), # TODO: Is this really the same as ST_Intersects()?
|
||||
'equals': SDOOperation('SDO_EQUAL'),
|
||||
'exact': SDOOperation('SDO_EQUAL'),
|
||||
'overlaps': SDOOperation('SDO_OVERLAPS'),
|
||||
'same_as': SDOOperation('SDO_EQUAL'),
|
||||
'relate': (SDORelate, six.string_types), # Oracle uses a different syntax, e.g., 'mask=inside+touch'
|
||||
'touches': SDOOperation('SDO_TOUCH'),
|
||||
'within': SDOOperation('SDO_INSIDE'),
|
||||
}
|
||||
geometry_functions.update(distance_functions)
|
||||
|
||||
gis_terms = set(['isnull'])
|
||||
gis_terms.update(geometry_functions)
|
||||
|
||||
truncate_params = {'relate' : None}
|
||||
truncate_params = {'relate': None}
|
||||
|
||||
def convert_extent(self, clob):
|
||||
if clob:
|
||||
|
||||
@@ -32,14 +32,14 @@ class PostGISIntrospection(DatabaseIntrospection):
|
||||
try:
|
||||
cursor.execute(oid_sql, ('geometry',))
|
||||
GEOM_TYPE = cursor.fetchone()[0]
|
||||
postgis_types = {GEOM_TYPE : 'GeometryField'}
|
||||
postgis_types = {GEOM_TYPE: 'GeometryField'}
|
||||
if self.connection.ops.geography:
|
||||
cursor.execute(oid_sql, ('geography',))
|
||||
GEOG_TYPE = cursor.fetchone()[0]
|
||||
# The value for the geography type is actually a tuple
|
||||
# to pass in the `geography=True` keyword to the field
|
||||
# definition.
|
||||
postgis_types[GEOG_TYPE] = ('GeometryField', {'geography' : True})
|
||||
postgis_types[GEOG_TYPE] = ('GeometryField', {'geography': True})
|
||||
finally:
|
||||
cursor.close()
|
||||
|
||||
|
||||
@@ -84,56 +84,56 @@ class PostGISOperations(DatabaseOperations, BaseSpatialOperations):
|
||||
self.geometry_operators = {
|
||||
# The "&<" operator returns true if A's bounding box overlaps or
|
||||
# is to the left of B's bounding box.
|
||||
'overlaps_left' : PostGISOperator('&<'),
|
||||
'overlaps_left': PostGISOperator('&<'),
|
||||
# The "&>" operator returns true if A's bounding box overlaps or
|
||||
# is to the right of B's bounding box.
|
||||
'overlaps_right' : PostGISOperator('&>'),
|
||||
'overlaps_right': PostGISOperator('&>'),
|
||||
# The "<<" operator returns true if A's bounding box is strictly
|
||||
# to the left of B's bounding box.
|
||||
'left' : PostGISOperator('<<'),
|
||||
'left': PostGISOperator('<<'),
|
||||
# The ">>" operator returns true if A's bounding box is strictly
|
||||
# to the right of B's bounding box.
|
||||
'right' : PostGISOperator('>>'),
|
||||
'right': PostGISOperator('>>'),
|
||||
# The "&<|" operator returns true if A's bounding box overlaps or
|
||||
# is below B's bounding box.
|
||||
'overlaps_below' : PostGISOperator('&<|'),
|
||||
'overlaps_below': PostGISOperator('&<|'),
|
||||
# The "|&>" operator returns true if A's bounding box overlaps or
|
||||
# is above B's bounding box.
|
||||
'overlaps_above' : PostGISOperator('|&>'),
|
||||
'overlaps_above': PostGISOperator('|&>'),
|
||||
# The "<<|" operator returns true if A's bounding box is strictly
|
||||
# below B's bounding box.
|
||||
'strictly_below' : PostGISOperator('<<|'),
|
||||
'strictly_below': PostGISOperator('<<|'),
|
||||
# The "|>>" operator returns true if A's bounding box is strictly
|
||||
# above B's bounding box.
|
||||
'strictly_above' : PostGISOperator('|>>'),
|
||||
'strictly_above': PostGISOperator('|>>'),
|
||||
# The "~=" operator is the "same as" operator. It tests actual
|
||||
# geometric equality of two features. So if A and B are the same feature,
|
||||
# vertex-by-vertex, the operator returns true.
|
||||
'same_as' : PostGISOperator('~='),
|
||||
'exact' : PostGISOperator('~='),
|
||||
'same_as': PostGISOperator('~='),
|
||||
'exact': PostGISOperator('~='),
|
||||
# The "@" operator returns true if A's bounding box is completely contained
|
||||
# by B's bounding box.
|
||||
'contained' : PostGISOperator('@'),
|
||||
'contained': PostGISOperator('@'),
|
||||
# The "~" operator returns true if A's bounding box completely contains
|
||||
# by B's bounding box.
|
||||
'bbcontains' : PostGISOperator('~'),
|
||||
'bbcontains': PostGISOperator('~'),
|
||||
# The "&&" operator returns true if A's bounding box overlaps
|
||||
# B's bounding box.
|
||||
'bboverlaps' : PostGISOperator('&&'),
|
||||
'bboverlaps': PostGISOperator('&&'),
|
||||
}
|
||||
|
||||
self.geometry_functions = {
|
||||
'equals' : PostGISFunction(prefix, 'Equals'),
|
||||
'disjoint' : PostGISFunction(prefix, 'Disjoint'),
|
||||
'touches' : PostGISFunction(prefix, 'Touches'),
|
||||
'crosses' : PostGISFunction(prefix, 'Crosses'),
|
||||
'within' : PostGISFunction(prefix, 'Within'),
|
||||
'overlaps' : PostGISFunction(prefix, 'Overlaps'),
|
||||
'contains' : PostGISFunction(prefix, 'Contains'),
|
||||
'intersects' : PostGISFunction(prefix, 'Intersects'),
|
||||
'relate' : (PostGISRelate, six.string_types),
|
||||
'coveredby' : PostGISFunction(prefix, 'CoveredBy'),
|
||||
'covers' : PostGISFunction(prefix, 'Covers'),
|
||||
'equals': PostGISFunction(prefix, 'Equals'),
|
||||
'disjoint': PostGISFunction(prefix, 'Disjoint'),
|
||||
'touches': PostGISFunction(prefix, 'Touches'),
|
||||
'crosses': PostGISFunction(prefix, 'Crosses'),
|
||||
'within': PostGISFunction(prefix, 'Within'),
|
||||
'overlaps': PostGISFunction(prefix, 'Overlaps'),
|
||||
'contains': PostGISFunction(prefix, 'Contains'),
|
||||
'intersects': PostGISFunction(prefix, 'Intersects'),
|
||||
'relate': (PostGISRelate, six.string_types),
|
||||
'coveredby': PostGISFunction(prefix, 'CoveredBy'),
|
||||
'covers': PostGISFunction(prefix, 'Covers'),
|
||||
}
|
||||
|
||||
# Valid distance types and substitutions
|
||||
@@ -141,16 +141,16 @@ class PostGISOperations(DatabaseOperations, BaseSpatialOperations):
|
||||
|
||||
def get_dist_ops(operator):
|
||||
"Returns operations for both regular and spherical distances."
|
||||
return {'cartesian' : PostGISDistance(prefix, operator),
|
||||
'sphere' : PostGISSphereDistance(prefix, operator),
|
||||
'spheroid' : PostGISSpheroidDistance(prefix, operator),
|
||||
return {'cartesian': PostGISDistance(prefix, operator),
|
||||
'sphere': PostGISSphereDistance(prefix, operator),
|
||||
'spheroid': PostGISSpheroidDistance(prefix, operator),
|
||||
}
|
||||
self.distance_functions = {
|
||||
'distance_gt' : (get_dist_ops('>'), dtypes),
|
||||
'distance_gte' : (get_dist_ops('>='), dtypes),
|
||||
'distance_lt' : (get_dist_ops('<'), dtypes),
|
||||
'distance_lte' : (get_dist_ops('<='), dtypes),
|
||||
'dwithin' : (PostGISFunctionParam(prefix, 'DWithin'), dtypes)
|
||||
'distance_gt': (get_dist_ops('>'), dtypes),
|
||||
'distance_gte': (get_dist_ops('>='), dtypes),
|
||||
'distance_lt': (get_dist_ops('<'), dtypes),
|
||||
'distance_lte': (get_dist_ops('<='), dtypes),
|
||||
'dwithin': (PostGISFunctionParam(prefix, 'DWithin'), dtypes)
|
||||
}
|
||||
|
||||
# Adding the distance functions to the geometries lookup.
|
||||
|
||||
@@ -9,13 +9,13 @@ class GeoFlexibleFieldLookupDict(FlexibleFieldLookupDict):
|
||||
"""
|
||||
base_data_types_reverse = FlexibleFieldLookupDict.base_data_types_reverse.copy()
|
||||
base_data_types_reverse.update(
|
||||
{'point' : 'GeometryField',
|
||||
'linestring' : 'GeometryField',
|
||||
'polygon' : 'GeometryField',
|
||||
'multipoint' : 'GeometryField',
|
||||
'multilinestring' : 'GeometryField',
|
||||
'multipolygon' : 'GeometryField',
|
||||
'geometrycollection' : 'GeometryField',
|
||||
{'point': 'GeometryField',
|
||||
'linestring': 'GeometryField',
|
||||
'polygon': 'GeometryField',
|
||||
'multipoint': 'GeometryField',
|
||||
'multilinestring': 'GeometryField',
|
||||
'multipolygon': 'GeometryField',
|
||||
'geometrycollection': 'GeometryField',
|
||||
})
|
||||
|
||||
class SpatiaLiteIntrospection(DatabaseIntrospection):
|
||||
|
||||
@@ -86,31 +86,31 @@ class SpatiaLiteOperations(DatabaseOperations, BaseSpatialOperations):
|
||||
select = 'AsText(%s)'
|
||||
|
||||
geometry_functions = {
|
||||
'equals' : SpatiaLiteFunction('Equals'),
|
||||
'disjoint' : SpatiaLiteFunction('Disjoint'),
|
||||
'touches' : SpatiaLiteFunction('Touches'),
|
||||
'crosses' : SpatiaLiteFunction('Crosses'),
|
||||
'within' : SpatiaLiteFunction('Within'),
|
||||
'overlaps' : SpatiaLiteFunction('Overlaps'),
|
||||
'contains' : SpatiaLiteFunction('Contains'),
|
||||
'intersects' : SpatiaLiteFunction('Intersects'),
|
||||
'relate' : (SpatiaLiteRelate, six.string_types),
|
||||
'equals': SpatiaLiteFunction('Equals'),
|
||||
'disjoint': SpatiaLiteFunction('Disjoint'),
|
||||
'touches': SpatiaLiteFunction('Touches'),
|
||||
'crosses': SpatiaLiteFunction('Crosses'),
|
||||
'within': SpatiaLiteFunction('Within'),
|
||||
'overlaps': SpatiaLiteFunction('Overlaps'),
|
||||
'contains': SpatiaLiteFunction('Contains'),
|
||||
'intersects': SpatiaLiteFunction('Intersects'),
|
||||
'relate': (SpatiaLiteRelate, six.string_types),
|
||||
# Returns true if B's bounding box completely contains A's bounding box.
|
||||
'contained' : SpatiaLiteFunction('MbrWithin'),
|
||||
'contained': SpatiaLiteFunction('MbrWithin'),
|
||||
# Returns true if A's bounding box completely contains B's bounding box.
|
||||
'bbcontains' : SpatiaLiteFunction('MbrContains'),
|
||||
'bbcontains': SpatiaLiteFunction('MbrContains'),
|
||||
# Returns true if A's bounding box overlaps B's bounding box.
|
||||
'bboverlaps' : SpatiaLiteFunction('MbrOverlaps'),
|
||||
'bboverlaps': SpatiaLiteFunction('MbrOverlaps'),
|
||||
# These are implemented here as synonyms for Equals
|
||||
'same_as' : SpatiaLiteFunction('Equals'),
|
||||
'exact' : SpatiaLiteFunction('Equals'),
|
||||
'same_as': SpatiaLiteFunction('Equals'),
|
||||
'exact': SpatiaLiteFunction('Equals'),
|
||||
}
|
||||
|
||||
distance_functions = {
|
||||
'distance_gt' : (get_dist_ops('>'), dtypes),
|
||||
'distance_gte' : (get_dist_ops('>='), dtypes),
|
||||
'distance_lt' : (get_dist_ops('<'), dtypes),
|
||||
'distance_lte' : (get_dist_ops('<='), dtypes),
|
||||
'distance_gt': (get_dist_ops('>'), dtypes),
|
||||
'distance_gte': (get_dist_ops('>='), dtypes),
|
||||
'distance_lt': (get_dist_ops('<'), dtypes),
|
||||
'distance_lte': (get_dist_ops('<='), dtypes),
|
||||
}
|
||||
geometry_functions.update(distance_functions)
|
||||
|
||||
|
||||
@@ -19,11 +19,11 @@ class SpatialOperation(object):
|
||||
return self.sql_template % self.params(geo_col, geometry), []
|
||||
|
||||
def params(self, geo_col, geometry):
|
||||
params = {'function' : self.function,
|
||||
'geo_col' : geo_col,
|
||||
'geometry' : geometry,
|
||||
'operator' : self.operator,
|
||||
'result' : self.result,
|
||||
params = {'function': self.function,
|
||||
'geo_col': geo_col,
|
||||
'geometry': geometry,
|
||||
'operator': self.operator,
|
||||
'result': self.result,
|
||||
}
|
||||
params.update(self.extra)
|
||||
return params
|
||||
@@ -36,9 +36,9 @@ class SpatialFunction(SpatialOperation):
|
||||
|
||||
def __init__(self, func, result='', operator='', **kwargs):
|
||||
# Getting the function prefix.
|
||||
default = {'function' : func,
|
||||
'operator' : operator,
|
||||
'result' : result
|
||||
default = {'function': func,
|
||||
'operator': operator,
|
||||
'result': result
|
||||
}
|
||||
kwargs.update(default)
|
||||
super(SpatialFunction, self).__init__(**kwargs)
|
||||
|
||||
@@ -203,9 +203,9 @@ class GeometryField(Field):
|
||||
return connection.ops.geo_db_type(self)
|
||||
|
||||
def formfield(self, **kwargs):
|
||||
defaults = {'form_class' : self.form_class,
|
||||
'geom_type' : self.geom_type,
|
||||
'srid' : self.srid,
|
||||
defaults = {'form_class': self.form_class,
|
||||
'geom_type': self.geom_type,
|
||||
'srid': self.srid,
|
||||
}
|
||||
defaults.update(kwargs)
|
||||
if (self.dim > 2 and not 'widget' in kwargs and
|
||||
|
||||
@@ -41,9 +41,9 @@ class GeoQuerySet(QuerySet):
|
||||
# Peforming setup here rather than in `_spatial_attribute` so that
|
||||
# we can get the units for `AreaField`.
|
||||
procedure_args, geo_field = self._spatial_setup('area', field_name=kwargs.get('field_name', None))
|
||||
s = {'procedure_args' : procedure_args,
|
||||
'geo_field' : geo_field,
|
||||
'setup' : False,
|
||||
s = {'procedure_args': procedure_args,
|
||||
'geo_field': geo_field,
|
||||
'setup': False,
|
||||
}
|
||||
connection = connections[self.db]
|
||||
backend = connection.ops
|
||||
@@ -170,9 +170,9 @@ class GeoQuerySet(QuerySet):
|
||||
options = 1
|
||||
elif bbox:
|
||||
options = 2
|
||||
s = {'desc' : 'GeoJSON',
|
||||
'procedure_args' : {'precision' : precision, 'options' : options},
|
||||
'procedure_fmt' : '%(geo_col)s,%(precision)s,%(options)s',
|
||||
s = {'desc': 'GeoJSON',
|
||||
'procedure_args': {'precision': precision, 'options': options},
|
||||
'procedure_fmt': '%(geo_col)s,%(precision)s,%(options)s',
|
||||
}
|
||||
return self._spatial_attribute('geojson', s, **kwargs)
|
||||
|
||||
@@ -184,7 +184,7 @@ class GeoQuerySet(QuerySet):
|
||||
The `precision` keyword may be used to custom the number of
|
||||
_characters_ used in the output GeoHash, the default is 20.
|
||||
"""
|
||||
s = {'desc' : 'GeoHash',
|
||||
s = {'desc': 'GeoHash',
|
||||
'procedure_args': {'precision': precision},
|
||||
'procedure_fmt': '%(geo_col)s,%(precision)s',
|
||||
}
|
||||
@@ -196,7 +196,7 @@ class GeoQuerySet(QuerySet):
|
||||
on each element of the GeoQuerySet.
|
||||
"""
|
||||
backend = connections[self.db].ops
|
||||
s = {'desc' : 'GML', 'procedure_args' : {'precision' : precision}}
|
||||
s = {'desc': 'GML', 'procedure_args': {'precision': precision}}
|
||||
if backend.postgis:
|
||||
# PostGIS AsGML() aggregate function parameter order depends on the
|
||||
# version -- uggh.
|
||||
@@ -204,7 +204,7 @@ class GeoQuerySet(QuerySet):
|
||||
s['procedure_fmt'] = '%(version)s,%(geo_col)s,%(precision)s'
|
||||
else:
|
||||
s['procedure_fmt'] = '%(geo_col)s,%(precision)s,%(version)s'
|
||||
s['procedure_args'] = {'precision' : precision, 'version' : version}
|
||||
s['procedure_args'] = {'precision': precision, 'version': version}
|
||||
|
||||
return self._spatial_attribute('gml', s, **kwargs)
|
||||
|
||||
@@ -221,9 +221,9 @@ class GeoQuerySet(QuerySet):
|
||||
Returns KML representation of the geometry field in a `kml`
|
||||
attribute on each element of this GeoQuerySet.
|
||||
"""
|
||||
s = {'desc' : 'KML',
|
||||
'procedure_fmt' : '%(geo_col)s,%(precision)s',
|
||||
'procedure_args' : {'precision' : kwargs.pop('precision', 8)},
|
||||
s = {'desc': 'KML',
|
||||
'procedure_fmt': '%(geo_col)s,%(precision)s',
|
||||
'procedure_args': {'precision': kwargs.pop('precision', 8)},
|
||||
}
|
||||
return self._spatial_attribute('kml', s, **kwargs)
|
||||
|
||||
@@ -300,14 +300,14 @@ class GeoQuerySet(QuerySet):
|
||||
if connections[self.db].ops.spatialite:
|
||||
if z != 0.0:
|
||||
raise NotImplementedError('SpatiaLite does not support 3D scaling.')
|
||||
s = {'procedure_fmt' : '%(geo_col)s,%(x)s,%(y)s',
|
||||
'procedure_args' : {'x' : x, 'y' : y},
|
||||
'select_field' : GeomField(),
|
||||
s = {'procedure_fmt': '%(geo_col)s,%(x)s,%(y)s',
|
||||
'procedure_args': {'x': x, 'y': y},
|
||||
'select_field': GeomField(),
|
||||
}
|
||||
else:
|
||||
s = {'procedure_fmt' : '%(geo_col)s,%(x)s,%(y)s,%(z)s',
|
||||
'procedure_args' : {'x' : x, 'y' : y, 'z' : z},
|
||||
'select_field' : GeomField(),
|
||||
s = {'procedure_fmt': '%(geo_col)s,%(x)s,%(y)s,%(z)s',
|
||||
'procedure_args': {'x': x, 'y': y, 'z': z},
|
||||
'select_field': GeomField(),
|
||||
}
|
||||
return self._spatial_attribute('scale', s, **kwargs)
|
||||
|
||||
@@ -327,22 +327,22 @@ class GeoQuerySet(QuerySet):
|
||||
if nargs == 1:
|
||||
size = args[0]
|
||||
procedure_fmt = '%(geo_col)s,%(size)s'
|
||||
procedure_args = {'size' : size}
|
||||
procedure_args = {'size': size}
|
||||
elif nargs == 2:
|
||||
xsize, ysize = args
|
||||
procedure_fmt = '%(geo_col)s,%(xsize)s,%(ysize)s'
|
||||
procedure_args = {'xsize' : xsize, 'ysize' : ysize}
|
||||
procedure_args = {'xsize': xsize, 'ysize': ysize}
|
||||
elif nargs == 4:
|
||||
xsize, ysize, xorigin, yorigin = args
|
||||
procedure_fmt = '%(geo_col)s,%(xorigin)s,%(yorigin)s,%(xsize)s,%(ysize)s'
|
||||
procedure_args = {'xsize' : xsize, 'ysize' : ysize,
|
||||
'xorigin' : xorigin, 'yorigin' : yorigin}
|
||||
procedure_args = {'xsize': xsize, 'ysize': ysize,
|
||||
'xorigin': xorigin, 'yorigin': yorigin}
|
||||
else:
|
||||
raise ValueError('Must provide 1, 2, or 4 arguments to `snap_to_grid`.')
|
||||
|
||||
s = {'procedure_fmt' : procedure_fmt,
|
||||
'procedure_args' : procedure_args,
|
||||
'select_field' : GeomField(),
|
||||
s = {'procedure_fmt': procedure_fmt,
|
||||
'procedure_args': procedure_args,
|
||||
'select_field': GeomField(),
|
||||
}
|
||||
|
||||
return self._spatial_attribute('snap_to_grid', s, **kwargs)
|
||||
@@ -362,10 +362,10 @@ class GeoQuerySet(QuerySet):
|
||||
relative = int(bool(relative))
|
||||
if not isinstance(precision, six.integer_types):
|
||||
raise TypeError('SVG precision keyword argument must be an integer.')
|
||||
s = {'desc' : 'SVG',
|
||||
'procedure_fmt' : '%(geo_col)s,%(rel)s,%(precision)s',
|
||||
'procedure_args' : {'rel' : relative,
|
||||
'precision' : precision,
|
||||
s = {'desc': 'SVG',
|
||||
'procedure_fmt': '%(geo_col)s,%(rel)s,%(precision)s',
|
||||
'procedure_args': {'rel': relative,
|
||||
'precision': precision,
|
||||
}
|
||||
}
|
||||
return self._spatial_attribute('svg', s, **kwargs)
|
||||
@@ -385,14 +385,14 @@ class GeoQuerySet(QuerySet):
|
||||
if connections[self.db].ops.spatialite:
|
||||
if z != 0.0:
|
||||
raise NotImplementedError('SpatiaLite does not support 3D translation.')
|
||||
s = {'procedure_fmt' : '%(geo_col)s,%(x)s,%(y)s',
|
||||
'procedure_args' : {'x' : x, 'y' : y},
|
||||
'select_field' : GeomField(),
|
||||
s = {'procedure_fmt': '%(geo_col)s,%(x)s,%(y)s',
|
||||
'procedure_args': {'x': x, 'y': y},
|
||||
'select_field': GeomField(),
|
||||
}
|
||||
else:
|
||||
s = {'procedure_fmt' : '%(geo_col)s,%(x)s,%(y)s,%(z)s',
|
||||
'procedure_args' : {'x' : x, 'y' : y, 'z' : z},
|
||||
'select_field' : GeomField(),
|
||||
s = {'procedure_fmt': '%(geo_col)s,%(x)s,%(y)s,%(z)s',
|
||||
'procedure_args': {'x': x, 'y': y, 'z': z},
|
||||
'select_field': GeomField(),
|
||||
}
|
||||
return self._spatial_attribute('translate', s, **kwargs)
|
||||
|
||||
@@ -455,7 +455,7 @@ class GeoQuerySet(QuerySet):
|
||||
(desc, connection.ops.name))
|
||||
|
||||
# Initializing the procedure arguments.
|
||||
procedure_args = {'function' : func}
|
||||
procedure_args = {'function': func}
|
||||
|
||||
# Is there a geographic field in the model to perform this
|
||||
# operation on?
|
||||
@@ -580,7 +580,7 @@ class GeoQuerySet(QuerySet):
|
||||
# Finally, setting the extra selection attribute with
|
||||
# the format string expanded with the stored procedure
|
||||
# arguments.
|
||||
return self.extra(select={model_att : fmt % settings['procedure_args']},
|
||||
return self.extra(select={model_att: fmt % settings['procedure_args']},
|
||||
select_params=settings['select_params'])
|
||||
|
||||
def _distance_attribute(self, func, geom=None, tolerance=0.05, spheroid=False, **kwargs):
|
||||
@@ -695,29 +695,29 @@ class GeoQuerySet(QuerySet):
|
||||
if spheroid:
|
||||
# Call to distance_spheroid() requires spheroid param as well.
|
||||
procedure_fmt += ",'%(spheroid)s'"
|
||||
procedure_args.update({'function' : backend.distance_spheroid, 'spheroid' : params[1]})
|
||||
procedure_args.update({'function': backend.distance_spheroid, 'spheroid': params[1]})
|
||||
else:
|
||||
procedure_args.update({'function' : backend.distance_sphere})
|
||||
procedure_args.update({'function': backend.distance_sphere})
|
||||
elif length or perimeter:
|
||||
procedure_fmt = '%(geo_col)s'
|
||||
if not geography and geodetic and length:
|
||||
# There's no `length_sphere`, and `length_spheroid` also
|
||||
# works on 3D geometries.
|
||||
procedure_fmt += ",'%(spheroid)s'"
|
||||
procedure_args.update({'function' : backend.length_spheroid, 'spheroid' : params[1]})
|
||||
procedure_args.update({'function': backend.length_spheroid, 'spheroid': params[1]})
|
||||
elif geom_3d and backend.postgis:
|
||||
# Use 3D variants of perimeter and length routines on PostGIS.
|
||||
if perimeter:
|
||||
procedure_args.update({'function' : backend.perimeter3d})
|
||||
procedure_args.update({'function': backend.perimeter3d})
|
||||
elif length:
|
||||
procedure_args.update({'function' : backend.length3d})
|
||||
procedure_args.update({'function': backend.length3d})
|
||||
|
||||
# Setting up the settings for `_spatial_attribute`.
|
||||
s = {'select_field' : DistanceField(dist_att),
|
||||
'setup' : False,
|
||||
'geo_field' : geo_field,
|
||||
'procedure_args' : procedure_args,
|
||||
'procedure_fmt' : procedure_fmt,
|
||||
s = {'select_field': DistanceField(dist_att),
|
||||
'setup': False,
|
||||
'geo_field': geo_field,
|
||||
'procedure_args': procedure_args,
|
||||
'procedure_fmt': procedure_fmt,
|
||||
}
|
||||
if geom_args:
|
||||
s['geom_args'] = ('geom',)
|
||||
@@ -736,7 +736,7 @@ class GeoQuerySet(QuerySet):
|
||||
s = {'select_field': GeomField()}
|
||||
if connections[self.db].ops.oracle:
|
||||
s['procedure_fmt'] = '%(geo_col)s,%(tolerance)s'
|
||||
s['procedure_args'] = {'tolerance' : tolerance}
|
||||
s['procedure_args'] = {'tolerance': tolerance}
|
||||
return self._spatial_attribute(func, s, **kwargs)
|
||||
|
||||
def _geomset_attribute(self, func, geom, tolerance=0.05, **kwargs):
|
||||
@@ -746,10 +746,10 @@ class GeoQuerySet(QuerySet):
|
||||
for geometry set-like operations (e.g., intersection, difference,
|
||||
union, sym_difference).
|
||||
"""
|
||||
s = {'geom_args' : ('geom',),
|
||||
'select_field' : GeomField(),
|
||||
'procedure_fmt' : '%(geo_col)s,%(geom)s',
|
||||
'procedure_args' : {'geom' : geom},
|
||||
s = {'geom_args': ('geom',),
|
||||
'select_field': GeomField(),
|
||||
'procedure_fmt': '%(geo_col)s,%(geom)s',
|
||||
'procedure_args': {'geom': geom},
|
||||
}
|
||||
if connections[self.db].ops.oracle:
|
||||
s['procedure_fmt'] += ',%(tolerance)s'
|
||||
|
||||
@@ -67,9 +67,9 @@ class GeoQuery(sql.Query):
|
||||
elif isinstance(field, DistanceField):
|
||||
# Using the field's distance attribute, can instantiate
|
||||
# `Distance` with the right context.
|
||||
value = Distance(**{field.distance_att : value})
|
||||
value = Distance(**{field.distance_att: value})
|
||||
elif isinstance(field, AreaField):
|
||||
value = Area(**{field.area_att : value})
|
||||
value = Area(**{field.area_att: value})
|
||||
elif isinstance(field, (GeomField, GeometryField)) and value:
|
||||
value = Geometry(value)
|
||||
elif field is not None:
|
||||
|
||||
@@ -133,7 +133,7 @@ class Feed(BaseFeed):
|
||||
feed_type = GeoRSSFeed
|
||||
|
||||
def feed_extra_kwargs(self, obj):
|
||||
return {'geometry' : self.__get_dynamic_attr('geometry', obj)}
|
||||
return {'geometry': self.__get_dynamic_attr('geometry', obj)}
|
||||
|
||||
def item_extra_kwargs(self, item):
|
||||
return {'geometry' : self.__get_dynamic_attr('item_geometry', item)}
|
||||
return {'geometry': self.__get_dynamic_attr('item_geometry', item)}
|
||||
|
||||
@@ -19,10 +19,10 @@ class GeometryField(forms.Field):
|
||||
geom_type = 'GEOMETRY'
|
||||
|
||||
default_error_messages = {
|
||||
'required' : _('No geometry value provided.'),
|
||||
'invalid_geom' : _('Invalid geometry value.'),
|
||||
'invalid_geom_type' : _('Invalid geometry type.'),
|
||||
'transform_error' : _('An error occurred when transforming the geometry '
|
||||
'required': _('No geometry value provided.'),
|
||||
'invalid_geom': _('Invalid geometry value.'),
|
||||
'invalid_geom_type': _('Invalid geometry type.'),
|
||||
'transform_error': _('An error occurred when transforming the geometry '
|
||||
'to the SRID of the geometry form field.'),
|
||||
}
|
||||
|
||||
|
||||
@@ -15,11 +15,11 @@ class Driver(GDALBase):
|
||||
"Wraps an OGR Data Source Driver."
|
||||
|
||||
# Case-insensitive aliases for OGR Drivers.
|
||||
_alias = {'esri' : 'ESRI Shapefile',
|
||||
'shp' : 'ESRI Shapefile',
|
||||
'shape' : 'ESRI Shapefile',
|
||||
'tiger' : 'TIGER',
|
||||
'tiger/line' : 'TIGER',
|
||||
_alias = {'esri': 'ESRI Shapefile',
|
||||
'shp': 'ESRI Shapefile',
|
||||
'shape': 'ESRI Shapefile',
|
||||
'tiger': 'TIGER',
|
||||
'tiger/line': 'TIGER',
|
||||
}
|
||||
|
||||
def __init__(self, dr_input):
|
||||
|
||||
@@ -711,19 +711,19 @@ class MultiPolygon(GeometryCollection):
|
||||
pass
|
||||
|
||||
# Class mapping dictionary (using the OGRwkbGeometryType as the key)
|
||||
GEO_CLASSES = {1 : Point,
|
||||
2 : LineString,
|
||||
3 : Polygon,
|
||||
4 : MultiPoint,
|
||||
5 : MultiLineString,
|
||||
6 : MultiPolygon,
|
||||
7 : GeometryCollection,
|
||||
GEO_CLASSES = {1: Point,
|
||||
2: LineString,
|
||||
3: Polygon,
|
||||
4: MultiPoint,
|
||||
5: MultiLineString,
|
||||
6: MultiPolygon,
|
||||
7: GeometryCollection,
|
||||
101: LinearRing,
|
||||
1 + OGRGeomType.wkb25bit : Point,
|
||||
2 + OGRGeomType.wkb25bit : LineString,
|
||||
3 + OGRGeomType.wkb25bit : Polygon,
|
||||
4 + OGRGeomType.wkb25bit : MultiPoint,
|
||||
5 + OGRGeomType.wkb25bit : MultiLineString,
|
||||
6 + OGRGeomType.wkb25bit : MultiPolygon,
|
||||
7 + OGRGeomType.wkb25bit : GeometryCollection,
|
||||
1 + OGRGeomType.wkb25bit: Point,
|
||||
2 + OGRGeomType.wkb25bit: LineString,
|
||||
3 + OGRGeomType.wkb25bit: Polygon,
|
||||
4 + OGRGeomType.wkb25bit: MultiPoint,
|
||||
5 + OGRGeomType.wkb25bit: MultiLineString,
|
||||
6 + OGRGeomType.wkb25bit: MultiPolygon,
|
||||
7 + OGRGeomType.wkb25bit: GeometryCollection,
|
||||
}
|
||||
|
||||
@@ -9,23 +9,23 @@ class OGRGeomType(object):
|
||||
wkb25bit = -2147483648
|
||||
|
||||
# Dictionary of acceptable OGRwkbGeometryType s and their string names.
|
||||
_types = {0 : 'Unknown',
|
||||
1 : 'Point',
|
||||
2 : 'LineString',
|
||||
3 : 'Polygon',
|
||||
4 : 'MultiPoint',
|
||||
5 : 'MultiLineString',
|
||||
6 : 'MultiPolygon',
|
||||
7 : 'GeometryCollection',
|
||||
100 : 'None',
|
||||
101 : 'LinearRing',
|
||||
_types = {0: 'Unknown',
|
||||
1: 'Point',
|
||||
2: 'LineString',
|
||||
3: 'Polygon',
|
||||
4: 'MultiPoint',
|
||||
5: 'MultiLineString',
|
||||
6: 'MultiPolygon',
|
||||
7: 'GeometryCollection',
|
||||
100: 'None',
|
||||
101: 'LinearRing',
|
||||
1 + wkb25bit: 'Point25D',
|
||||
2 + wkb25bit: 'LineString25D',
|
||||
3 + wkb25bit: 'Polygon25D',
|
||||
4 + wkb25bit: 'MultiPoint25D',
|
||||
5 + wkb25bit : 'MultiLineString25D',
|
||||
6 + wkb25bit : 'MultiPolygon25D',
|
||||
7 + wkb25bit : 'GeometryCollection25D',
|
||||
5 + wkb25bit: 'MultiLineString25D',
|
||||
6 + wkb25bit: 'MultiPolygon25D',
|
||||
7 + wkb25bit: 'GeometryCollection25D',
|
||||
}
|
||||
# Reverse type dictionary, keyed by lower-case of the name.
|
||||
_str_types = dict((v.lower(), k) for k, v in _types.items())
|
||||
|
||||
@@ -12,10 +12,10 @@ valid_drivers = ('ESRI Shapefile', 'MapInfo File', 'TIGER', 'S57', 'DGN',
|
||||
|
||||
invalid_drivers = ('Foo baz', 'clucka', 'ESRI Shp')
|
||||
|
||||
aliases = {'eSrI' : 'ESRI Shapefile',
|
||||
'TigER/linE' : 'TIGER',
|
||||
'SHAPE' : 'ESRI Shapefile',
|
||||
'sHp' : 'ESRI Shapefile',
|
||||
aliases = {'eSrI': 'ESRI Shapefile',
|
||||
'TigER/linE': 'TIGER',
|
||||
'SHAPE': 'ESRI Shapefile',
|
||||
'sHp': 'ESRI Shapefile',
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -195,8 +195,8 @@ class GeoIP(object):
|
||||
'24.124.1.80' and 'djangoproject.com' are valid parameters.
|
||||
"""
|
||||
# Returning the country code and name
|
||||
return {'country_code' : self.country_code(query),
|
||||
'country_name' : self.country_name(query),
|
||||
return {'country_code': self.country_code(query),
|
||||
'country_name': self.country_name(query),
|
||||
}
|
||||
|
||||
#### Coordinate retrieval routines ####
|
||||
|
||||
@@ -80,7 +80,7 @@ class GeoIPTest(unittest.TestCase):
|
||||
self.assertEqual('US', func(query))
|
||||
for func in (g.country_name, g.country_name_by_addr, g.country_name_by_name):
|
||||
self.assertEqual('United States', func(query))
|
||||
self.assertEqual({'country_code' : 'US', 'country_name' : 'United States'},
|
||||
self.assertEqual({'country_code': 'US', 'country_name': 'United States'},
|
||||
g.country(query))
|
||||
|
||||
@skipUnless(HAS_GEOS, "Geos is required")
|
||||
@@ -96,7 +96,7 @@ class GeoIPTest(unittest.TestCase):
|
||||
self.assertEqual('US', func(query))
|
||||
for func in (g.country_name, g.country_name_by_addr, g.country_name_by_name):
|
||||
self.assertEqual('United States', func(query))
|
||||
self.assertEqual({'country_code' : 'US', 'country_name' : 'United States'},
|
||||
self.assertEqual({'country_code': 'US', 'country_name': 'United States'},
|
||||
g.country(query))
|
||||
|
||||
# City information dictionary.
|
||||
|
||||
@@ -707,14 +707,14 @@ from django.contrib.gis.geos.linestring import LineString, LinearRing
|
||||
from django.contrib.gis.geos.point import Point
|
||||
from django.contrib.gis.geos.polygon import Polygon
|
||||
from django.contrib.gis.geos.collections import GeometryCollection, MultiPoint, MultiLineString, MultiPolygon
|
||||
GEOS_CLASSES = {0 : Point,
|
||||
1 : LineString,
|
||||
2 : LinearRing,
|
||||
3 : Polygon,
|
||||
4 : MultiPoint,
|
||||
5 : MultiLineString,
|
||||
6 : MultiPolygon,
|
||||
7 : GeometryCollection,
|
||||
GEOS_CLASSES = {0: Point,
|
||||
1: LineString,
|
||||
2: LinearRing,
|
||||
3: Polygon,
|
||||
4: MultiPoint,
|
||||
5: MultiLineString,
|
||||
6: MultiPolygon,
|
||||
7: GeometryCollection,
|
||||
}
|
||||
|
||||
# If supported, import the PreparedGeometry class.
|
||||
|
||||
@@ -239,7 +239,7 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
|
||||
# an invalid type.
|
||||
for g in (p, ls):
|
||||
self.assertNotEqual(g, None)
|
||||
self.assertNotEqual(g, {'foo' : 'bar'})
|
||||
self.assertNotEqual(g, {'foo': 'bar'})
|
||||
self.assertNotEqual(g, False)
|
||||
|
||||
def test_points(self):
|
||||
|
||||
@@ -103,9 +103,9 @@ class Command(LabelCommand):
|
||||
if show_mapping:
|
||||
# Constructing the keyword arguments for `mapping`, and
|
||||
# calling it on the data source.
|
||||
kwargs = {'geom_name' : options['geom_name'],
|
||||
'layer_key' : options['layer_key'],
|
||||
'multi_geom' : options['multi_geom'],
|
||||
kwargs = {'geom_name': options['geom_name'],
|
||||
'layer_key': options['layer_key'],
|
||||
'multi_geom': options['multi_geom'],
|
||||
}
|
||||
mapping_dict = mapping(ds, **kwargs)
|
||||
# This extra legwork is so that the dictionary definition comes
|
||||
|
||||
@@ -98,16 +98,16 @@ class GoogleMap(object):
|
||||
"""
|
||||
Generates the JavaScript necessary for displaying this Google Map.
|
||||
"""
|
||||
params = {'calc_zoom' : self.calc_zoom,
|
||||
'center' : self.center,
|
||||
'dom_id' : self.dom_id,
|
||||
'js_module' : self.js_module,
|
||||
'kml_urls' : self.kml_urls,
|
||||
'zoom' : self.zoom,
|
||||
'polygons' : self.polygons,
|
||||
'polylines' : self.polylines,
|
||||
params = {'calc_zoom': self.calc_zoom,
|
||||
'center': self.center,
|
||||
'dom_id': self.dom_id,
|
||||
'js_module': self.js_module,
|
||||
'kml_urls': self.kml_urls,
|
||||
'zoom': self.zoom,
|
||||
'polygons': self.polygons,
|
||||
'polylines': self.polylines,
|
||||
'icons': self.icons,
|
||||
'markers' : self.markers,
|
||||
'markers': self.markers,
|
||||
}
|
||||
params.update(self.extra_context)
|
||||
return render_to_string(self.template, params)
|
||||
@@ -211,10 +211,10 @@ class GoogleMapSet(GoogleMap):
|
||||
Generates the JavaScript for the collection of Google Maps in
|
||||
this set.
|
||||
"""
|
||||
params = {'js_module' : self.js_module,
|
||||
'dom_ids' : self.dom_ids,
|
||||
'load_map_js' : self.load_map_js(),
|
||||
'icons' : self.icons,
|
||||
params = {'js_module': self.js_module,
|
||||
'dom_ids': self.dom_ids,
|
||||
'load_map_js': self.load_map_js(),
|
||||
'icons': self.icons,
|
||||
}
|
||||
params.update(self.extra_context)
|
||||
return render_to_string(self.template, params)
|
||||
|
||||
@@ -221,77 +221,77 @@ class MeasureBase(object):
|
||||
class Distance(MeasureBase):
|
||||
STANDARD_UNIT = "m"
|
||||
UNITS = {
|
||||
'chain' : 20.1168,
|
||||
'chain_benoit' : 20.116782,
|
||||
'chain_sears' : 20.1167645,
|
||||
'british_chain_benoit' : 20.1167824944,
|
||||
'british_chain_sears' : 20.1167651216,
|
||||
'british_chain_sears_truncated' : 20.116756,
|
||||
'cm' : 0.01,
|
||||
'british_ft' : 0.304799471539,
|
||||
'british_yd' : 0.914398414616,
|
||||
'clarke_ft' : 0.3047972654,
|
||||
'clarke_link' : 0.201166195164,
|
||||
'fathom' : 1.8288,
|
||||
'chain': 20.1168,
|
||||
'chain_benoit': 20.116782,
|
||||
'chain_sears': 20.1167645,
|
||||
'british_chain_benoit': 20.1167824944,
|
||||
'british_chain_sears': 20.1167651216,
|
||||
'british_chain_sears_truncated': 20.116756,
|
||||
'cm': 0.01,
|
||||
'british_ft': 0.304799471539,
|
||||
'british_yd': 0.914398414616,
|
||||
'clarke_ft': 0.3047972654,
|
||||
'clarke_link': 0.201166195164,
|
||||
'fathom': 1.8288,
|
||||
'ft': 0.3048,
|
||||
'german_m' : 1.0000135965,
|
||||
'gold_coast_ft' : 0.304799710181508,
|
||||
'indian_yd' : 0.914398530744,
|
||||
'inch' : 0.0254,
|
||||
'german_m': 1.0000135965,
|
||||
'gold_coast_ft': 0.304799710181508,
|
||||
'indian_yd': 0.914398530744,
|
||||
'inch': 0.0254,
|
||||
'km': 1000.0,
|
||||
'link' : 0.201168,
|
||||
'link_benoit' : 0.20116782,
|
||||
'link_sears' : 0.20116765,
|
||||
'link': 0.201168,
|
||||
'link_benoit': 0.20116782,
|
||||
'link_sears': 0.20116765,
|
||||
'm': 1.0,
|
||||
'mi': 1609.344,
|
||||
'mm' : 0.001,
|
||||
'mm': 0.001,
|
||||
'nm': 1852.0,
|
||||
'nm_uk' : 1853.184,
|
||||
'rod' : 5.0292,
|
||||
'sears_yd' : 0.91439841,
|
||||
'survey_ft' : 0.304800609601,
|
||||
'um' : 0.000001,
|
||||
'nm_uk': 1853.184,
|
||||
'rod': 5.0292,
|
||||
'sears_yd': 0.91439841,
|
||||
'survey_ft': 0.304800609601,
|
||||
'um': 0.000001,
|
||||
'yd': 0.9144,
|
||||
}
|
||||
|
||||
# Unit aliases for `UNIT` terms encountered in Spatial Reference WKT.
|
||||
ALIAS = {
|
||||
'centimeter' : 'cm',
|
||||
'foot' : 'ft',
|
||||
'inches' : 'inch',
|
||||
'kilometer' : 'km',
|
||||
'kilometre' : 'km',
|
||||
'meter' : 'm',
|
||||
'metre' : 'm',
|
||||
'micrometer' : 'um',
|
||||
'micrometre' : 'um',
|
||||
'millimeter' : 'mm',
|
||||
'millimetre' : 'mm',
|
||||
'mile' : 'mi',
|
||||
'yard' : 'yd',
|
||||
'British chain (Benoit 1895 B)' : 'british_chain_benoit',
|
||||
'British chain (Sears 1922)' : 'british_chain_sears',
|
||||
'British chain (Sears 1922 truncated)' : 'british_chain_sears_truncated',
|
||||
'British foot (Sears 1922)' : 'british_ft',
|
||||
'British foot' : 'british_ft',
|
||||
'British yard (Sears 1922)' : 'british_yd',
|
||||
'British yard' : 'british_yd',
|
||||
"Clarke's Foot" : 'clarke_ft',
|
||||
"Clarke's link" : 'clarke_link',
|
||||
'Chain (Benoit)' : 'chain_benoit',
|
||||
'Chain (Sears)' : 'chain_sears',
|
||||
'Foot (International)' : 'ft',
|
||||
'German legal metre' : 'german_m',
|
||||
'Gold Coast foot' : 'gold_coast_ft',
|
||||
'Indian yard' : 'indian_yd',
|
||||
'centimeter': 'cm',
|
||||
'foot': 'ft',
|
||||
'inches': 'inch',
|
||||
'kilometer': 'km',
|
||||
'kilometre': 'km',
|
||||
'meter': 'm',
|
||||
'metre': 'm',
|
||||
'micrometer': 'um',
|
||||
'micrometre': 'um',
|
||||
'millimeter': 'mm',
|
||||
'millimetre': 'mm',
|
||||
'mile': 'mi',
|
||||
'yard': 'yd',
|
||||
'British chain (Benoit 1895 B)': 'british_chain_benoit',
|
||||
'British chain (Sears 1922)': 'british_chain_sears',
|
||||
'British chain (Sears 1922 truncated)': 'british_chain_sears_truncated',
|
||||
'British foot (Sears 1922)': 'british_ft',
|
||||
'British foot': 'british_ft',
|
||||
'British yard (Sears 1922)': 'british_yd',
|
||||
'British yard': 'british_yd',
|
||||
"Clarke's Foot": 'clarke_ft',
|
||||
"Clarke's link": 'clarke_link',
|
||||
'Chain (Benoit)': 'chain_benoit',
|
||||
'Chain (Sears)': 'chain_sears',
|
||||
'Foot (International)': 'ft',
|
||||
'German legal metre': 'german_m',
|
||||
'Gold Coast foot': 'gold_coast_ft',
|
||||
'Indian yard': 'indian_yd',
|
||||
'Link (Benoit)': 'link_benoit',
|
||||
'Link (Sears)': 'link_sears',
|
||||
'Nautical Mile' : 'nm',
|
||||
'Nautical Mile (UK)' : 'nm_uk',
|
||||
'US survey foot' : 'survey_ft',
|
||||
'U.S. Foot' : 'survey_ft',
|
||||
'Yard (Indian)' : 'indian_yd',
|
||||
'Yard (Sears)' : 'sears_yd'
|
||||
'Nautical Mile': 'nm',
|
||||
'Nautical Mile (UK)': 'nm_uk',
|
||||
'US survey foot': 'survey_ft',
|
||||
'U.S. Foot': 'survey_ft',
|
||||
'Yard (Indian)': 'indian_yd',
|
||||
'Yard (Sears)': 'sears_yd'
|
||||
}
|
||||
LALIAS = dict((k.lower(), v) for k, v in ALIAS.items())
|
||||
|
||||
|
||||
@@ -55,8 +55,8 @@ class KMLSitemap(Sitemap):
|
||||
|
||||
def location(self, obj):
|
||||
return urlresolvers.reverse('django.contrib.gis.sitemaps.views.%s' % self.geo_format,
|
||||
kwargs={'label' : obj[0],
|
||||
'model' : obj[1],
|
||||
kwargs={'label': obj[0],
|
||||
'model': obj[1],
|
||||
'field_name': obj[2],
|
||||
}
|
||||
)
|
||||
|
||||
@@ -106,7 +106,7 @@ def kml(request, label, model, field_name=None, compress=False, using=DEFAULT_DB
|
||||
render = render_to_kmz
|
||||
else:
|
||||
render = render_to_kml
|
||||
return render('gis/kml/placemarks.kml', {'places' : placemarks})
|
||||
return render('gis/kml/placemarks.kml', {'places': placemarks})
|
||||
|
||||
def kmz(request, label, model, field_name=None, using=DEFAULT_DB_ALIAS):
|
||||
"""
|
||||
|
||||
@@ -46,10 +46,10 @@ city_dict = dict((name, coords) for name, coords in city_data)
|
||||
interstate_data = (
|
||||
('I-45',
|
||||
'LINESTRING(-95.3708481 29.7765870 11.339,-95.3694580 29.7787980 4.536,-95.3690305 29.7797359 9.762,-95.3691886 29.7812450 12.448,-95.3696447 29.7850144 10.457,-95.3702511 29.7868518 9.418,-95.3706724 29.7881286 14.858,-95.3711632 29.7896157 15.386,-95.3714525 29.7936267 13.168,-95.3717848 29.7955007 15.104,-95.3717719 29.7969804 16.516,-95.3717305 29.7982117 13.923,-95.3717254 29.8000778 14.385,-95.3719875 29.8013539 15.160,-95.3720575 29.8026785 15.544,-95.3721321 29.8040912 14.975,-95.3722074 29.8050998 15.688,-95.3722779 29.8060430 16.099,-95.3733818 29.8076750 15.197,-95.3741563 29.8103686 17.268,-95.3749458 29.8129927 19.857,-95.3763564 29.8144557 15.435)',
|
||||
(11.339, 4.536, 9.762, 12.448, 10.457, 9.418, 14.858,
|
||||
15.386, 13.168, 15.104, 16.516, 13.923, 14.385, 15.16 ,
|
||||
15.544, 14.975, 15.688, 16.099, 15.197, 17.268, 19.857,
|
||||
15.435),
|
||||
(11.339, 4.536, 9.762, 12.448, 10.457, 9.418, 14.858,
|
||||
15.386, 13.168, 15.104, 16.516, 13.923, 14.385, 15.16,
|
||||
15.544, 14.975, 15.688, 16.099, 15.197, 17.268, 19.857,
|
||||
15.435),
|
||||
),
|
||||
)
|
||||
|
||||
@@ -131,8 +131,8 @@ class Geo3DTest(TestCase):
|
||||
"""
|
||||
Testing LayerMapping on 3D models.
|
||||
"""
|
||||
point_mapping = {'point' : 'POINT'}
|
||||
mpoint_mapping = {'mpoint' : 'MULTIPOINT'}
|
||||
point_mapping = {'point': 'POINT'}
|
||||
mpoint_mapping = {'mpoint': 'MULTIPOINT'}
|
||||
|
||||
# The VRT is 3D, but should still be able to map sans the Z.
|
||||
lm = LayerMapping(Point2D, vrt_file, point_mapping, transform=False)
|
||||
|
||||
@@ -56,11 +56,11 @@ class TestW3CGeo3(TestGeoRSS1):
|
||||
|
||||
# The feed dictionary to use for URLs.
|
||||
feed_dict = {
|
||||
'rss1' : TestGeoRSS1,
|
||||
'rss2' : TestGeoRSS2,
|
||||
'atom1' : TestGeoAtom1,
|
||||
'atom2' : TestGeoAtom2,
|
||||
'w3cgeo1' : TestW3CGeo1,
|
||||
'w3cgeo2' : TestW3CGeo2,
|
||||
'w3cgeo3' : TestW3CGeo3,
|
||||
'rss1': TestGeoRSS1,
|
||||
'rss2': TestGeoRSS2,
|
||||
'atom1': TestGeoAtom1,
|
||||
'atom2': TestGeoAtom2,
|
||||
'w3cgeo1': TestW3CGeo1,
|
||||
'w3cgeo2': TestW3CGeo2,
|
||||
'w3cgeo3': TestW3CGeo3,
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ from .feeds import feed_dict
|
||||
from .models import City, Country
|
||||
|
||||
|
||||
sitemaps = {'kml' : KMLSitemap([City, Country]),
|
||||
'kmz' : KMZSitemap([City, Country]),
|
||||
'georss' : GeoRSSSitemap(feed_dict),
|
||||
sitemaps = {'kml': KMLSitemap([City, Country]),
|
||||
'kmz': KMZSitemap([City, Country]),
|
||||
'georss': GeoRSSSitemap(feed_dict),
|
||||
}
|
||||
|
||||
@@ -33,11 +33,11 @@ class GeoRegressionTests(TestCase):
|
||||
def test_kmz(self):
|
||||
"Testing `render_to_kmz` with non-ASCII data. See #11624."
|
||||
name = "Åland Islands"
|
||||
places = [{'name' : name,
|
||||
'description' : name,
|
||||
'kml' : '<Point><coordinates>5.0,23.0</coordinates></Point>'
|
||||
places = [{'name': name,
|
||||
'description': name,
|
||||
'kml': '<Point><coordinates>5.0,23.0</coordinates></Point>'
|
||||
}]
|
||||
render_to_kmz('gis/kml/placemarks.kml', {'places' : places})
|
||||
render_to_kmz('gis/kml/placemarks.kml', {'places': places})
|
||||
|
||||
@no_spatialite
|
||||
@no_mysql
|
||||
|
||||
@@ -534,7 +534,7 @@ class GeoQuerySetTest(TestCase):
|
||||
|
||||
def test_gml(self):
|
||||
"Testing GML output from the database using GeoQuerySet.gml()."
|
||||
if mysql or (spatialite and not connection.ops.gml) :
|
||||
if mysql or (spatialite and not connection.ops.gml):
|
||||
self.assertRaises(NotImplementedError, Country.objects.all().gml, field_name='mpoly')
|
||||
return
|
||||
|
||||
@@ -635,15 +635,15 @@ class GeoQuerySetTest(TestCase):
|
||||
# Reference values.
|
||||
if oracle:
|
||||
# SELECT SDO_UTIL.TO_WKTGEOMETRY(SDO_GEOM.SDO_POINTONSURFACE(GEOAPP_COUNTRY.MPOLY, 0.05)) FROM GEOAPP_COUNTRY;
|
||||
ref = {'New Zealand' : fromstr('POINT (174.616364 -36.100861)', srid=4326),
|
||||
'Texas' : fromstr('POINT (-103.002434 36.500397)', srid=4326),
|
||||
ref = {'New Zealand': fromstr('POINT (174.616364 -36.100861)', srid=4326),
|
||||
'Texas': fromstr('POINT (-103.002434 36.500397)', srid=4326),
|
||||
}
|
||||
|
||||
elif postgis or spatialite:
|
||||
# Using GEOSGeometry to compute the reference point on surface values
|
||||
# -- since PostGIS also uses GEOS these should be the same.
|
||||
ref = {'New Zealand' : Country.objects.get(name='New Zealand').mpoly.point_on_surface,
|
||||
'Texas' : Country.objects.get(name='Texas').mpoly.point_on_surface
|
||||
ref = {'New Zealand': Country.objects.get(name='New Zealand').mpoly.point_on_surface,
|
||||
'Texas': Country.objects.get(name='Texas').mpoly.point_on_surface
|
||||
}
|
||||
|
||||
for c in Country.objects.point_on_surface():
|
||||
|
||||
@@ -11,8 +11,8 @@ urlpatterns = patterns('',
|
||||
)
|
||||
|
||||
urlpatterns += patterns('django.contrib.gis.sitemaps.views',
|
||||
(r'^sitemap.xml$', 'index', {'sitemaps' : sitemaps}),
|
||||
(r'^sitemaps/(?P<section>\w+)\.xml$', 'sitemap', {'sitemaps' : sitemaps}),
|
||||
(r'^sitemap.xml$', 'index', {'sitemaps': sitemaps}),
|
||||
(r'^sitemaps/(?P<section>\w+)\.xml$', 'sitemap', {'sitemaps': sitemaps}),
|
||||
(r'^sitemaps/kml/(?P<label>\w+)/(?P<model>\w+)/(?P<field_name>\w+)\.kml$', 'kml'),
|
||||
(r'^sitemaps/kml/(?P<label>\w+)/(?P<model>\w+)/(?P<field_name>\w+)\.kmz$', 'kmz'),
|
||||
)
|
||||
|
||||
@@ -69,9 +69,9 @@ class GeographyTest(TestCase):
|
||||
# Getting the shapefile and mapping dictionary.
|
||||
shp_path = os.path.realpath(os.path.join(os.path.dirname(upath(__file__)), '..', 'data'))
|
||||
co_shp = os.path.join(shp_path, 'counties', 'counties.shp')
|
||||
co_mapping = {'name' : 'Name',
|
||||
'state' : 'State',
|
||||
'mpoly' : 'MULTIPOLYGON',
|
||||
co_mapping = {'name': 'Name',
|
||||
'state': 'State',
|
||||
'mpoly': 'MULTIPOLYGON',
|
||||
}
|
||||
|
||||
# Reference county names, number of polygons, and state names.
|
||||
|
||||
@@ -48,23 +48,23 @@ class Invalid(models.Model):
|
||||
point = models.PointField()
|
||||
|
||||
# Mapping dictionaries for the models above.
|
||||
co_mapping = {'name' : 'Name',
|
||||
'state' : {'name' : 'State'}, # ForeignKey's use another mapping dictionary for the _related_ Model (State in this case).
|
||||
'mpoly' : 'MULTIPOLYGON', # Will convert POLYGON features into MULTIPOLYGONS.
|
||||
co_mapping = {'name': 'Name',
|
||||
'state': {'name': 'State'}, # ForeignKey's use another mapping dictionary for the _related_ Model (State in this case).
|
||||
'mpoly': 'MULTIPOLYGON', # Will convert POLYGON features into MULTIPOLYGONS.
|
||||
}
|
||||
|
||||
cofeat_mapping = {'name' : 'Name',
|
||||
'poly' : 'POLYGON',
|
||||
cofeat_mapping = {'name': 'Name',
|
||||
'poly': 'POLYGON',
|
||||
}
|
||||
|
||||
city_mapping = {'name' : 'Name',
|
||||
'population' : 'Population',
|
||||
'density' : 'Density',
|
||||
'dt' : 'Created',
|
||||
'point' : 'POINT',
|
||||
city_mapping = {'name': 'Name',
|
||||
'population': 'Population',
|
||||
'density': 'Density',
|
||||
'dt': 'Created',
|
||||
'point': 'POINT',
|
||||
}
|
||||
|
||||
inter_mapping = {'name' : 'Name',
|
||||
'length' : 'Length',
|
||||
'path' : 'LINESTRING',
|
||||
inter_mapping = {'name': 'Name',
|
||||
'length': 'Length',
|
||||
'path': 'LINESTRING',
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ class LayerMapTest(TestCase):
|
||||
bad_fk_map1 = copy(co_mapping)
|
||||
bad_fk_map1['state'] = 'name'
|
||||
bad_fk_map2 = copy(co_mapping)
|
||||
bad_fk_map2['state'] = {'nombre' : 'State'}
|
||||
bad_fk_map2['state'] = {'nombre': 'State'}
|
||||
self.assertRaises(TypeError, LayerMapping, County, co_shp, bad_fk_map1, transform=False)
|
||||
self.assertRaises(LayerMapError, LayerMapping, County, co_shp, bad_fk_map2, transform=False)
|
||||
|
||||
@@ -262,11 +262,11 @@ class LayerMapTest(TestCase):
|
||||
|
||||
def test_model_inheritance(self):
|
||||
"Tests LayerMapping on inherited models. See #12093."
|
||||
icity_mapping = {'name' : 'Name',
|
||||
'population' : 'Population',
|
||||
'density' : 'Density',
|
||||
'point' : 'POINT',
|
||||
'dt' : 'Created',
|
||||
icity_mapping = {'name': 'Name',
|
||||
'population': 'Population',
|
||||
'density': 'Density',
|
||||
'point': 'POINT',
|
||||
'dt': 'Created',
|
||||
}
|
||||
|
||||
# Parent model has geometry field.
|
||||
|
||||
@@ -6,29 +6,29 @@ from django.contrib.gis.tests.utils import (no_mysql, oracle, postgis,
|
||||
from django.utils import six
|
||||
|
||||
|
||||
test_srs = ({'srid' : 4326,
|
||||
'auth_name' : ('EPSG', True),
|
||||
'auth_srid' : 4326,
|
||||
test_srs = ({'srid': 4326,
|
||||
'auth_name': ('EPSG', True),
|
||||
'auth_srid': 4326,
|
||||
# Only the beginning, because there are differences depending on installed libs
|
||||
'srtext' : 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84"',
|
||||
'srtext': 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84"',
|
||||
# +ellps=WGS84 has been removed in the 4326 proj string in proj-4.8
|
||||
'proj4_re' : r'\+proj=longlat (\+ellps=WGS84 )?\+datum=WGS84 \+no_defs ',
|
||||
'spheroid' : 'WGS 84', 'name' : 'WGS 84',
|
||||
'geographic' : True, 'projected' : False, 'spatialite' : True,
|
||||
'ellipsoid' : (6378137.0, 6356752.3, 298.257223563), # From proj's "cs2cs -le" and Wikipedia (semi-minor only)
|
||||
'eprec' : (1, 1, 9),
|
||||
'proj4_re': r'\+proj=longlat (\+ellps=WGS84 )?\+datum=WGS84 \+no_defs ',
|
||||
'spheroid': 'WGS 84', 'name': 'WGS 84',
|
||||
'geographic': True, 'projected': False, 'spatialite': True,
|
||||
'ellipsoid': (6378137.0, 6356752.3, 298.257223563), # From proj's "cs2cs -le" and Wikipedia (semi-minor only)
|
||||
'eprec': (1, 1, 9),
|
||||
},
|
||||
{'srid' : 32140,
|
||||
'auth_name' : ('EPSG', False),
|
||||
'auth_srid' : 32140,
|
||||
'srtext' : 'PROJCS["NAD83 / Texas South Central",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980"',
|
||||
'proj4_re' : r'\+proj=lcc \+lat_1=30.28333333333333 \+lat_2=28.38333333333333 \+lat_0=27.83333333333333 '
|
||||
{'srid': 32140,
|
||||
'auth_name': ('EPSG', False),
|
||||
'auth_srid': 32140,
|
||||
'srtext': 'PROJCS["NAD83 / Texas South Central",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980"',
|
||||
'proj4_re': r'\+proj=lcc \+lat_1=30.28333333333333 \+lat_2=28.38333333333333 \+lat_0=27.83333333333333 '
|
||||
r'\+lon_0=-99 \+x_0=600000 \+y_0=4000000 (\+ellps=GRS80 )?'
|
||||
r'(\+datum=NAD83 |\+towgs84=0,0,0,0,0,0,0 )?\+units=m \+no_defs ',
|
||||
'spheroid' : 'GRS 1980', 'name' : 'NAD83 / Texas South Central',
|
||||
'geographic' : False, 'projected' : True, 'spatialite' : False,
|
||||
'ellipsoid' : (6378137.0, 6356752.31414, 298.257222101), # From proj's "cs2cs -le" and Wikipedia (semi-minor only)
|
||||
'eprec' : (1, 5, 10),
|
||||
'spheroid': 'GRS 1980', 'name': 'NAD83 / Texas South Central',
|
||||
'geographic': False, 'projected': True, 'spatialite': False,
|
||||
'ellipsoid': (6378137.0, 6356752.31414, 298.257222101), # From proj's "cs2cs -le" and Wikipedia (semi-minor only)
|
||||
'eprec': (1, 5, 10),
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@@ -40,32 +40,32 @@ class LayerMapping(object):
|
||||
"A class that maps OGR Layers to GeoDjango Models."
|
||||
|
||||
# Acceptable 'base' types for a multi-geometry type.
|
||||
MULTI_TYPES = {1 : OGRGeomType('MultiPoint'),
|
||||
2 : OGRGeomType('MultiLineString'),
|
||||
3 : OGRGeomType('MultiPolygon'),
|
||||
OGRGeomType('Point25D').num : OGRGeomType('MultiPoint25D'),
|
||||
OGRGeomType('LineString25D').num : OGRGeomType('MultiLineString25D'),
|
||||
OGRGeomType('Polygon25D').num : OGRGeomType('MultiPolygon25D'),
|
||||
MULTI_TYPES = {1: OGRGeomType('MultiPoint'),
|
||||
2: OGRGeomType('MultiLineString'),
|
||||
3: OGRGeomType('MultiPolygon'),
|
||||
OGRGeomType('Point25D').num: OGRGeomType('MultiPoint25D'),
|
||||
OGRGeomType('LineString25D').num: OGRGeomType('MultiLineString25D'),
|
||||
OGRGeomType('Polygon25D').num: OGRGeomType('MultiPolygon25D'),
|
||||
}
|
||||
|
||||
# Acceptable Django field types and corresponding acceptable OGR
|
||||
# counterparts.
|
||||
FIELD_TYPES = {
|
||||
models.AutoField : OFTInteger,
|
||||
models.IntegerField : (OFTInteger, OFTReal, OFTString),
|
||||
models.FloatField : (OFTInteger, OFTReal),
|
||||
models.DateField : OFTDate,
|
||||
models.DateTimeField : OFTDateTime,
|
||||
models.EmailField : OFTString,
|
||||
models.TimeField : OFTTime,
|
||||
models.DecimalField : (OFTInteger, OFTReal),
|
||||
models.CharField : OFTString,
|
||||
models.SlugField : OFTString,
|
||||
models.TextField : OFTString,
|
||||
models.URLField : OFTString,
|
||||
models.BigIntegerField : (OFTInteger, OFTReal, OFTString),
|
||||
models.SmallIntegerField : (OFTInteger, OFTReal, OFTString),
|
||||
models.PositiveSmallIntegerField : (OFTInteger, OFTReal, OFTString),
|
||||
models.AutoField: OFTInteger,
|
||||
models.IntegerField: (OFTInteger, OFTReal, OFTString),
|
||||
models.FloatField: (OFTInteger, OFTReal),
|
||||
models.DateField: OFTDate,
|
||||
models.DateTimeField: OFTDateTime,
|
||||
models.EmailField: OFTString,
|
||||
models.TimeField: OFTTime,
|
||||
models.DecimalField: (OFTInteger, OFTReal),
|
||||
models.CharField: OFTString,
|
||||
models.SlugField: OFTString,
|
||||
models.TextField: OFTString,
|
||||
models.URLField: OFTString,
|
||||
models.BigIntegerField: (OFTInteger, OFTReal, OFTString),
|
||||
models.SmallIntegerField: (OFTInteger, OFTReal, OFTString),
|
||||
models.PositiveSmallIntegerField: (OFTInteger, OFTReal, OFTString),
|
||||
}
|
||||
|
||||
def __init__(self, model, data, mapping, layer=0,
|
||||
@@ -322,7 +322,7 @@ class LayerMapping(object):
|
||||
of the feature kwargs.
|
||||
"""
|
||||
if isinstance(self.unique, six.string_types):
|
||||
return {self.unique : kwargs[self.unique]}
|
||||
return {self.unique: kwargs[self.unique]}
|
||||
else:
|
||||
return dict((fld, kwargs[fld]) for fld in self.unique)
|
||||
|
||||
|
||||
@@ -56,10 +56,10 @@ def add_srs_entry(srs, auth_name='EPSG', auth_srid=None, ref_sys_name=None,
|
||||
|
||||
# Initializing the keyword arguments dictionary for both PostGIS
|
||||
# and SpatiaLite.
|
||||
kwargs = {'srid' : srs.srid,
|
||||
'auth_name' : auth_name,
|
||||
'auth_srid' : auth_srid or srs.srid,
|
||||
'proj4text' : srs.proj4,
|
||||
kwargs = {'srid': srs.srid,
|
||||
'auth_name': auth_name,
|
||||
'auth_srid': auth_srid or srs.srid,
|
||||
'proj4text': srs.proj4,
|
||||
}
|
||||
|
||||
# Backend-specific fields for the SpatialRefSys model.
|
||||
|
||||
@@ -11,7 +11,7 @@ from django.core.management.color import no_style
|
||||
|
||||
def create_default_site(app, created_models, verbosity, db, **kwargs):
|
||||
# Only create the default sites in databases where Django created the table
|
||||
if Site in created_models and router.allow_migrate(db, Site) :
|
||||
if Site in created_models and router.allow_migrate(db, Site):
|
||||
# The default settings set SITE_ID = 1, and some tests in Django's test
|
||||
# suite rely on this value. However, if database sequences are reused
|
||||
# (e.g. in the test suite after flush/syncdb), it isn't guaranteed that
|
||||
|
||||
@@ -10,8 +10,8 @@ Usage::
|
||||
To add your own serializers, use the SERIALIZATION_MODULES setting::
|
||||
|
||||
SERIALIZATION_MODULES = {
|
||||
"csv" : "path.to.csv.serializer",
|
||||
"txt" : "path.to.txt.serializer",
|
||||
"csv": "path.to.csv.serializer",
|
||||
"txt": "path.to.txt.serializer",
|
||||
}
|
||||
|
||||
"""
|
||||
@@ -24,10 +24,10 @@ from django.core.serializers.base import SerializerDoesNotExist
|
||||
|
||||
# Built-in serializers
|
||||
BUILTIN_SERIALIZERS = {
|
||||
"xml" : "django.core.serializers.xml_serializer",
|
||||
"python" : "django.core.serializers.python",
|
||||
"json" : "django.core.serializers.json",
|
||||
"yaml" : "django.core.serializers.pyyaml",
|
||||
"xml": "django.core.serializers.xml_serializer",
|
||||
"python": "django.core.serializers.python",
|
||||
"json": "django.core.serializers.json",
|
||||
"yaml": "django.core.serializers.pyyaml",
|
||||
}
|
||||
|
||||
_serializers = {}
|
||||
|
||||
@@ -28,7 +28,7 @@ class Serializer(base.Serializer):
|
||||
"""
|
||||
self.xml = SimplerXMLGenerator(self.stream, self.options.get("encoding", settings.DEFAULT_CHARSET))
|
||||
self.xml.startDocument()
|
||||
self.xml.startElement("django-objects", {"version" : "1.0"})
|
||||
self.xml.startElement("django-objects", {"version": "1.0"})
|
||||
|
||||
def end_serialization(self):
|
||||
"""
|
||||
@@ -68,8 +68,8 @@ class Serializer(base.Serializer):
|
||||
"""
|
||||
self.indent(2)
|
||||
self.xml.startElement("field", {
|
||||
"name" : field.name,
|
||||
"type" : field.get_internal_type()
|
||||
"name": field.name,
|
||||
"type": field.get_internal_type()
|
||||
})
|
||||
|
||||
# Get a "string version" of the object's data.
|
||||
@@ -125,7 +125,7 @@ class Serializer(base.Serializer):
|
||||
else:
|
||||
def handle_m2m(value):
|
||||
self.xml.addQuickElement("object", attrs={
|
||||
'pk' : smart_text(value._get_pk_val())
|
||||
'pk': smart_text(value._get_pk_val())
|
||||
})
|
||||
for relobj in getattr(obj, field.name).iterator():
|
||||
handle_m2m(relobj)
|
||||
@@ -138,9 +138,9 @@ class Serializer(base.Serializer):
|
||||
"""
|
||||
self.indent(2)
|
||||
self.xml.startElement("field", {
|
||||
"name" : field.name,
|
||||
"rel" : field.rel.__class__.__name__,
|
||||
"to" : smart_text(field.rel.to._meta),
|
||||
"name": field.name,
|
||||
"rel": field.rel.__class__.__name__,
|
||||
"to": smart_text(field.rel.to._meta),
|
||||
})
|
||||
|
||||
class Deserializer(base.Deserializer):
|
||||
|
||||
@@ -331,7 +331,7 @@ class RegexURLResolver(LocaleRegexProvider):
|
||||
return ResolverMatch(sub_match.func, sub_match.args, sub_match_dict, sub_match.url_name, self.app_name or sub_match.app_name, [self.namespace] + sub_match.namespaces)
|
||||
tried.append([pattern])
|
||||
raise Resolver404({'tried': tried, 'path': new_path})
|
||||
raise Resolver404({'path' : path})
|
||||
raise Resolver404({'path': path})
|
||||
|
||||
@property
|
||||
def urlconf_module(self):
|
||||
|
||||
@@ -423,8 +423,8 @@ def formset_factory(form, formset=BaseFormSet, extra=1, can_order=False,
|
||||
attrs = {'form': form, 'extra': extra,
|
||||
'can_order': can_order, 'can_delete': can_delete,
|
||||
'min_num': min_num, 'max_num': max_num,
|
||||
'absolute_max': absolute_max, 'validate_min' : validate_min,
|
||||
'validate_max' : validate_max}
|
||||
'absolute_max': absolute_max, 'validate_min': validate_min,
|
||||
'validate_max': validate_max}
|
||||
return type(form.__name__ + str('FormSet'), (formset,), attrs)
|
||||
|
||||
def all_valid(formsets):
|
||||
|
||||
@@ -149,7 +149,7 @@ class RootElement(Element):
|
||||
|
||||
|
||||
class Parser(HTMLParser):
|
||||
SELF_CLOSING_TAGS = ('br' , 'hr', 'input', 'img', 'meta', 'spacer',
|
||||
SELF_CLOSING_TAGS = ('br', 'hr', 'input', 'img', 'meta', 'spacer',
|
||||
'link', 'frame', 'base', 'col')
|
||||
|
||||
def __init__(self):
|
||||
|
||||
@@ -665,7 +665,7 @@ def parse_accept_lang_header(lang_string):
|
||||
if pieces[-1]:
|
||||
return []
|
||||
for i in range(0, len(pieces) - 1, 3):
|
||||
first, lang, priority = pieces[i : i + 3]
|
||||
first, lang, priority = pieces[i:i + 3]
|
||||
if first:
|
||||
return []
|
||||
if priority:
|
||||
|
||||
@@ -303,7 +303,7 @@ class ExceptionReporter(object):
|
||||
'sys_version_info': '%d.%d.%d' % sys.version_info[0:3],
|
||||
'server_time': datetime.datetime.now(),
|
||||
'django_version_info': get_version(),
|
||||
'sys_path' : sys.path,
|
||||
'sys_path': sys.path,
|
||||
'template_info': self.template_info,
|
||||
'template_does_not_exist': self.template_does_not_exist,
|
||||
'loader_debug_info': self.loader_debug_info,
|
||||
@@ -592,7 +592,7 @@ TECHNICAL_500_TEMPLATE = """
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
var e = document.getElementById(arguments[i]);
|
||||
if (e) {
|
||||
e.style.display = e.style.display == 'none' ? 'block' : 'none';
|
||||
e.style.display = e.style.display == 'none' ? 'block': 'none';
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -608,7 +608,7 @@ TECHNICAL_500_TEMPLATE = """
|
||||
function switchPastebinFriendly(link) {
|
||||
s1 = "Switch to copy-and-paste view";
|
||||
s2 = "Switch back to interactive view";
|
||||
link.innerHTML = link.innerHTML == s1 ? s2 : s1;
|
||||
link.innerHTML = link.innerHTML == s1 ? s2: s1;
|
||||
toggle('browserTraceback', 'pastebinTraceback');
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ def serve(request, path, document_root=None, show_indexes=False):
|
||||
|
||||
To use, put a URL pattern such as::
|
||||
|
||||
(r'^(?P<path>.*)$', 'django.views.static.serve', {'document_root' : '/path/to/my/files/'})
|
||||
(r'^(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/path/to/my/files/'})
|
||||
|
||||
in your URLconf. You must provide the ``document_root`` param. You may
|
||||
also set ``show_indexes`` to ``True`` if you'd like to serve a basic index
|
||||
@@ -108,8 +108,8 @@ def directory_index(path, fullpath):
|
||||
f += '/'
|
||||
files.append(f)
|
||||
c = Context({
|
||||
'directory' : path + '/',
|
||||
'file_list' : files,
|
||||
'directory': path + '/',
|
||||
'file_list': files,
|
||||
})
|
||||
return HttpResponse(t.render(c))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user