Example #1
0
 def __init__(self, proj):
   if isinstance(proj, CRS):
     self._crs = proj
   elif isinstance(proj, Projection):
     self._crs = proj._crs
   elif isinstance(proj, (str,unicode)):
     try:
        self._crs = crs.decode(proj)
     except:
        try:
          self._crs = crs.parseWKT(proj)
        except:
          raise Exception('Unable to determine projection from %s' % proj)
Example #2
0
 def __init__(self, proj):
     if isinstance(proj, CRS):
         self._crs = proj
     elif isinstance(proj, Projection):
         self._crs = proj._crs
     elif isinstance(proj, (str, unicode)):
         try:
             self._crs = crs.decode(proj)
         except:
             try:
                 self._crs = crs.parseWKT(proj)
             except:
                 raise Exception('Unable to determine projection from %s' %
                                 proj)
Example #3
0
    def get_crs(clz, crs):
        """ Converts crs definition to GeoTools CRS obj. """
        if isinstance(crs, CoordinateReferenceSystem):
            return crs

        # @TODO
        # Eventually should add handling for
        # proj4 strings, dicts.

        if isinstance(crs, str) or isinstance(crs, unicode):
            if crs.startswith('EPSG:'):
                return CRS.decode(crs)
            # Otherwise assume WKT.
            else:
                return CRS.parseWKT(crs)