Example #1
0
 def clean(self):
     data = super(TileForm, self).clean()
     x, y, z = map(data.get, ('x', 'y', 'z'))
     # Create bbox from NW and SE tile corners.
     try:
         extent = (tile.to_lonlat(x, y, z) +
                   tile.to_lonlat(x + 1, y + 1, z))
     except ValueError:
         extent = (0, 0, 0, 0)
     geom = gdal.OGRGeometry.from_bbox(extent)
     geom.srid = self.fields['bbox'].srid
     data['bbox'] = geom
     return data
Example #2
0
 def clean(self):
     data = super(TileForm, self).clean()
     x, y, z = map(data.get, ('x', 'y', 'z'))
     # Create bbox from NW and SE tile corners.
     try:
         extent = (tile.to_lonlat(x, y, z) +
                   tile.to_lonlat(x + 1, y + 1, z))
     except ValueError:
         extent = (0, 0, 0, 0)
     geom = gdal.OGRGeometry.from_bbox(extent)
     geom.srid = self.fields['bbox'].srid
     data['bbox'] = geom
     return data
Example #3
0
 def test_to_lonlat(self):
     self.assertAlmostEqual(tile.to_lonlat(553, 346, 10),
                            (14.4140625, 50.28933925329178))