Exemple #1
0
 def forward(self,geom):
     if self.to_prj.geographic and self.from_prj.geographic:
         return geom
     elif not self.to_prj.geographic and self.from_prj.geographic:
         return mapnik.forward_(geom,self.to_prj)
     elif self.to_prj.geographic and not self.from_prj.geographic:
         return mapnik.inverse_(geom,self.to_prj)
     elif not self.to_prj.geographic and not self.from_prj.geographic:
         if self.to_prj.params() == self.from_prj.params():
             return geom
         else:
             raise NotImplementedError(TRANSFORM_ERROR)
Exemple #2
0
 def forward(self,geom):
     if self.to_prj.geographic and self.from_prj.geographic:
         return geom
     elif not self.to_prj.geographic and self.from_prj.geographic:
         return forward_(geom,self.to_prj)
     elif self.to_prj.geographic and not self.from_prj.geographic:
         return inverse_(geom,self.to_prj)
     elif not self.to_prj.geographic and not self.from_prj.geographic:
         if self.to_prj.params() == self.from_prj.params():
             return geom
         else:
             raise AttributeError(TRANSFORM_ERROR)
Exemple #3
0
 def backward(self, geom):
     if self.to_prj.geographic and self.from_prj.geographic:
         return geom
     elif not self.to_prj.geographic and self.from_prj.geographic:
         return mapnik.inverse_(geom, self.to_prj)
     elif self.to_prj.geographic and not self.from_prj.geographic:
         return mapnik.forward_(geom, self.to_prj)
     elif not self.to_prj.geographic and not self.from_prj.geographic:
         if self.to_prj.params() == self.from_prj.params():
             return geom
         else:
             raise NotImplementedError(TRANSFORM_ERROR)
Exemple #4
0
#!/usr/bin/env python

from mapnik import Coord, Envelope, Projection, forward_, inverse_
import sys

if (len(sys.argv) < 2):
    print sys.argv[0] + " <epsg:code> <Coord or Envelope>"
    sys.exit(1)
else:
    epsg = sys.argv[1]
    p = Projection('+init=%s' % epsg)
    coord = map(float,sys.argv[2].split(','))
    if len(coord) == 2:
        long_lat = Coord(*coord)
        print 'Forwarded:',
        print p.forward(long_lat)
        print
        print 'Inversed:',
        print p.inverse(long_lat)      
    elif len(coord) == 4:
        extent = Envelope(*coord)
        print 'Forwarded:',
        print forward_(extent,p)
        print
        print 'Inversed:',
        print inverse_(extent,p)
Exemple #5
0
 def inverse(self,obj):
     return inverse_(self,obj)
Exemple #6
0
 def inverse(self,obj):
     return mapnik.inverse_(self,obj)
Exemple #7
0
 def inverse(self, obj):
     return mapnik.inverse_(self, obj)
Exemple #8
0
#!/usr/bin/env python

from mapnik import Coord, Envelope, Projection, forward_, inverse_
import sys

if (len(sys.argv) < 2):
    print sys.argv[0] + " <epsg:code> <Coord or Envelope>"
    sys.exit(1)
else:
    epsg = sys.argv[1]
    p = Projection('+init=%s' % epsg)
    coord = map(float, sys.argv[2].split(','))
    if len(coord) == 2:
        long_lat = Coord(*coord)
        print 'Forwarded:',
        print p.forward(long_lat)
        print
        print 'Inversed:',
        print p.inverse(long_lat)
    elif len(coord) == 4:
        extent = Envelope(*coord)
        print 'Forwarded:',
        print forward_(extent, p)
        print
        print 'Inversed:',
        print inverse_(extent, p)