/[thuban]/branches/WIP-pyshapelib-bramz/Thuban/Model/resource.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/Thuban/Model/resource.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1933 by bh, Tue Nov 11 16:37:53 2003 UTC revision 1964 by bh, Wed Nov 19 19:48:47 2003 UTC
# Line 15  __version__ = "$Revision$" Line 15  __version__ = "$Revision$"
15  import os  import os
16  import os.path  import os.path
17  import weakref  import weakref
18    import traceback
19    
20  import Thuban  import Thuban
21  from Thuban import _  from Thuban import _
# Line 32  projdir = \ Line 33  projdir = \
33    
34  PROJ_EXT = ".proj"  PROJ_EXT = ".proj"
35    
36  has_gdal_support = lambda: False  # Determine the status of GDAL support. If GDAL is supported
37  try:  # gdal_support_status will be set to the empty string, otherwise to a
38      # first try to see if our extension module is there. if it  # string with information why it isn't supported
39      # wasn't even compiled, we obviously don't have gdal support.  #
40      import gdalwarp  # GDAL is supported if we can import both the thuban specific gdalwarp
41    # module and the GDAL python bindings.
42      # now try to import the python extension. if this doesn't  for _module in ("gdalwarp", "gdal"):
43      # exist then we can't do anything.      try:
44      import gdal          __import__(_module)
45        except ImportError, val:
46      """Return True if the gdal library is available."""          gdal_support_status = (_("No GDAL support because module '%s'"
47      has_gdal_support = lambda: True                                   " cannot be imported. Python exception: '%s'")
48  except ImportError:                                 % (_module, str(val)))
49      pass          break
50    else:
51        gdal_support_status = ""
52    
53    def has_gdal_support():
54        return gdal_support_status == ""
55    
56    
57  projfile_cache = weakref.WeakValueDictionary()  projfile_cache = weakref.WeakValueDictionary()
58    
# Line 91  def write_proj_file(pf): Line 98  def write_proj_file(pf):
98      saver = ProjFileSaver(pf)      saver = ProjFileSaver(pf)
99      saver.write(pf.GetFilename())      saver.write(pf.GetFilename())
100    
101    #
102  # Constants for the get_system_proj_file function  # Constants for the get_system_proj_file function
103    #
104    
105    # The default projection file with a few predefined projections
106  DEFAULT_PROJ_FILE = "defaults.proj"  DEFAULT_PROJ_FILE = "defaults.proj"
107    
108    # The epsg projections.
109  EPSG_PROJ_FILE = "epsg.proj"  EPSG_PROJ_FILE = "epsg.proj"
110    
111    # Deprecated EPSG projections.
112    EPSG_DEPRECATED_PROJ_FILE = "epsg-deprecated.proj"
113    
114  def get_system_proj_file(filename):  def get_system_proj_file(filename):
115      """Return the projections from the indicated file and a list with warnings      """Return the projections from the indicated file and a list with warnings
116    
# Line 103  def get_system_proj_file(filename): Line 118  def get_system_proj_file(filename):
118      with Thuban's default projection files (Resources/Projections/). If      with Thuban's default projection files (Resources/Projections/). If
119      possible callers should not use hardwired string literal for the      possible callers should not use hardwired string literal for the
120      name to avoid unnecessary duplication. Instead they should use one      name to avoid unnecessary duplication. Instead they should use one
121      of the predefined constants, currently DEFAULT_PROJ_FILE or      of the predefined constants, currently DEFAULT_PROJ_FILE,
122      EPSG_PROJ_FILE.      EPSG_PROJ_FILE or EPSG_DEPRECATED_PROJ_FILE.
123    
124      The return value is a tuple with the projections in a ProjFile      The return value is a tuple with the projections in a ProjFile
125      object and a list of strings with warning messages. The warnings      object and a list of strings with warning messages. The warnings

Legend:
Removed from v.1933  
changed lines
  Added in v.1964

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26