'Load record data from database and update the values dict
@param record_id: the location record ID
@param values: the values dict'

def extract(self, record_id, values=None):

    if (values is None):
        values = {}
    for key in ('L0', 'L1', 'L2', 'L3', 'L4', 'L5', 'specific', 'parent', 'radius'):
        if (key not in values):
            values[key] = None
    values['id'] = record_id
    if (not record_id):
        return values
    db = current.db
    table = current.s3db.gis_location
    levels = self.load_levels
    lat = values.get('lat')
    lon = values.get('lon')
    wkt = values.get('wkt')
    radius = values.get('radius')
    address = values.get('address')
    postcode = values.get('postcode')
    record = db((table.id == record_id)).select(table.id, table.path, table.parent, table.level, table.gis_feature_type, table.inherited, table.lat, table.lon, table.wkt, table.radius, table.addr_street, table.addr_postcode, limitby=(0, 1)).first()
    if (not record):
        raise ValueError
    level = record.level
    path = record.path
    if (path is None):
        try:
            path = current.gis.update_location_tree({'id': record_id})
        except ValueError:
            pass
    path = ([] if (path is None) else path.split('/'))
    path_ok = True
    if level:
        values['level'] = level
        values['specific'] = None
        if (len(path) != (int(level[1:]) + 1)):
            path_ok = False
    else:
        values['parent'] = record.parent
        values['specific'] = record.id
        if (len(path) < (len(levels) + 1)):
            path_ok = False
        if (not record.inherited):
            if self.points:
                if ((lat is None) or (lat == '')):
                    if (record.gis_feature_type == 1):
                        lat = record.lat
                    else:
                        lat = None
                if ((lon is None) or (lon == '')):
                    if (record.gis_feature_type == 1):
                        lon = record.lon
                    else:
                        lon = None
            else:
                lat = None
                lon = None
            if (self.lines or self.polygons or self.circles):
                if (not wkt):
                    if (record.gis_feature_type != 1):
                        wkt = record.wkt
                        if (record.radius is not None):
                            radius = record.radius
                    else:
                        wkt = None
            else:
                wkt = None
        if (address is None):
            address = record.addr_street
        if (postcode is None):
            postcode = record.addr_postcode
    if path_ok:
        for level in levels:
            idx = int(level[1:])
            if (len(path) > idx):
                values[level] = int(path[idx])
    else:
        rows = db(table.id.belongs(path)).select(table.id, table.level)
        for row in rows:
            if row.level:
                values[row.level] = row.id
    values['address'] = address
    values['postcode'] = postcode
    values['lat'] = lat
    values['lon'] = lon
    values['wkt'] = wkt
    values['radius'] = radius
    return values
