'Testing (HEX)EWKB output.'

def test_hexewkb(self):

    ogc_hex = '01010000000000000000000000000000000000F03F'
    ogc_hex_3d = '01010000800000000000000000000000000000F03F0000000000000040'
    hexewkb_2d = '0101000020E61000000000000000000000000000000000F03F'
    hexewkb_3d = '01010000A0E61000000000000000000000000000000000F03F0000000000000040'
    pnt_2d = Point(0, 1, srid=4326)
    pnt_3d = Point(0, 1, 2, srid=4326)
    self.assertEqual(ogc_hex, pnt_2d.hex)
    self.assertEqual(ogc_hex_3d, pnt_3d.hex)
    self.assertEqual(hexewkb_2d, pnt_2d.hexewkb)
    if GEOS_PREPARE:
        self.assertEqual(hexewkb_3d, pnt_3d.hexewkb)
        self.assertEqual(True, GEOSGeometry(hexewkb_3d).hasz)
    else:
        try:
            hexewkb = pnt_3d.hexewkb
        except GEOSException:
            pass
        else:
            self.fail(u'Should    have    raised    GEOSException.')
    self.assertEqual(memoryview(a2b_hex(hexewkb_2d)), pnt_2d.ewkb)
    if GEOS_PREPARE:
        self.assertEqual(memoryview(a2b_hex(hexewkb_3d)), pnt_3d.ewkb)
    else:
        try:
            ewkb = pnt_3d.ewkb
        except GEOSException:
            pass
        else:
            self.fail(u'Should    have    raised    GEOSException')
    self.assertEqual(4326, GEOSGeometry(hexewkb_2d).srid)
