mirror of
https://github.com/django/django.git
synced 2025-07-04 09:49:12 +00:00
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).
git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@6414 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
1025326602
commit
65b4cb2cca
@ -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
|
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
|
# Importing GeoIP
|
||||||
try:
|
try:
|
||||||
from django.contrib.gis.utils.geoip import GeoIP
|
from django.contrib.gis.utils.geoip import GeoIP
|
||||||
|
@ -30,10 +30,14 @@ Usage:
|
|||||||
geometry type, e.g. 'POINT', 'LINESTRING', 'POLYGON'.
|
geometry type, e.g. 'POINT', 'LINESTRING', 'POLYGON'.
|
||||||
|
|
||||||
Keyword Args:
|
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,
|
source_srs:
|
||||||
some shapefiles don't come with a '.prj' file)
|
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:
|
Example:
|
||||||
|
|
||||||
@ -167,7 +171,7 @@ def check_feature(feat, model_fields, mapping):
|
|||||||
else:
|
else:
|
||||||
raise Exception, 'Given mapping field "%s" not in given Model fields!' % model_field
|
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:
|
if ogr_field in ogc_types:
|
||||||
# At this time, no more than one geographic field per model =(
|
# At this time, no more than one geographic field per model =(
|
||||||
if HAS_GEO:
|
if HAS_GEO:
|
||||||
@ -218,6 +222,8 @@ def check_srs(layer, source_srs):
|
|||||||
sr = source_srs
|
sr = source_srs
|
||||||
elif isinstance(source_srs, SpatialRefSys):
|
elif isinstance(source_srs, SpatialRefSys):
|
||||||
sr = source_srs.srs
|
sr = source_srs.srs
|
||||||
|
elif isinstance(source_srs, (int, str)):
|
||||||
|
sr = SpatialReference(source_srs)
|
||||||
else:
|
else:
|
||||||
sr = layer.srs
|
sr = layer.srs
|
||||||
if not sr:
|
if not sr:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user