Author: jbronn
Date: 2007-09-24 17:18:00 -0500 (Mon, 24 Sep 2007)
New Revision: 6414
Modified:
django/branches/gis/django/contrib/gis/utils/__init__.py
django/branches/gis/django/contrib/gis/utils/layermapping.py
Log:
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).
Modified: django/branches/gis/django/contrib/gis/utils/__init__.py
===================================================================
--- django/branches/gis/django/contrib/gis/utils/__init__.py 2007-09-24
20:29:27 UTC (rev 6413)
+++ django/branches/gis/django/contrib/gis/utils/__init__.py 2007-09-24
22:18:00 UTC (rev 6414)
@@ -1,6 +1,14 @@
-from django.contrib.gis.utils.layermapping import LayerMapping
+"""
+ This module contains useful utilities for GeoDjango.
+"""
+
from django.contrib.gis.utils.inspect_data import sample
+# Importing LayerMapping (will not be done if GDAL is not installed)
+from django.contrib.gis.gdal import HAS_GDAL
+if HAS_GDAL:
+ from django.contrib.gis.utils.layermapping import LayerMapping
+
# Importing GeoIP
try:
from django.contrib.gis.utils.geoip import GeoIP
Modified: django/branches/gis/django/contrib/gis/utils/layermapping.py
===================================================================
--- django/branches/gis/django/contrib/gis/utils/layermapping.py
2007-09-24 20:29:27 UTC (rev 6413)
+++ django/branches/gis/django/contrib/gis/utils/layermapping.py
2007-09-24 22:18:00 UTC (rev 6414)
@@ -30,10 +30,14 @@
geometry type, e.g. 'POINT', 'LINESTRING', 'POLYGON'.
Keyword Args:
- layer -- The index of the layer to use from the Data Source (defaults to 0)
+ layer:
+ The index of the layer to use from the Data Source (defaults to 0)
- source_srs -- Use this to specify the source SRS manually (for example,
- some shapefiles don't come with a '.prj' file)
+ source_srs:
+ Use this to specify the source SRS manually (for example, some
+ shapefiles don't come with a '.prj' file). A SRID integer, a
+ WKT string, a SpatialReference, and a SpatialRefSys object are
+ all valid parameters here.
Example:
@@ -167,7 +171,7 @@
else:
raise Exception, 'Given mapping field "%s" not in given Model
fields!' % model_field
- ## Handling if we get a geometry in the Field ###
+ ### Handling if we get a geometry in the Field ###
if ogr_field in ogc_types:
# At this time, no more than one geographic field per model =(
if HAS_GEO:
@@ -218,6 +222,8 @@
sr = source_srs
elif isinstance(source_srs, SpatialRefSys):
sr = source_srs.srs
+ elif isinstance(source_srs, (int, str)):
+ sr = SpatialReference(source_srs)
else:
sr = layer.srs
if not sr:
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---