'Initializes Geometry on either WKT or an OGR pointer as input.'

def __init__(self, geom_input, srs=None):

    str_instance = isinstance(geom_input, six.string_types)
    if (str_instance and hex_regex.match(geom_input)):
        geom_input = memoryview(a2b_hex(geom_input.upper().encode()))
        str_instance = False
    if str_instance:
        wkt_m = wkt_regex.match(geom_input)
        json_m = json_regex.match(geom_input)
        if wkt_m:
            if wkt_m.group('srid'):
                srs = int(wkt_m.group('srid'))
            if (wkt_m.group('type').upper() == 'LINEARRING'):
                g = capi.create_geom(OGRGeomType(wkt_m.group('type')).num)
                capi.import_wkt(g, byref(c_char_p(wkt_m.group('wkt').encode())))
            else:
                g = capi.from_wkt(byref(c_char_p(wkt_m.group('wkt').encode())), None, byref(c_void_p()))
        elif json_m:
            g = capi.from_json(geom_input.encode())
        else:
            ogr_t = OGRGeomType(geom_input)
            g = capi.create_geom(OGRGeomType(geom_input).num)
    elif isinstance(geom_input, memoryview):
        g = capi.from_wkb(bytes(geom_input), None, byref(c_void_p()), len(geom_input))
    elif isinstance(geom_input, OGRGeomType):
        g = capi.create_geom(geom_input.num)
    elif isinstance(geom_input, self.ptr_type):
        g = geom_input
    else:
        raise OGRException(('Invalid    input    type    for    OGR    Geometry    construction:    %s' % type(geom_input)))
    if (not g):
        raise OGRException(('Cannot    create    OGR    Geometry    from    input:    %s' % str(geom_input)))
    self.ptr = g
    if bool(srs):
        self.srs = srs
    self.__class__ = GEO_CLASSES[self.geom_type.num]
