cyberdelia / heroku-geo-buildpack

Geo libraries for Heroku
https://github.com/heroku/heroku-geo-buildpack
114 stars 135 forks source link

Bug in projections. #7

Closed galuszkak closed 11 years ago

galuszkak commented 11 years ago

I think this is related to this buildpack. My transfrom projections doesn't work. Code to reproduce problem:

In [17]: from django.contrib.gis.geos import Point

In [18]: we = Point(-33.9123110, 151.0226540, srid=900913)

In [19]: we.transform(4326)
---------------------------------------------------------------------------
OGRException                              Traceback (most recent call last)
/app/.heroku/python/lib/python2.7/site-packages/django/core/management/commands/shell.py in <module>()
----> 1 we.transform(4326)

/app/.heroku/python/lib/python2.7/site-packages/django/contrib/gis/geos/geometry.pyc in transform(self, ct, clone)
    510 
    511         # Creating an OGR Geometry, which is then transformed.
--> 512         g = self.ogr
    513         g.transform(ct)
    514         # Getting a new GEOS pointer

/app/.heroku/python/lib/python2.7/site-packages/django/contrib/gis/geos/geometry.pyc in ogr(self)
    463         if gdal.HAS_GDAL:
    464             if self.srid:
--> 465                 return gdal.OGRGeometry(self.wkb, self.srid)
    466             else:
    467                 return gdal.OGRGeometry(self.wkb)

/app/.heroku/python/lib/python2.7/site-packages/django/contrib/gis/gdal/geometries.py in __init__(self, geom_input, srs)
    123 
    124         # Assigning the SpatialReference object to the geometry, if valid.
--> 125         if bool(srs): self.srs = srs
    126 
    127         # Setting the class depending upon the OGR Geometry Type

/app/.heroku/python/lib/python2.7/site-packages/django/contrib/gis/gdal/geometries.py in _set_srs(self, srs)
    283             srs_ptr = srs.ptr
    284         elif isinstance(srs, six.integer_types + six.string_types):
--> 285             sr = SpatialReference(srs)
    286             srs_ptr = sr.ptr
    287         else:

/app/.heroku/python/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.py in __init__(self, srs_input)
     94             self.import_user_input(srs_input)
     95         elif srs_type == 'epsg':
---> 96             self.import_epsg(srs_input)
     97 
     98     def __del__(self):

/app/.heroku/python/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.py in import_epsg(self, epsg)
    280     def import_epsg(self, epsg):
    281         "Imports the Spatial Reference from the EPSG code (an integer)."
--> 282         capi.from_epsg(self.ptr, epsg)
    283 
    284     def import_proj(self, proj):

/app/.heroku/python/lib/python2.7/site-packages/django/contrib/gis/gdal/prototypes/errcheck.py in check_errcode(result, func, cargs)
    106     Check the error code returned (c_int).
    107     """
--> 108     check_err(result)
    109     return
    110 

/app/.heroku/python/lib/python2.7/site-packages/django/contrib/gis/gdal/error.pyc in check_err(code)
     38     elif code in OGRERR_DICT:
     39         e, msg = OGRERR_DICT[code]
---> 40         raise e(msg)
     41     else:
     42         raise OGRException('Unknown error code: "%s"' % code)

OGRException: OGR failure.
cyberdelia commented 11 years ago

It's seems that gdal need to have GDAL_DATA setup properly, I'm working on it.

cyberdelia commented 11 years ago

GDAL_DATA is now correctly setup.

>>> from django.contrib.gis.geos import Point
>>> we = Point(-33.9123110, 151.0226540, srid=900913)
>>> we.transform(4326)
>>> 
galuszkak commented 11 years ago

It works. Thanks @cyberdelia !