Django

Code

Changeset 6414

Show
Ignore:
Timestamp:
09/24/07 17:18:00 (1 year ago)
Author:
jbronn
Message:

gis: utils module now only imports LayerMapping? when GDAL is installed; the source_srs keyword lf LayerMapping? may now take integer and string parameters (for SRID and WKT spatial references, respectively).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/gis/django/contrib/gis/utils/__init__.py

    r6387 r6414  
    1 from django.contrib.gis.utils.layermapping import LayerMapping 
     1""" 
     2 This module contains useful utilities for GeoDjango. 
     3""" 
     4 
    25from django.contrib.gis.utils.inspect_data import sample 
     6 
     7# Importing LayerMapping (will not be done if GDAL is not installed) 
     8from django.contrib.gis.gdal import HAS_GDAL 
     9if HAS_GDAL: 
     10    from django.contrib.gis.utils.layermapping import LayerMapping 
    311 
    412# Importing GeoIP 
  • django/branches/gis/django/contrib/gis/utils/layermapping.py

    r6369 r6414  
    3131 
    3232Keyword Args: 
    33   layer -- The index of the layer to use from the Data Source (defaults to 0) 
    34  
    35   source_srs -- Use this to specify the source SRS manually (for example,  
    36                  some shapefiles don't come with a '.prj' file) 
     33  layer:  
     34    The index of the layer to use from the Data Source (defaults to 0) 
     35 
     36  source_srs: 
     37    Use this to specify the source SRS manually (for example, some  
     38     shapefiles don't come with a '.prj' file).  A SRID integer, a 
     39     WKT string, a SpatialReference, and a SpatialRefSys object are 
     40     all valid parameters here. 
    3741 
    3842Example: 
     
    168172            raise Exception, 'Given mapping field "%s" not in given Model fields!' % model_field 
    169173 
    170         ## Handling if we get a geometry in the Field ### 
     174        ### Handling if we get a geometry in the Field ### 
    171175        if ogr_field in ogc_types: 
    172176            # At this time, no more than one geographic field per model =( 
     
    219223    elif isinstance(source_srs, SpatialRefSys): 
    220224        sr = source_srs.srs 
     225    elif isinstance(source_srs, (int, str)): 
     226        sr = SpatialReference(source_srs) 
    221227    else: 
    222228        sr = layer.srs