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)
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)
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)
#!/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)
def inverse(self,obj): return inverse_(self,obj)
def inverse(self,obj): return mapnik.inverse_(self,obj)
def inverse(self, obj): return mapnik.inverse_(self, obj)
#!/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)