def _substitute_lat_lon(location_dict):
    """
    Replace "lat" and "lon" keys in location_dict with "ST_SetSRID(ST_Point(lon, lat), 4326)"
    This function is used by `LonLatSpatialUnit.location_subset_clause()`
    """
    location_copy = location_dict.copy()
    if 'lon' in location_copy and 'lat' in location_copy:
        lon = location_copy.pop('lon')
        lat = location_copy.pop('lat')
        location_copy['ST_SetSRID(ST_Point(lon, lat), 4326)'
            ] = f'ST_SetSRID(ST_Point({lon}, {lat}), 4326)'
    return location_copy
