Ejemplo n.º 1
0
 def setUp(self):
     self.slippyMap = InasafeSlippyMap(PARENT)
Ejemplo n.º 2
0
 def setUp(self):
     self.slippyMap = InasafeSlippyMap(PARENT)
Ejemplo n.º 3
0
class SlippyMapTest(unittest.TestCase):
    """Test the Slippy map widget"""
    def setUp(self):
        self.slippyMap = InasafeSlippyMap(PARENT)

    def test_flipLatitude(self):
        """ test flipLatitude function """
        myMessage = "Number don't match. expect {0} but got {1} "

        myNumber = self.slippyMap.flipLatitude(20)
        assert myNumber == 20, myMessage.format(20, myNumber)

        myNumber = self.slippyMap.flipLatitude(100)
        assert myNumber == 80, myMessage.format(80, myNumber)

        myNumber = self.slippyMap.flipLatitude(300)
        assert myNumber == -60, myMessage.format(-60, myNumber)

        myNumber = self.slippyMap.flipLatitude(-20)
        assert myNumber == -20, myMessage.format(-20, myNumber)

        myNumber = self.slippyMap.flipLatitude(-100)
        assert myNumber == -80, myMessage.format(80, myNumber)

        #FIXME(gigih): still fail, expected value is 60 the result is 120


#        myNumber = self.slippyMap.flipLatitude(-300)
#        assert myNumber == 60, myMessage.format(60, myNumber)

    def test_flipLongitude(self):
        """ test flipLongitude function """

        myMessage = "Number don't match. expect {0} but got {1} "

        myNumber = self.slippyMap.flipLatitude(20)
        assert myNumber == 20, myMessage.format(20, myNumber)

        myNumber = self.slippyMap.flipLatitude(200)
        assert myNumber == -20, myMessage.format(-20, myNumber)

        myNumber = self.slippyMap.flipLatitude(400)
        assert myNumber == 40, myMessage.format(40, myNumber)

        myNumber = self.slippyMap.flipLatitude(-20)
        assert myNumber == -20, myMessage.format(-20, myNumber)

        myNumber = self.slippyMap.flipLatitude(-200)
        assert myNumber == 20, myMessage.format(20, myNumber)

    def test_calculateExtends(self):
        """ test calculateExtends function """

        self.slippyMap.zoom = 9
        self.slippyMap.latitude = 80
        self.slippyMap.longitude = 81
        self.slippyMap.width = 400
        self.slippyMap.height = 400

        self.slippyMap.calculateExtent()

        myMessage = "Number don't match. expect {0} but got {1} "

        myNumber = self.slippyMap.tlLat
        myResult = 79.45078125
        assert myNumber == myResult, myMessage.format(myResult, myNumber)

        myNumber = self.slippyMap.tlLng
        myResult = 80.45078125
        assert myNumber == myResult, myMessage.format(myResult, myNumber)

        myNumber = self.slippyMap.brLat
        myResult = 80.54921875
        assert myNumber == myResult, myMessage.format(myResult, myNumber)

        myNumber = self.slippyMap.brLng
        myResult = 81.54921875
        assert myNumber == myResult, myMessage.format(myResult, myNumber)
Ejemplo n.º 4
0
class SlippyMapTest(unittest.TestCase):
    """Test the Slippy map widget"""

    def setUp(self):
        self.slippyMap = InasafeSlippyMap(PARENT)

    def test_flipLatitude(self):
        """ test flipLatitude function """
        myMessage = "Number don't match. expect {0} but got {1} "

        myNumber = self.slippyMap.flipLatitude(20)
        assert myNumber == 20, myMessage.format(20, myNumber)

        myNumber = self.slippyMap.flipLatitude(100)
        assert myNumber == 80, myMessage.format(80, myNumber)

        myNumber = self.slippyMap.flipLatitude(300)
        assert myNumber == -60, myMessage.format(-60, myNumber)

        myNumber = self.slippyMap.flipLatitude(-20)
        assert myNumber == -20, myMessage.format(-20, myNumber)

        myNumber = self.slippyMap.flipLatitude(-100)
        assert myNumber == -80, myMessage.format(80, myNumber)

        # FIXME(gigih): still fail, expected value is 60 the result is 120

    #        myNumber = self.slippyMap.flipLatitude(-300)
    #        assert myNumber == 60, myMessage.format(60, myNumber)

    def test_flipLongitude(self):
        """ test flipLongitude function """

        myMessage = "Number don't match. expect {0} but got {1} "

        myNumber = self.slippyMap.flipLatitude(20)
        assert myNumber == 20, myMessage.format(20, myNumber)

        myNumber = self.slippyMap.flipLatitude(200)
        assert myNumber == -20, myMessage.format(-20, myNumber)

        myNumber = self.slippyMap.flipLatitude(400)
        assert myNumber == 40, myMessage.format(40, myNumber)

        myNumber = self.slippyMap.flipLatitude(-20)
        assert myNumber == -20, myMessage.format(-20, myNumber)

        myNumber = self.slippyMap.flipLatitude(-200)
        assert myNumber == 20, myMessage.format(20, myNumber)

    def test_calculateExtends(self):
        """ test calculateExtends function """

        self.slippyMap.zoom = 9
        self.slippyMap.latitude = 80
        self.slippyMap.longitude = 81
        self.slippyMap.width = 400
        self.slippyMap.height = 400

        self.slippyMap.calculateExtent()

        myMessage = "Number don't match. expect {0} but got {1} "

        myNumber = self.slippyMap.tlLat
        myResult = 79.45078125
        assert myNumber == myResult, myMessage.format(myResult, myNumber)

        myNumber = self.slippyMap.tlLng
        myResult = 80.45078125
        assert myNumber == myResult, myMessage.format(myResult, myNumber)

        myNumber = self.slippyMap.brLat
        myResult = 80.54921875
        assert myNumber == myResult, myMessage.format(myResult, myNumber)

        myNumber = self.slippyMap.brLng
        myResult = 81.54921875
        assert myNumber == myResult, myMessage.format(myResult, myNumber)